Hi,
I am trying to get distance calculations working within rgeo.
I am using MapQuest to convert an addresses to a longitude / latitude.
When calculating the distance (both with ST_DISTANCE with postgis and rgeo's distance method) myself I get an answer around 2.8km.
When doing the same thing on
https://www.daftlogic.com/projects-google-maps-distance-calculator.htm I get an answer of approximatly 1.7km.
This is a huge relative difference.
I assume this is because I am using the wrong geometry types, but I am not sure which I should be using...
Initializer
RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
config.default = RGeo::Geographic.spherical_factory(srid: 4326)
end
Migration
t.st_point :latlon, geographic: true
latlon1.distance(latlon2) => 2825
latlon1 => #<RGeo::Geographic::SphericalPointImpl:0x2ad8aa0df180 "POINT (51.219323 4.425553)">
latlon2 => #<RGeo::Geographic::SphericalPointImpl:0x2ad8a9fc770c "POINT (51.221067 4.400229)">
I also tried with the simple mercator projection factory, but that gave very similar results.
Regards,
Nathan