1

我需要使用起点、距离和方位角找到终点。以下是每一项的价值:

latitude: 37.624942,
longitude": -7.896333,
azimute: 233.0
distance : 20.0

这是我的功能:

private List<double> findEndPoint(string latitudeStart, string longitudeStart, string azimute,double distancia) 
{
    List<double> endPoint = new List<double>();

    double latitudeStartDouble = Convert.ToDouble(latitudeStart, System.Globalization.CultureInfo.InvariantCulture);
    double longitudeStartDouble = Convert.ToDouble(longitudeStart, System.Globalization.CultureInfo.InvariantCulture);
    double azimuteDouble = Convert.ToDouble(azimute, System.Globalization.CultureInfo.InvariantCulture);
    double azimuteRadians = ConvertToRadians(azimuteDouble);

    
    double R = 6371.0; // Raio da Terra em km

    

    double latitudeEnd = Math.Asin(Math.Sin(latitudeStartDouble) * Math.Cos(distancia / R) +
        Math.Cos(latitudeStartDouble) * Math.Sin(distancia / R) * Math.Cos(azimuteRadians));

    endPoint.Add(latitudeEnd);

    double longitudeEnd = longitudeStartDouble + Math.Atan2(
        Math.Sin(azimuteRadians) * Math.Sin(distancia / R) * Math.Cos(latitudeStartDouble),
        Math.Cos(distancia / R) - Math.Sin(latitudeStartDouble) * Math.Sin(latitudeEnd));

    endPoint.Add(longitudeEnd);

    return endPoint;
}

它返回:

latitude: -0.0760588400705975
longitude:-7.8988473639987093

纬度一定是错误的,但我不知道为什么它给了我那个值。

4

2 回答 2

0

我需要使用弧度,然后将其转换回度数:

private List<double> findEndPoint(string latitudeStart, string longitudeStart, string azimute,double distancia) 
    {
        List<double> endPoint = new List<double>();

        double latitudeStartDouble = Convert.ToDouble(latitudeStart, System.Globalization.CultureInfo.InvariantCulture);
        latitudeStartDouble = ConvertToRadians(latitudeStartDouble);

        double longitudeStartDouble = Convert.ToDouble(longitudeStart, System.Globalization.CultureInfo.InvariantCulture);
        longitudeStartDouble = ConvertToRadians(longitudeStartDouble);

        double azimuteDouble = Convert.ToDouble(azimute, System.Globalization.CultureInfo.InvariantCulture);
        double azimuteRadians = ConvertToRadians(azimuteDouble);


        double R = 6371; // Raio da Terra em km

        

        double latitudeEnd = Math.Asin(Math.Sin(latitudeStartDouble) * Math.Cos(distancia / R) +
            Math.Cos(latitudeStartDouble) * Math.Sin(distancia / R) * Math.Cos(azimuteRadians));

        latitudeEnd = ConvertToDegrees(latitudeEnd);
        endPoint.Add(latitudeEnd);

        double longitudeEnd = longitudeStartDouble + Math.Atan2(Math.Sin(azimuteRadians) * Math.Sin(distancia / R) * Math.Cos(latitudeStartDouble),
            Math.Cos(distancia / R) - Math.Sin(latitudeStartDouble) * Math.Sin(latitudeEnd));

        longitudeEnd = ConvertToDegrees(longitudeEnd);
        endPoint.Add(longitudeEnd);

        return endPoint;
    }
于 2020-08-19T10:18:41.377 回答
0

您忘记添加latitudeStartDouble. 您只需计算增量。所以latitudeEnd = latitudeStartDouble + ...etc...

于 2020-08-18T21:42:40.047 回答