假设我有lat1 = 21.154533& long1 = 79.045760 精度为x米,另一个lat2 = 21.153184& long2 = 79.045882。所以可以 我找到了与lat1和amp;相关的最近位置(lat,long)。 long1借助lat2& long2方向?
答案 0 :(得分:0)
最后,我找到了自己问题的答案。
- 使用Lat1,Long1&计算轴承/角度。 Lat2,Long2
function bearing($lat1, $long1, $lat2, $long2){
$bearingradians = atan2(asin($long1-$long2)*cos($lat2),
cos($lat1)*sin($lat2) - sin($lat1)*cos($lat2)*cos($long1-$long2));
$bearingdegrees = abs(rad2deg($bearingradians));
return $bearingdegrees;
}
- 计算Lat1,Long1和&之间的距离。 LAT2,Long2
function distance($lat1, $lon1, $lat2, $lon2) {
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$distanceMeters = $dist * 60 * 1000;
return $distanceMeters;
}
- 然后在Lat1,Long2附近生成新的Lat Long。
$earthRadius = 6371000;
$lat1 = deg2rad(21.156845);
$lon1 = deg2rad(79.053331);
$lat2 = deg2rad(21.156805);
$lon2 = deg2rad(79.057634);
//$bearing = $this->bearing($lat1,$lon1,$lat2,$lon2); //you can get value from above function
//$distance = $this->distance($lat1,$lon1,$lat2,$lon2);//you can get value from above function
$bearing = deg2rad(90);
$distance =100;
$Newlat = asin(sin($lat1) * cos($distance / $earthRadius) + cos($lat1) * sin($distance / $earthRadius) * cos($bearing));
$Newlon = $lon1 + atan2(sin($bearing) * sin($distance / $earthRadius) * cos($lat1), cos($distance / $earthRadius) - sin($lat1) * sin($Newlat));
echo 'distance: ' .$distance;
echo 'bearing: ' .$bearing;
echo 'LAT: ' . rad2deg($Newlat);
echo 'LNG: ' . rad2deg($Newlon);
结论是我们得到不正确的lat2,long2值。但我们可以 精确计算lat,长度接近lat1和lat2,其精确角度。我们在整合信标技术时发现了这一挑战。