2016-10-18 31 views
0

获取网格参考我的应用通过使用下面的代码获取longitudelatitude将位置坐标发送到服务器。我如何从我的CLLoocation.coordinate

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) 
} 

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

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

回答

0

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

+0

谢谢,我试过使用代码,因为应用程序不会在Xcode8中运行。结果还不完全正确,但它确实给了我一些继续。 – user616076