0
我正在使用以下功能。長距離獲取不正確的緯度和經度
private static Location CoordinateAtADistance(double latOrigin, double lonOrigin, double radius, double angle)
{
double lonDestination;
double R = 6371.0;
double d = radius/R; // d = angular distance covered on earth's surface
double lat1 = ToRadian(latOrigin);
double lon1 = ToRadian(lonOrigin);
double brng = ToRadian(angle);
double latDestination = lat1 + d * Math.Cos(brng);
double dLat = d * Math.Cos(brng);
double dPhi = Math.Log(Math.Tan(latDestination/2 + Math.PI/4)/Math.Tan(lat1/2 + Math.PI/4));
double q = (double.IsNaN(dLat/dPhi)) ? dLat/dPhi : Math.Cos(lat1); // E-W line gives dPhi=0
double dLon = d * Math.Sin(brng)/q;
// check for some daft bugger going past the pole
if (Math.Abs(latDestination) > Math.PI/2)
latDestination = latDestination > 0 ? Math.PI - latDestination : -(Math.PI - latDestination);
lonDestination = (lon1 + dLon +3* Math.PI) % (2 * Math.PI) - Math.PI;
Location nextPoint = new Location();
if (angle == 0)
{
nextPoint.Latitude = ToDegree(latDestination);
nextPoint.Longitude = lonOrigin;
}
if (angle == 90)
{
nextPoint.Latitude = latOrigin;
nextPoint.Longitude = ToDegree(lonDestination);
}
return nextPoint;
}
這裏的半徑是距離。
現在的問題是當我計算短距離例如幾百公里,它完美的作品。但是,如果路程長達11,000公里,它的經度是正確的。 請不要只沿緯度或經度移動,因此其中一個在任何情況下都不會改變。在移動緯度的時候,我得到了正確的答案,但經度值並沒有更接近。 如果有不明之處,請發表評論。