在Mercator地图上绘制FlighRoute如何用给定的经度计算多线线点



我想在两个城市之间的mercator映射上绘制一条多线。例如起点:

 Location berlin = new Location(52.517, 13.40);
 Location tokio = new Location(35.70,139.767);

它看起来应该像一条飞行路线。

所以我的计划是在两个城市之间经过所有经度值,并计算相应的纬度值:

LocationCollection locationCollection = new LocationCollection();
Location next = new Location(berlin.Latitude,berlin.Longitude); //startpunkt
for (double x = berlin.Longitude+1; x < tokio.Longitude; x++) {
  locationCollection.Add(next);
  next = new Location(???, x);
}

问题是如何计算多线线的每个经度值的纬度?谢谢!

来自此链接:

这是c。

中的实现
#define PI 3.14159265358979323846
double degrees_radians(double d) { return d * PI / 180.0; }
double radians_degrees(double r) { return r * 180.0 / PI; }
double latitude(double lat1, double lon1, double lat2, double lon2, double lon)
{
    return atan((sin(lat1)*cos(lat2)*sin(lon-lon2)-sin(lat2)*cos(lat1)*sin(lon-lon1))/(cos(lat1)*cos(lat2)*sin(lon1-lon2)));
}
int main()
{
    // start and end in degrees
    double lat1_d = 52.517;
    double lon1_d = 13.40;
    double lat2_d = 35.70;
    double lon2_d = 139.767;
    // start and end in radians
    double lat1_r = degrees_radians(lat1_d);
    double lon1_r = degrees_radians(lon1_d);
    double lat2_r = degrees_radians(lat2_d);
    double lon2_r = degrees_radians(lon2_d);
    // interpolate latitide at every degree of longitude between 1 and 2
    for (double lon = ceil(lon1_d); lon < lon2_d; lon += 1.0)
    {
        double lat_r = latitude(lat1_r, lon1_r, lat2_r, lon2_r, degrees_radians(lon));
        double lat_d = radians_degrees(lat_r);
        printf("%.3f , %.3fn", lat_d, lon);
    }
    return 0;
}

然后,柏林和东京之间的大圆圈达到的最大纬度在68°时显示为66.183°。

相关内容

  • 没有找到相关文章

最新更新