Sha256: 92a56966b066b85a7ce4c283c3891a3524656661f1b255e0619cf26194c686d1

Contents?: true

Size: 721 Bytes

Versions: 5

Compression:

Stored size: 721 Bytes

Contents

require 'ostruct'
require 'digest/md5'

module SpatialFeatures
  module Importers
    class JsonArcGIS < Base
      def cache_key
        @cache_key ||= Digest::MD5.hexdigest(features.to_json)
      end

      private

      def each_record(&block)
        json = esri_json_to_geojson(@data)
        json['features'].each do |record|
          yield OpenStruct.new(
            :feature_type => record['geometry']['type'],
            :geog => SpatialFeatures::Utils.geom_from_json(record['geometry']),
            :metadata => record['properties']
          )
        end
      end

      def esri_json_to_geojson(url)
        JSON.parse(`ogr2ogr -f GeoJSON /dev/stdout "#{url}" OGRGeoJSON`)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spatial_features-2.20.0 lib/spatial_features/importers/json_arcgis.rb
spatial_features-2.19.1 lib/spatial_features/importers/json_arcgis.rb
spatial_features-2.19.0 lib/spatial_features/importers/json_arcgis.rb
spatial_features-2.18.0 lib/spatial_features/importers/json_arcgis.rb
spatial_features-2.17.3 lib/spatial_features/importers/json_arcgis.rb