Skip to content
November 1, 2011 / windperson

由兩點經緯度數值計算實際距離的方法

因為地球是圓的,所以從經緯度坐標計算距離,若直接用國中數學教的√((x1-x2)^2+(y1-y2)^2),會很不準。

實際上的算法是要回歸經緯度的座標值是球面座標上的弳度來算(Great-circle distance

但如果要認真計較的話,地球不是正球體,而是橢圓體,實際正解的算法又太麻煩。

所以在程式Implement上,都是採用較簡易的算法:
http://big5.china-code.net/al-ccKHgZqOcS-162657.html
http://panyee.cnblogs.com/archive/2006/07/04/442771.html

下面這個是在Objective-C的實作:
http://stackoverflow.com/questions/1950145/large-volume-geocoding-and-distance-checking

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: