http://www.movable-type.co.uk/scripts/latlong.htmlのアルゴリズムを使用して、2 点間の距離を見つけました。
私の2つのポイントは
long1 = 51.507467;
lat1 = -0.08776;
long2 = 51.508736;
lat2 = -0.08612;
Movable Type Scriptによると、答えは 0.1812km です。
私のアプリケーションは結果 ( d
) を 0.230km として返します
Haversine 式を確認してください: http://www.movable-type.co.uk/scripts/latlong.html
double R = 6371; // earth’s radius (mean radius = 6,371km)
double dLat = Math.toRadians(lat2-lat1);
double dLon = Math.toRadians(long2-long1);
a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
double d = R * c;