2

I'm having some trouble storing a point in RGeo.

initializer/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'

Migration:

def change
 add_column :location, limit: {:srid=>4326, :type=>"point", :geometric=>true}
end

I get this error

    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)"

My problem is essentially the same as this question, but none of the solutions there seems to work. Any help would be appreciated!

Community
  • 1
  • 1
Ivan
  • 93
  • 1
  • 5

0 Answers0