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/ ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match