【问题标题】:How to find ArcGIS iOS AGSPoint xy coordinates with latitude and longitude?如何使用经纬度查找 ArcGIS iOS AGSPoint xy 坐标?
【发布时间】:2019-04-11 10:28:53
【问题描述】:

我正在创建一个寻路应用程序,它将根据设备的当前位置和所需目的地显示方向。我正在尝试添加停止点。给定位置的纬度和经度,我如何找到 AGSPoint 的 x 和 y 值?经过一番研究,我找到了以下代码,但编译器告诉我 * 不是前缀一元运算符

     func findAGSPointXY(longitude:Double, latitude:Double) -> (){
    let mercatorX = longitude * 0.017453292519943295 * 6378137.0;
    let a = latitude * 0.017453292519943295;
    let mercatorY = 3189068.5 * log((1.0 + sin(a))/(1.0 - sin(a)));
    AGSPoint *graphicPoint = [AGSPoint pointWithX:mercatorX y:mercatorY spatialReference:[AGSSpatialReference wgs84SpatialReference]];
}

【问题讨论】:

    标签: ios arcgis


    【解决方案1】:

    看起来你正在混合objective-c和swift,在同一个sn-p中有objc指针(*),objc方法调用([])和swift const(let)。我假设你正在使用 swift。

    ArcGIS SDK 可以重新投影几何,您不必手动计算这些值。

    //Create an AGSPoint from your parameters, specifying them as WGS 84.
    let wgsPoint = AGSPoint(x: longitude, y: latitude, spatialReference:  AGSSpatialReference.wgs84())
    
    //Preparing a Geometry Engine
    let geometryEngine = AGSGeometryEngine.defaultGeometryEngine()
    
    //Get a projected (in web mercator) geometry (points, lines, polygons and whatever inherit AGSGeometry).
    let projGeometry = geometryEngine.projectGeometry(wgsPoint, toSpatialReference: AGSSpatialReference.webMercatorSpatialReference())
    //Cast it back to AGSPoint, might have some optional to manage
    let projPoint = projGeometry as AGSPoint // Might be some optional to manage there
    
    //Here you can use projPoint.x and projPoint.y
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-28
      • 1970-01-01
      • 2013-01-09
      • 2017-01-18
      相关资源
      最近更新 更多