我在 RGeo 中存储一个点时遇到了一些麻烦。
初始化程序/rgeo.rb
RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
# By default, use the GEOS implementation for spatial columns.
config.default = RGeo::Geos.factory_generator
# But use a geographic implementation for point columns.
config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "point")
end
宝石文件:
gem 'activerecord-postgis-adapter'
gem 'rgeo'
gem 'rgeo-activerecord'
移民:
def change
add_column :location, limit: {:srid=>4326, :type=>"point", :geometric=>true}
end
我收到这个错误
2.4.0-rc1 :012 > u.location = 'POINT(-100.192823 47.23178)'
=> "POINT(-100.192823 47.23178)"
2.4.0-rc1 :013 > u.location
ArgumentError: invalid value for Float(): "POINT(-100.192823 47.23178)"
我的问题与这个问题基本相同,但那里的解决方案似乎都不起作用。任何帮助,将不胜感激!