【问题标题】:Geoalgorithm for finding coordinates of point from a known location by distance and bearing通过距离和方位从已知位置查找点坐标的地理算法
【发布时间】:2010-10-16 06:07:19
【问题描述】:

我想使用 Google 地图静态 API 来显示带有指示边界的路径叠加层的地图。

AFAICT 静态 API 不支持多边形,所以我打算通过使用路径绘制边界来规避这个问题。

为此,我需要确定在它们之间绘制直线(路径)的点;所以我想要一种算法,它可以返回给定方位角和距已知点的距离的地理位置(即 WGS84 坐标)。

谁能给我指出这样的算法。最好用 C#,但其他语言也可以?

【问题讨论】:

  • 它将是弧度。任何使用 pi 的角度都是弧度。

标签: coordinates distance bearing


【解决方案1】:

我在 C# 中实现并测试了它,使用度数作为输入/输出而不是弧度:

    static readonly double FullCircleDegrees = 360d;
    static readonly double HalfCircleDegrees = FullCircleDegrees / 2d;
    static readonly double DegreesToRadians = Math.PI / HalfCircleDegrees;
    static readonly double RadiansToDegrees = 1 / DegreesToRadians;

    public LatLng GetPointGivenRadialAndDistance(LatLng center, double radius, double azimuth)
    {
        var lat1 = center.Lat * DegreesToRadians;
        var lng1 = center.Lng * DegreesToRadians;
        var lat = Math.Asin( (Math.Sin(lat1) * Math.Cos(radius)) + Math.Cos(lat1) * Math.Sin(radius) * Math.Cos(azimuth * DegreesToRadians));
        var lng = 0d;
        if (Math.Cos(lat) == 0)
        {
            lng = lng1;
        }
        else
        {
            lng = ((lng1 + Math.PI - Math.Asin(Math.Sin(azimuth * DegreesToRadians) * Math.Sin(radius) / Math.Cos(lat1))) % (2 * Math.PI)) - Math.PI;
        }
        return new LatLng(lat * RadiansToDegrees, lng * RadiansToDegrees);
    }

【讨论】:

  • 与大圆距离相比,它的准确率高达 80%
【解决方案2】:

您可以在 KML 文件上绘制多边形,然后在 Google 地图上显示 KML。

Here's KML on Google maps(来自 Google KML 示例)检查内容中的 “Google Campus - Polygons” 部分。

【讨论】:

  • 我在 KML 方面的经验非常有限,但是这适用于静态地图吗?
  • 您可以将KML文件作为静态地图的参数传递。
【解决方案3】:

在(我认为)我知道的每一种语言中,弧度。请注意,我认为您的示例代码为您提供了基于球体的坐标,而不是 WGS84。这里是Java code for converting between co-ordinate systems。

【讨论】:

    【解决方案4】:

    看看Gavaghan Geodesy C# 库,它应该是你要找的。而且是免费的。

    【讨论】:

      【解决方案5】:

      找到这个(这里:http://williams.best.vwh.net/avform.htm#LL):

      点 {lat,lon} 在 tc 径向上距离点 1 的距离为 d,如果:

      lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc))
      IF (cos(lat)=0)
          lon=lon1      // endpoint a pole
      ELSE
          lon=mod(lon1-asin(sin(tc)*sin(d)/cos(lat))+pi,2*pi)-pi
      ENDIF
      

      径向是弧度还是度数?

      编辑:

      弧度 = 度 * PI / 180

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-04-29
        • 1970-01-01
        • 2010-10-27
        • 1970-01-01
        • 2013-09-28
        • 2012-09-21
        • 1970-01-01
        • 2011-02-18
        相关资源
        最近更新 更多