在Java中集成google API时,我需要使用现有的经纬度、距离和方向来计算另一个地方的经纬度。如何计算这一点?
发布于 2015-02-23 18:04:43
以下PHP代码提供了沿方位角距离( $lat1,$lng1 $dist $brng,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();
}https://stackoverflow.com/questions/28667429
复制相似问题