【问题标题】:How can I get a grid reference from my CLLoocation.coordinate如何从我的 CLLocation.coordinate 获取网格参考
【发布时间】:2016-10-18 10:11:42
【问题描述】:

我的应用通过使用下面的代码获取longitudelatitude 将位置坐标发送到服务器。

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
{
    let locationArray = locations as NSArray
    let locationObj = locationArray.lastObject as! CLLocation
    let coord = locationObj.coordinate

    latitudeTxt = String(format: "%.4f", coord.latitude)
    longitudeTxt = String(format: "%.4f",coord.longitude)
}

我现在被要求将值作为网格参考发送,而我发现这样做的唯一方法涉及非常复杂的算法。

有没有更简单的方法可以从我的经度和纬度值中获取网格参考?

【问题讨论】:

    标签: ios swift cllocationmanager cllocation


    【解决方案1】:

    没有原生支持,但我确实在 github 上找到了这个项目:GeodeticUTMConverter。它似乎已经实现了用于将纬度/经度转换为东经和北纬的算法,您可能需要做一些工作才能获得准确的网格参考,但这将是一个很好的起点。

    【讨论】:

    • 谢谢,我已经尝试使用该代码,因为该应用程序无法在 Xcode8 中运行。结果还不是很正确,但它确实给了我一些东西。
    猜你喜欢
    • 2013-06-15
    • 2023-02-07
    • 2022-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-28
    • 2016-10-17
    相关资源
    最近更新 更多