【问题标题】:Attempting to calculate lat and long given distance and bearing from start point尝试从起点计算经纬度给定距离和方位
【发布时间】:2019-03-09 16:36:40
【问题描述】:

使用this 网站我正在尝试从初始纬度和经度以及C# 中的距离和方位计算经度和经度,但我无法让它正常工作。无论方位和距离如何,输出似乎总是或多或少地垂直于起点与赤道保持一致。我已经按照网站所说的做了,但没有成功。

这是我到目前为止所做的:

    public static double[] LocWithBearingAndDistance(double lat, double lon, double bearing, double distanceM)
    {
        double angdistance = distanceM / 6371000.0;
        double lat2 = Math.Asin(Math.Sin(lat) * Math.Cos(angdistance) + Math.Cos(lat) * Math.Sin(angdistance) * Math.Cos(bearing));
        double lon2 = lon + Math.Atan2(Math.Cos(angdistance) - Math.Sin(lat) * Math.Sin(lat2), Math.Sin(bearing) * Math.Sin(angdistance) * Math.Cos(lat));
        return new double[2] {lat2, (lon2 + 540) % 360 - 180};
    }

感谢您的帮助。

【问题讨论】:

    标签: c# .net gis geospatial latitude-longitude


    【解决方案1】:

    这是我解决问题的代码:

    public static (double Lat, double Lon) Destination((double Lat, double Lon) startPoint, double distance, double bearing)
        {
            double φ1 = startPoint.Lat * (Math.PI / 180);
            double λ1 = startPoint.Lon * (Math.PI / 180);
            double brng = bearing * (Math.PI / 180);
            double φ2 = Math.Asin(Math.Sin(φ1) * Math.Cos(distance / radius) + Math.Cos(φ1) * Math.Sin(distance / radius) * Math.Cos(brng));
            double λ2 = λ1 + Math.Atan2(Math.Sin(brng) * Math.Sin(distance / radius) * Math.Cos(φ1), Math.Cos(distance / radius) - Math.Sin(φ1) * Math.Sin(φ2));
            return (φ2 * (180 / Math.PI), λ2 * (180 / Math.PI));
        }
    

    radius 是地球的半径,以米为单位。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-03
      • 1970-01-01
      • 2015-07-12
      • 2011-11-05
      • 1970-01-01
      • 2021-05-10
      相关资源
      最近更新 更多