3
基本上,我有三個座標在玩。爲什麼<@>不能在Postgresql中返回正確的距離?
- 克利夫蘭田納西州 - (35.255097,-84.86844) - 這是原產地。
- 佐治亞州亞特蘭大 - (32.4608333,-84.9877778) - 這更接近該起源。
- 哥倫布,喬治亞州 - (33.7488889,-84.3880556) - 這是絕對更遠。
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)
那麼它告訴我的是,哥倫布,GA接近克里夫蘭(18.95mi),TN比亞特蘭大,GA(34.58mi ),儘管我可以清楚地說出這是不正確的。我已經在Postgresql 9.1和Postgresql 8.4上確認了這些結果。
哪些線順序顛倒了?我相信緯度是第一位,它在Google地圖中起作用。 – 2012-02-22 04:47:34
請參閱更新。 – 2012-02-22 05:09:45
我不明白你的更新,你是否確定了我的問題的解決方案,或者你自己的答案中有問題? – 2012-02-22 05:12:05