2点間の経緯度の距離を求める
前回、ある経緯度からXKm地点の経緯度を求めるものをコーディングしましたが、次は経緯度がわかっている2点の距離を求める式です。
こちらを参考にしました。
ヒュベニの距離計算式というものがあるそうです。
double dp = Math.abs(lat1 - lat2); //2点間の緯度差
double dr = Math.abs(lon1 - lon2); //2点間の経度差
double p = lat1 + ((lat2 - lat1) / 2); //2点の平均緯度
double sp = Math.sin(p);
double cp = Math.cos(p);
double m = 6335439 / Math.sqrt(Math.pow(1 - 0.006694 * Math.pow(sp,2),3));
double n = 6378137 / Math.sqrt(1 - 0.006694 * Math.pow(sp,2));
double dis = Math.sqrt(Math.pow(m * dp,2) + Math.pow(n * cp * dr,2));
こんな感じです。
また、こちらを見るとBessel、GRS 80、WGS 84と計測方法の違いにより、長短の半径が変わるようです。
ひとまず新しいほうのパラメータで計算しました。
Posted in Java |
