IOS: how to convert MKMapPoint or CLLocationCoordinate2D to UTM?

From what I read, complex mathematics is required in which I feel bad. So, I ask here.

Does anyone have experience converting MKMapPoint or CLLocationCoordinate2D to UTM value? I found this resource ( http://www.uwgb.edu/dutchs/usefuldata/UTMFormulas.HTM ), but the math is overwhelming.

+4
source share
3 answers

You can use one lib to do this or analyze the code of one lib to understand the algorithm and do it yourself.

This is the C ++ lib that does the job: http://geographiclib.sourceforge.net/html/

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

I found this site (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 look at it and try to convert to Obj-c.

+2
source

I recently wrote a class for this and posted a sample project on GitHub

UTMConverter example for iOS

The part you want is the UTMConverter.m file. It has methods for converting from lat / long to UTM and vice versa.

+6
source

MKMapViewZoom seems to have some class methods that can convert between flat maps (geometric) and curved maps (geographical) coordinates, although I have not tested them. Someone give me thumbs if this really 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 kind of documentation here

UPDATE:

This is crazy, but in order for this source code of this class to work exactly, I basically had to extract the methods into my own domain, then remove the parts of the code that refer to MERCATOR_OFFSET and change the MERCATOR_RADIUS to meters of the Earth's radius. I was kind of, well, really surprised when I discovered that it really worked.

+1
source

All Articles