我想保存一个多边形。
这是 Geojson在此处输入链接描述
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