1
這些是我的2個點我怎樣才能得到他們之間的距離(米)?找到2個經緯度點之間的距離(單位:米)
52.33816422 -106.2828899 52.33816422 -106.2828634
所有convesions programms的尋找ddmm.mmmmmmm和dddmm.mmmmmmmm
這些是我的2個點我怎樣才能得到他們之間的距離(米)?找到2個經緯度點之間的距離(單位:米)
52.33816422 -106.2828899 52.33816422 -106.2828634
所有convesions programms的尋找ddmm.mmmmmmm和dddmm.mmmmmmmm
def distance loc1, loc2
rad_per_deg = Math::PI/180 # PI/180
rkm = 6371 # Earth radius in kilometers
rm = rkm * 1000 # Radius in meters
dlat_rad = (loc2[0]-loc1[0]) * rad_per_deg # Delta, converted to rad
dlon_rad = (loc2[1]-loc1[1]) * rad_per_deg
lat1_rad, lon1_rad = loc1.map {|i| i * rad_per_deg }
lat2_rad, lon2_rad = loc2.map {|i| i * rad_per_deg }
a = Math.sin(dlat_rad/2)**2 + Math.cos(lat1_rad) * Math.cos(lat2_rad) * Math.sin(dlon_rad/2)**2
c = 2 * Math::atan2(Math::sqrt(a), Math::sqrt(1-a))
rm * C# Delta in meters
end
puts distance [52.33816422, -106.2828899],[52.33816422, -106.2828634]
# Will return the answer
從這裏:How to calculate the distance between two GPS coordinates without using Google Maps API?
編輯:你的座標更新
嘿,偉大的是,Python代碼? – RobM
哎呦沒關係它的紅寶石:)謝謝 – RobM