1
我想找到距离我的位置4000km的地方的GeoCoordinate,将其命名为newLocation
。将距离转换为WP8中的GeoCoordinate
我需要,为了结果转化为ViewportPoint
这样的:
System.Windows.Point p1 =
mapControl.ConvertGeoCoordinateToViewportPoint(newLocation);
,并假设我的位置被定义为:
System.Windows.Point p2 =
radiusMap.ConvertGeoCoordinateToViewportPoint(myLocation);
那么我可以简单地添加中心的圆我的位置和边界通过newLocation
,我需要计算,如下所示:
double radius = getDistance(p1, p2);
Ellipse circle = new Ellipse();
circle.Width = radius * 2;
circle.Height = radius * 2;
circle.Opacity = 0.4;
circle.Fill = new SolidColorBrush(Colors.Green);
MapOverlay mapOverLay = new MapOverlay();
mapOverLay.PositionOrigin = new System.Windows.Point(0.5, 0.5);
mapOverLay.Content = circle;
mapOverLay.GeoCoordinate = myLocation;
MyLayer.Add(mapOverLay);
radiusMap.Layers.Add(MyLayer);
所以,计算newLocation
是我所需要的。
注:
- 我试图this solution但有一个限制。
我们可以在Visual Studio中的以下内容:
GeoCoordinate location1 = ..., location2 = ...; double distance = location1.GetDistanceTo(location2);
不知逆已经实现。
更新:我发现GetDistanceTo(...)的实施,那就是:
double d = this.Latitude * 0.017453292519943295;
double num3 = this.Longitude * 0.017453292519943295;
double num4 = other.Latitude * 0.017453292519943295;
double num5 = other.Longitude * 0.017453292519943295;
double num6 = num5 - num3;
double num7 = num4 - d;
double num8 = Math.Pow(Math.Sin(num7/2.0), 2.0) + ((Math.Cos(d) * Math.Cos(num4)) * Math.Pow(Math.Sin(num6/2.0), 2.0));
double num9 = 2.0 * Math.Atan2(Math.Sqrt(num8), Math.Sqrt(1.0 - num8));
return (6376500.0 * num9);
我不知道如果让反是可以或不可以。即给予我的地理坐标和离我的距离,以便返回新位置的地理坐标。
感谢您的回答。我会测试这些方程并给你反馈。 – 2013-02-18 14:03:12