我需要使用现有的纬度/经度、距离和方向来计算纬度/经度



在Java中集成google API时,我需要使用现有的纬度/经度、距离和方向来计算另一个地方的纬度/长度。如何计算该点?

以下PHP代码提供了从$lat1,$lng1到轴承$brng距离$dist(kms)的点。

function destination($lat1,$lng1,$dist,$brng){
$alpha = $dist/6371; // km
$lat2 = asin((sin($lat1)*cos($alpha)) +(cos($lat1)*sin($alpha)*cos($brng)) );
$lng2 = $lng1 + atan2(sin($brng)*sin($alpha)*cos($lat1),cos($alpha)-sin($lat1)*sin($lat2));
return array(toDeg($lat2),toDeg($lng2));
}

弧度中的$lat1,$lng1 & $brng

function toRad($deg) {
// Converts numeric degrees to radians 
    return $deg * pi() / 180;
}
function toDeg($rad){
   return $rad * 180 / pi();
}

最新更新