class SpatialFeatures::Importers::JsonArcGIS
Public Instance Methods
cache_key()
click to toggle source
# File lib/spatial_features/importers/json_arcgis.rb, line 7 def cache_key @cache_key ||= Digest::MD5.hexdigest(features.to_json) end
Private Instance Methods
each_record() { |open_struct( :feature_type => record['type'], :geog => geom_from_json(record), :metadata => record| ... }
click to toggle source
# File lib/spatial_features/importers/json_arcgis.rb, line 13 def each_record(&block) json = esri_json_to_geojson(@data) json['features'].each do |record| yield OpenStruct.new( :feature_type => record['geometry']['type'], :geog => geom_from_json(record['geometry']), :metadata => record['properties'] ) end end
esri_json_to_geojson(url)
click to toggle source
# File lib/spatial_features/importers/json_arcgis.rb, line 24 def esri_json_to_geojson(url) JSON.parse(`ogr2ogr -f GeoJSON /dev/stdout "#{url}" OGRGeoJSON`) end
geom_from_json(geometry)
click to toggle source
# File lib/spatial_features/importers/json_arcgis.rb, line 28 def geom_from_json(geometry) ActiveRecord::Base.connection.select_value("SELECT ST_GeomFromGeoJSON('#{geometry.to_json}')") end