如何找到具有经度和纬度的ArcGIS iOS AGSPoint xy坐标?

时间:2018-11-07 22:28:47

标签: ios arcgis

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

from decimal import Decimal

def pay_with_coins( amount ):
    amount = Decimal(amount)
    coins_list = [0, 0, 0, 0, 0, 0, 0, 0]

    if amount == 0:
        return(coins_list)
    else:
        while amount > Decimal("2.00"):
            coins_list[0] = (coins_list[0] + 1)
            amount = amount - Decimal("2.00")
        while amount >= Decimal("1.00") and amount < Decimal("2.00"):
            coins_list[1] = (coins_list[1] + 1)
            amount = amount - Decimal("1.00")
        while amount >= Decimal("0.50") and amount < Decimal("1.00"):
            coins_list[2] = (coins_list[2] + 1)
            amount = amount - Decimal("0.50")
        while amount >= Decimal("0.20") and amount < Decimal("0.50"):
            coins_list[3] = (coins_list[3] + 1)
            amount = amount - Decimal("0.20")
        while amount >= Decimal("0.10") and amount < Decimal("0.20"):
            coins_list[4] = (coins_list[4] + 1)
            amount = amount - Decimal("0.10")
        while amount >= Decimal("0.05") and amount < Decimal("0.10"):
            coins_list[5] = (coins_list[5] + 1)
            amount = amount - Decimal("0.05")
        while amount >= Decimal("0.02") and amount < Decimal("0.05"):
            coins_list[6] = (coins_list[6] + 1)
            amount = amount - Decimal("0.02")
        while amount >= Decimal("0.01") and amount < Decimal("0.05"):
            coins_list[7] = (coins_list[7] + 1)
            amount = amount - Decimal("0.01")
        return(coins_list)
print(pay_with_coins("1.74"))

1 个答案:

答案 0 :(得分:0)

似乎您要混合使用Objective-C和Swift,在同一代码段中有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
相关问题