在地图上显示圆圈会显示拉长的椭圆形

Showing circle on the map displays elongated ellipse instead

我需要在地图上围绕一个点显示一个圆圈。我正在使用 windows 应用程序和 GMap.NET 控件。我得到的不是圆圈,而是这个:

这是我用来获取多边形点的sql:

declare @lat float = 43.722385, @lng float = -79.415241, @radius int = 100;
DECLARE @g geography;
SET @g = geography::STGeomFromText('POINT(' + Str(@lat, 10, 7) + ' ' + Str(@lng, 10, 7) + ')', 4326);
SELECT @g.STBuffer(@radius).STAsText() as circle, @g.STBuffer(@radius)

我似乎得到了正确的结果:

但是当显示在地图上时,我得到了一个椭圆,正如您在第一张图片上看到的那样。

这是多边形边界的示例,如果我只是找到所有纬度和经度的 max/min 值并将它们显示在 bing 地图中作为完整性检查并确认这不仅仅是一个 GMap.NET 问题:

这是我使用多边形创建圆的代码:

 List<PointLatLng> points = new List<PointLatLng>();
 string[] ps = radCirclePoints.Split(',');
 foreach (string p in ps) {
     string[] coords = p.Trim().Split(' ');
     points.Add(new PointLatLng(double.Parse(coords[0]), double.Parse(coords[1])));
 }

 GMapPolygon polygon = new GMapPolygon(points, "circ");
 polygon.Fill = new SolidBrush(Color.FromArgb(50, Color.Red));
 polygon.Stroke = new Pen(Color.Red, 1);
 markersOverlay.Polygons.Add(polygon);

这是怎么回事?使用 STBuffer 是找到多边形边界以显示圆的一种优雅方式,但它在某处失败了。有什么想法吗?

当您创建 STGeomFromText 时,您将纬度和经度颠倒了。更改此顺序后,您还必须调整从缓冲区输出中解析它们的顺序。通过让它们反转,点被缓冲,就好像它是 at/below 南极,这就是椭圆的原因。

DECLARE @g geography;
SET @g = geography::STPointFromText('POINT(' + Str(@lng, 10, 7) + ' ' + Str(@lat, 10, 7) + ')', 4326);

SELECT @g.STBuffer(@radius).STAsText() as circle, @g.STAsText() AS point, @g.STBuffer(@radius)

然后在 c#

List<PointLatLng> points = new List<PointLatLng>();
 string[] ps = radCirclePoints.Split(',');
 foreach (string p in ps) {
     string[] coords = p.Trim().Split(' ');
     points.Add(new PointLatLng(double.Parse(coords[1]), double.Parse(coords[0])));
 }