Re: earthdistance is not giving correct results. - Mailing list pgsql-general

From Michael Fuhr
Subject Re: earthdistance is not giving correct results.
Date
Msg-id 20041003020802.GA26078@winnie.fuhr.org
Whole thread Raw
In response to Re: earthdistance is not giving correct results.  (Jean-Luc Lachance <jllachan@sympatico.ca>)
Responses Re: earthdistance is not giving correct results.
Re: earthdistance is not giving correct results.
List pgsql-general
On Sat, Oct 02, 2004 at 09:29:16PM -0400, Jean-Luc Lachance wrote:
> Maybe it would work with the right long & lat...
> try
> Protland OR -122.67555, 45.51184
> Seattle WA -122.32956, 47.60342

It doesn't matter which hemisphere the longitudes are in as long
as they're in the same hemisphere:

test=> select earth_distance(ll_to_earth('122.55688','45.513746'),ll_to_earth('122.396357','47.648845'));
  earth_distance
------------------
 128862.563227506
(1 row)

test=> select earth_distance(ll_to_earth('-122.55688','45.513746'),ll_to_earth('-122.396357','47.648845'));
  earth_distance
------------------
 128862.563227506
(1 row)

What *does* matter is that one specify (lat, lon) instead of
(lon, lat):

test=> select earth_distance(ll_to_earth('45.513746', '122.55688'),ll_to_earth('47.648845', '122.396357'));
  earth_distance
------------------
 237996.256627247
(1 row)

That's 238km, or about 148mi; using your coordinates gives almost
the same answer, about 234km or 146mi.  As I said, the distance
between Portland and Seattle is around 150mi.

> Also, do not forget that it is the line distance not the driving distance.

I doubt anybody thought that earth_distance() was calculating driving
distance.  How would it know what route to follow without an extensive
road database and a route specification?

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-general by date:

Previous
From: Christopher Browne
Date:
Subject: Re: VACUUM FULL on 24/7 server
Next
From: Tom Lane
Date:
Subject: Re: earthdistance is not giving correct results.