我在一个 C# 项目上工作,我有一个给定纬度和经度的点。
我需要找到与给定点成 x 度角和 y 米的第二个点的纬度和经度。
谢谢你,
阿吉西劳斯
我在一个 C# 项目上工作,我有一个给定纬度和经度的点。
我需要找到与给定点成 x 度角和 y 米的第二个点的纬度和经度。
谢谢你,
阿吉西劳斯
请参阅此页面以获取从起点给定距离和方位的目的地点
这是改编自http://www.movable-type.co.uk/scripts/latlong-vincenty-direct.html的WGS-84(非球形地球)版本:
private const double wgs84_major = 6378.137;
private const double wgs84_minor = 6356.7523142;
private const double wgs84_flattening = 1D / 298.257223563;
public static bool PointFromDistance(double latitude, double longitude, double angleRadians, double distanceMetres, out double newLatitude, out double newLongitude)
{
double a = wgs84_major * 1000;
double b = wgs84_minor * 1000;
double f = wgs84_flattening;
double s = distanceMetres;
double sinAlpha1 = Math.Sin(angleRadians), cosAlpha1 = Math.Cos(angleRadians);
double tanU1 = (1 - f) * Math.Tan(latitude * Math.PI / 180D);
double cosU1 = 1 / Math.Sqrt((1 + tanU1 * tanU1)), sinU1 = tanU1 * cosU1;
double sigma1 = Math.Atan2(tanU1, cosAlpha1);
double sinAlpha = cosU1 * sinAlpha1;
double cosSqAlpha = 1 - sinAlpha * sinAlpha;
double uSq = cosSqAlpha * (a * a - b * b) / (b * b);
double A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
double B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
double sigma = s / (b * A), sigmaP = 2 * Math.PI;
double cos2SigmaM = 0;
double sinSigma = 0;
double cosSigma = 0;
double deltaSigma = 0;
while (Math.Abs(sigma - sigmaP) > 1e-12)
{
cos2SigmaM = Math.Cos(2 * sigma1 + sigma);
sinSigma = Math.Sin(sigma);
cosSigma = Math.Cos(sigma);
deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) -
B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
sigmaP = sigma;
sigma = s / (b * A) + deltaSigma;
}
double tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1;
double lat2 = Math.Atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1,
(1 - f) * Math.Sqrt(sinAlpha * sinAlpha + tmp * tmp));
double lambda = Math.Atan2(sinSigma * sinAlpha1, cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1);
double C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
double L = lambda - (1 - C) * f * sinAlpha *
(sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
double revAz = Math.Atan2(sinAlpha, -tmp); // final bearing
newLatitude = lat2 * 180D / Math.PI;
newLongitude = longitude + L * 180D / Math.PI;
return true;
}