我想保存 GeoJSON 多边形

I want to save GeoJSON polygon

我想保存多边形。

这是 Geojson enter link description here

str1 = "geojson....."
geom = RGeo::GeoJSON.decode(str1, json_parser: :json)
l = Limit.new
l.multipoligono = geom
l.save


NoMethodError: undefined methodfactory' for #RGeo::GeoJSON::FeatureCollection:0x3fc7febb7424`

这是我的rgeo.rb

RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
config.default = RGeo::Geos.factory_generator
config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "point")
config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "multi_polygon")
config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "geometry_collection")

end

有 110 颗星,我认为 this is how they do it in ruby

hash = RGeo::GeoJSON.encode(feature)
hash.to_json == str2      # => true

也就是说,我不会那样做。我也不会使用 Ruby。查看 PostGIS 的 ST_AsGeoJSON。它 returns geojson 的特征部分。也就是说,将RGeo从等式中剔除。