iOS:如何将 MKMapPoint 或 CLLocationCooperative2D 转换为 UTM?

发布于 2024-10-03 14:46:36 字数 261 浏览 0 评论 0原文

根据我的阅读,这需要一些我不擅长的复杂数学。所以,我在这里问。

有人有将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风柔一江水 2024-10-10 14:46:36

我最近为此编写了一个类,并在 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.

烟若柳尘 2024-10-10 14:46:36

您可以使用一个库来做到这一点,或者分析一个库的代码以了解算法并自己完成。

这是一个完成这项工作的 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.

迷乱花海 2024-10-10 14:46:36

MKMapViewZoom 似乎有一些类方法可以在平面地图(几何)和地图之间进行转换。弯曲地图(地理)坐标,尽管我还没有测试过它们。 有人给我竖起大拇指

//convert from WGS84 (geographic coordinates) to UTM (geometric coordinates)
+ (double)longitudeToPixelSpaceX(double)pixelX
+ (double)latitudeToPixelSpaceY(double)pixelY

//convert from UTM to WGS84
+ (double)pixelSpaceXToLongitude(double)longitude
+ (double)pixelSpaceYToLatitude(double)latitude

如果这确实有效,

更新:

这令人抓狂,但为了获得为了使此类的源代码准确工作,我基本上必须将方法提取到我自己的域中,然后删除引用 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 works

//convert from WGS84 (geographic coordinates) to UTM (geometric coordinates)
+ (double)longitudeToPixelSpaceX(double)pixelX
+ (double)latitudeToPixelSpaceY(double)pixelY

//convert from UTM to WGS84
+ (double)pixelSpaceXToLongitude(double)longitude
+ (double)pixelSpaceYToLatitude(double)latitude

some 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 & change MERCATOR_RADIUS to the meters value of the Earth's radius. I was kind of, ok, very surprised when I discovered this actually worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文