简体   繁体   English

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

[英]iOS: How to convert MKMapPoint or CLLocationCoordinate2D to UTM?

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? 有没有人有将MKMapPoint或CLLocationCoordinate2D转换为UTM值的经验? I found this resource ( http://www.uwgb.edu/dutchs/usefuldata/UTMFormulas.HTM ) but the math is overwhelming. 我找到了这个资源( http://www.uwgb.edu/dutchs/usefuldata/UTMFormulas.HTM ),但数学是压倒性的。

I recently wrote a class for this and posted a sample project on GitHub 我最近为此编写了一个类,并在GitHub上发布了一个示例项目

UTMConverter example for iOS 适用于iOS的UTMConverter示例

The part you want is a file called UTMConverter.m. 你想要的部分是一个名为UTMConverter.m的文件。 It has methods for converting from lat/long to UTM and vice-versa. 它有从lat / long转换为UTM的方法,反之亦然。

You could use one lib to do that, or analyze the code of one lib to understand the algorithm and do it yourself. 您可以使用一个lib来执行此操作,或者分析一个lib的代码以了解算法并自行完成。

This is a c++ lib that does the job: http://geographiclib.sourceforge.net/html/ 这是一个完成这项工作的c ++ lib: http//geographiclib.sourceforge.net/html/

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

I found this website (http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.html). 我找到了这个网站(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. 如果您查看源代码,整个转换是使用JavaScript完成的,您可以查看它并尝试转换为Obj-c。

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. MKMapViewZoom似乎有一些类方法可以在平面地图(几何)和曲线图(地理)坐标之间进行转换,但我还没有测试过它们。 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. 这是发疯,但为了得到这个类的源代码,以准确地工作,我基本上不得不方法提取到自己的域名本质上,然后删除代码的部分引用MERCATOR_OFFSET &转换MERCATOR_RADIUS到地球半径的米值。 I was kind of, ok, very surprised when I discovered this actually worked. 当我发现这实际上有效时,我很好,非常惊讶。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM