GeographicLib is a small set of C++ classes to perform conversions between geographic, UTM, UPS, MGRS, geocentric, and local cartesian coordinates. In this application, the errors are close to round-off (about 5 nm). It is specialized for use with the WGS84 but can be adapted for use with other ellipsoids. In addition, various properties of the Transverse Mercator Projection are described and a new accurate algorithm for Geodesics on the Ellipsoid is given.
The code is available for download at either of
(The two archives have identical contents; however, the text files in the zip archive have Windows-style line endings.)
It is licensed under the LGPL. For more information, see http://charles.karney.info/geographic/