基本上,我有三个坐标。
Here is a Google Map with these three points for comparison.
现在使用Earthdistance module for Postgresql我将使用<@>
运算符来获取两点之间的航空里程。
SELECT 'Celeveland, TN' AS origin
, '(35.255097,-84.86844)' AS origin_cords
, city || ', ' || region AS dest
, cords AS cords
, cords <@> '(35.255097,-84.86844)'::point AS distance_miles
FROM maxmind.city
WHERE (region = 'GA' AND city ='Atlanta') OR (region = 'GA' AND city = 'Columbus')
;
然而,这就是我得到的......
origin | origin_cords | dest | cords | distance_miles
----------------+-----------------------+--------------+--------------------------+------------------
Celeveland, TN | (35.255097,-84.86844) | Columbus, GA | (32.4608333,-84.9877778) | 18.952732930393
Celeveland, TN | (35.255097,-84.86844) | Atlanta, GA | (33.7488889,-84.3880556) | 34.5888147812704
(2 rows)
所以它告诉我的是,乔治亚州的哥伦布更接近克利夫兰(18.95mi),TN比亚特兰大,乔治亚州(34.58mi)更近,尽管我可以清楚地说明这不是真的。我在Postgresql 9.1和Postgresql 8.4上确认了这些结果。
答案 0 :(得分:3)
反向坐标顺序, PostGIS expects纬度为第一个。
UPD:抱歉,我对postgis标签感到困惑,这不是PostGIS功能。从您连接的地球距离文档:“第一个组件用于表示经度(以度为单位),第二个组件用于表示以度为单位的纬度”。你是对的,它适用于谷歌地图,但顺序相反。
UPD 2 :看来我们有GIS Stackexchange整个。