Sha256: 94dd40c7ce4a3b6eed8f38cbf7268559bd59e37b58b673dc1bc787fe5dac4c66

Contents?: true

Size: 839 Bytes

Versions: 1

Compression:

Stored size: 839 Bytes

Contents

#!/usr/bin/env ruby

require 'geohydra'
require 'json'

class BuildStageOptions < GeoHydra::Process
  # @param [String] shp assumes foo/bar/aa111bb1111/temp/shapefile.shp
  def doit(shp)
    r = {}
    r['druid'] = File.basename(File.dirname(File.dirname(shp)))
    raise ArgumentError, "SyntaxError: Not a shapefile: #{shp}" unless GeoHydra::Utils.shapefile?(shp)
    r['geometryType'] = GeoHydra::Transform.geometry_type(shp)
    r['filename'] = File.basename(shp)
    File.open(File.join(File.dirname(shp), 'geoOptions.json'), 'w') do |f|
      f.puts r.to_json.to_s
    end
  end

  def run(args)
    if args.empty?
      Dir.glob('/var/geomdtk/current/stage/**/temp/*.shp') do |shp|
        doit(shp)
      end
    else
      args.each do |shp|
        doit(shp)
      end
    end
  end
end

# __MAIN__
BuildStageOptions.new.run(ARGV)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geohydra-0.3.3 bin/build_stage_options.rb