我在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
的Gemfile:
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)"
我的问题与此question基本相同,但似乎没有任何解决方案可行。任何帮助将不胜感激!