I'm trying to compare the distance calculation that RGeo performs to ST_DistanceSphere. I thought they should give the same result given a spherical factory, but they don't. I'm hoping someone can help me understand why.
Here is what I'm doing:
Using RGeo:
factory = RGeo::Geographic.spherical_factory(:srid => 4326)
point_sfo = factory.point(-122.3748433, 37.61900194)
point_lga = factory.point(-73.87260917, 40.77724306)
distance_meters = point_sfo.distance(point_lga)
distance_miles = distance_meters * 0.000621371
=> 2575.9719632552024
Using PostGIS:
SELECT ST_DistanceSphere(
ST_GeomFromText('POINT(-122.3748433 37.61900194)',4326), -- SFO
ST_GeomFromText('POINT(-73.87260917 40.77724306)',4326) -- LGA
)::NUMERIC * 0.000621371 AS dist_miles
2573.09304783170447076
Thank you,
Barrett