如何使用长/纬度坐标在地图上旋转多边形?

Mat*_*Mis 2 c# rotatetransform rotation uwp uwp-maps

我想通过用一个函数替换硬编码的偏移值来旋转多边形(例如这个箭头),该函数可以传入北向偏移和我希望箭头旋转的度数。

我尝试使用旋转矩阵,但效果不佳。
可能是因为 1 Lat 的距离。!= 1 长。

我想用这个做什么:
箭头必须代表车辆并在车辆前进的方向上旋转。

double centerLatitude = pos.Coordinate.Point.Position.Latitude;
double centerLongitude = pos.Coordinate.Point.Position.Longitude;

MapPolygon mapPolygon = new MapPolygon();
mapPolygon.Path = new Geopath(new List<BasicGeoposition>() {
    new BasicGeoposition() {Longitude=centerLongitude, Latitude=centerLatitude},//top of the arrow
    new BasicGeoposition() {Longitude=centerLongitude-0.001, Latitude=centerLatitude-0.0010},
    new BasicGeoposition() {Longitude=centerLongitude-0.001, Latitude=centerLatitude-0.0030},
    new BasicGeoposition() {Longitude=centerLongitude+0.001, Latitude=centerLatitude-0.0030},
    new BasicGeoposition() {Longitude=centerLongitude+0.001, Latitude=centerLatitude-0.0010},              
});
mapPolygon.ZIndex = 1;
mapPolygon.FillColor = Colors.Orange;
mapPolygon.StrokeColor = Colors.Blue;
mapPolygon.StrokeThickness = 2;
mapPolygon.StrokeDashed = false;
MainMap.MapElements.Add(mapPolygon);
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

rbr*_*itt 6

MapPolygons 绑定到地图上的坐标。UWP 中的旋转变换不适用于 MapPolygons。如果要旋转 MapPolygon,则必须计算旋转后的坐标。Bing Maps V8 地图控件 (web) 提供了执行此操作的功能。这是它执行此操作的两种不同方式:

空间准确(由于地图投影可能看起来不一样)

像素准确(在旋转时看起来相同,但在空间上不准确)

  • 计算多边形的中心并将其用作旋转多边形的锚点。如果您愿意,您可以使用多边形的任何其他部分。将其转换为缩放级别 19 的全局像素坐标:https ://msdn.microsoft.com/en-us/library/bb259689.aspx (LatLongToPixelXY)
  • 循环遍历 MapPolygon 中的每个位置,并在缩放级别 19 处计算其全局像素坐标。
  • 计算旋转后的像素坐标:http : //homepages.inf.ed.ac.uk/rbf/HIPR2/rotate.htm
  • 将像素坐标转换回缩放级别 19 (PixelXyToLatLong) 的空间位置
  • 将新计算的位置传递到 MapPolygon。