如何从我的 CLLoocation.coordinate 中获取网格参考
How can I get a grid reference from my CLLoocation.coordinate
我的应用通过使用以下代码获取 longitude
和 latitude
将位置坐标发送到服务器。
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)
}
我现在被要求将值作为网格参考发送,我发现这样做的唯一方法涉及非常复杂的算法。
有没有更简单的方法从我的经度和纬度值获取网格参考?
没有本机支持,但我确实在 github 上找到了这个项目:GeodeticUTMConverter。它似乎已经实现了用于将 lat/long 转换为东距和北距的算法,您可能需要做一些工作才能获得准确的网格参考,但这将是一个很好的起点。
我的应用通过使用以下代码获取 longitude
和 latitude
将位置坐标发送到服务器。
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)
}
我现在被要求将值作为网格参考发送,我发现这样做的唯一方法涉及非常复杂的算法。
有没有更简单的方法从我的经度和纬度值获取网格参考?
没有本机支持,但我确实在 github 上找到了这个项目:GeodeticUTMConverter。它似乎已经实现了用于将 lat/long 转换为东距和北距的算法,您可能需要做一些工作才能获得准确的网格参考,但这将是一个很好的起点。