I'm looking to programmatically convert UTM to Web Mercator (a.k.a. Spherical Mercator, EPSG:3857, EPSG:3785, OpenLayers:900913). I'm looking for the algorithm, or something that runs on iOS (Swift, Objective-C or even C). The GDAL C library is not an option to due its huge size (this will be running on a mobile device).
GeographicLib is open source library with implementation in several languages:
- C (geodesic routines): documentation, also included with recent versions of proj.4;
- Fortran (geodesic routines): documentation;
- Java (geodesic routines): Maven Central package, documentation;
- Python (geodesic routines): PyPI package, documentation; Matlab/Octave (geodesic and some other routines): Matlab Central package, documentation;
- C# (.NET wrapper for complete C++ library): documentation;
- IDL (not part of GeographicLib): solving the inverse geodesic problem in IDL by Sean Elvidge and Chris Mannix;
- C# (not part of GeographicLib): GeographicLib (C#) by Surya Pratap (the same capability is provided by the NETGeographicLib);
- Mathematica (not part of GeographicLib): mathematica-geodesic by Kei Misawa.
I'm the author of Snyder Map Projections for Android and have used the code for various Remote Sensing agencies since it implements ALL projection equations in their entirety.
Currently only the Java code is available; however, the projections are easy ported to other languages including Swift (I ported a few projections privately). Don't be overwhelmed with the amount of code... the projections were designed to be wholly independent from one another specifically for language porting reasons.