iOS:如何将 MKMapPoint 或 CLLocationCooperative2D 转换为 UTM?
根据我的阅读,这需要一些我不擅长的复杂数学。所以,我在这里问。
有人有将 MKMapPoint 或 CLLocationCooperative2D 转换为 UTM 值的经验吗?我找到了这个资源(http://www.uwgb.edu/dutchs/usefuldata/UTMFormulas。 HTM),但是数学是压倒性的。
From what I have read this takes some complicated Math that I am not good at. So, I am asking here.
Does anyone have experience converting a MKMapPoint or CLLocationCoordinate2D to a UTM value? I found this resource (http://www.uwgb.edu/dutchs/usefuldata/UTMFormulas.HTM) but the math is overwhelming.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我最近为此编写了一个类,并在 GitHub 上发布了一个示例项目
iOS 的 UTMConverter 示例
您想要的部分是一个名为 UTMConverter 的文件。米。它具有从纬度/经度转换为 UTM 的方法,反之亦然。
I recently wrote a class for this and posted a sample project on GitHub
UTMConverter example for iOS
The part you want is a file called UTMConverter.m. It has methods for converting from lat/long to UTM and vice-versa.
您可以使用一个库来做到这一点,或者分析一个库的代码以了解算法并自己完成。
这是一个完成这项工作的 C++ lib: http://geographiclib.sourceforge.net/html/
网站
我找到了这个 (http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html)。如果你看一下源代码,整个转换是使用JavaScript完成的,你可以看一下并尝试转换为Obj-c。
You could use one lib to do that, or analyze the code of one lib to understand the algorithm and do it yourself.
This is a c++ lib that does the job: http://geographiclib.sourceforge.net/html/
http://geographiclib.sourceforge.net/html/classGeographicLib_1_1UTMUPS.html
I found this website (http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html). If you look at the source code, the whole conversion is done using JavaScript, you can have a look at it and try to convert to Obj-c.
MKMapViewZoom
似乎有一些类方法可以在平面地图(几何)和地图之间进行转换。弯曲地图(地理)坐标,尽管我还没有测试过它们。 有人给我竖起大拇指如果这确实有效,
更新:
这令人抓狂,但为了获得为了使此类的源代码准确工作,我基本上必须将方法提取到我自己的域中,然后删除引用 MERCATOR_OFFSET 的代码部分将
MERCATOR_RADIUS
更改为地球半径的米值。当我发现这确实有效时,我感到非常惊讶。MKMapViewZoom
appears to have some class methods which can convert between flat-map (geometric) & curved-map (geographic) coordinates, though I haven't tested them out. Somebody give me a thumbs up if this actually workssome documentation here
UPDATE:
This is maddening, but in order to get this class's source code to work accurately I basically had to extract the methods into my own domain essentially, then remove the parts of the code referencing
MERCATOR_OFFSET
& changeMERCATOR_RADIUS
to the meters value of the Earth's radius. I was kind of, ok, very surprised when I discovered this actually worked.