将屏幕转换为SP 4326
问题描述:
我正在使用Esri for .NET。我使用ScreenToLocation函数通过鼠标单击来捕获屏幕坐标。我如何将这个映射转换为4326的SP?将屏幕转换为SP 4326
MapPoint mapPoint = Mapview.ScreenToLocation(screenPoint);
我的地图不是我点击地图的地方。我得到的坐标为5423799.44921864,-267641.097678069
答
您是使用ArcGIS Runtime for windows store还是wpf的运行时?
无论如何,你正在获得一个WebMercator点。为了空间参考之间进行转换需要使用上wpf在winstore
的GeometryService的工程方法或GeometryEngine或者,如果你喜欢做转换WebMercator(三千八百五十七分之一十万二千百)到WGS84 (4326)同步的代码,你可以做:
private const double R_MAJOR = 6378137.0;
private const double R_MINOR = 6356752.3142;
public MapPoint PointToWGS84(double x, double y)
{
double originShift = 2 * Math.PI * R_MAJOR/2.0;
double mx = (x/originShift) * 180.0;
double my = (y/originShift) * 180.0;
my = (180/Math.PI) * (2 * Math.Atan(Math.Exp(my * Math.PI/180.0)) - Math.PI/2.0);
return new MapPoint(mx, my, new SpatialReference(WGS84));
}
从WGS84到WM
public MapPoint PointToWM(double x, double y)
{
double originShift = 2 * Math.PI * R_MAJOR/2.0;
double mx = x * originShift/180.0;
double my = Math.Log(Math.Tan((90.0 + y) * Math.PI/360.0))/(Math.PI/180.0);
my = my * originShift/180.0;
return new MapPoint(mx, my, new SpatialReference(102100));
}
请注意,此代码仅适用于WM来往/来自WGS。对于其他转换,您必须始终使用GeometryService
如果您想了解更多信息:http://wiki.openstreetmap.org/wiki/Mercator – Ivan