我有一个服务返回arcgis json格式,我想将这个几何点转换为经度和纬度ios 例如:
"geometryType": "esriGeometryPoint",
"geometry": {
"x": 445340.99496,
"y": 2423705.6300004,
"spatialReference": {
"wkid": 32637,
"latestWkid": 32637
}
}
我转换点
AGSGraphic *testGraphic = [[AGSGraphic alloc] initWithJSON:jsonData] ;
我如何从AGSGraphic经度和纬度获得
答案 0 :(得分:2)
这解决了问题,只需发送xPoint和yPoint,它将返回包含lng和latit的CLLocation对象
-(CLLocation *) convertToLongAndLat:(double) xPoint andYPoint :(double) yPoint {
double originShift = 2 * M_PI * 6378137 / 2.0;
double lon = (xPoint / originShift) * 180.0;
double lat = (yPoint / originShift) * 180.0;
lat = 180 / M_PI * (2 * atan( exp( lat * M_PI / 180.0)) - M_PI / 2.0);
return [[CLLocation alloc] initWithLatitude:lat longitude:lon];
}
答案 1 :(得分:1)
我认为您希望根据需要更改空间参考。
前:
//AA : Get the clicked point
let gpsPoint = clickedMapPoint
let engine = AGSGeometryEngine.defaultGeometryEngine()
//AA : Change the spatial ref to get real lon and lat
let mapPoint = engine.projectGeometry(gpsPoint, toSpatialReference: AGSSpatialReference.wgs84SpatialReference()) as! AGSPoint