4

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

有没有人有将 MKMapPoint 或 CLLocationCoordinate2D 转换为 UTM 值的经验?我找到了这个资源(http://www.uwgb.edu/dutchs/usefuldata/UTMFormulas.HTM),但数学是压倒性的。

4

3 回答 3

6

我最近为此写了一个类,并在 GitHub 上发布了一个示例项目

iOS 的 UTMConverter 示例

您想要的部分是一个名为 UTMConverter.m 的文件。它具有从纬度/经度转换为 UTM 的方法,反之亦然。

于 2012-07-09T15:07:40.520 回答
2

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

这是一个可以完成这项工作的 c++ 库:http: //geographiclib.sourceforge.net/html/

http://geographiclib.sourceforge.net/html/classGeographicLib_1_1UTMUPS.html

我找到了这个网站(http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html)。如果你看源代码,整个转换是使用 JavaScript 完成的,你可以看看它并尝试转换为 Obj-c。

于 2010-11-18T23:15:22.813 回答
1

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.

于 2014-02-23T19:43:24.247 回答