Code organization
Back to Getting Started. Forward to Transverse Mercator Projection. Up to Contents.

Here is a brief description of the relationship between the various components of GeographicLib.

GeographicLib::TransverseMercator and GeographicLib::PolarStereographic provide the basic projections. The constructors for these classes specify the ellipsoid and the forward and reverse projections are implemented as const member functions. TransverseMercator uses Krüger's series which have been extended to sixth order in the square of the eccentricity. PolarStereographic uses the exact formulas for the projection (from Snyder).

GeographicLib::TransverseMercator::UTM and GeographicLib::PolarStereographic::UPS are const static instantiations specific for the WGS84 ellipsoid with the UTM and UPS scale factors. (These do not add the standard false eastings or false northings for UTM and UPS.)

GeographicLib::UTMUPS uses TransverseMercator::UTM and PolarStereographic::UPS to perform the UTM and UPS projections. The class offers a uniform interface to UTM and UPS by treating UPS as UTM zone 0. This class stores no internal state and the forward and reverse projections are provided via static member functions. The forward projection offers the ability to override the standard UTM/UPS choice and the UTM zone.

GeographicLib::MGRS transforms between UTM/UPS coordinates and MGRS. UPS coordinates are handled as UTM zone 0. This class stores no internal state and the forward (UTM/UPS to MGRS) and reverse (MGRS to UTM/UPS) conversions are provided via static member functions.

GeographicLib::GeoCoords holds a single geographic location which may be specified as latitude and longitude, UTM or UPS, or MGRS. Member functions are provided to convert between coordinate systems and to provide formatted representations of them.

GeoConvert is a simple command line utility to provide access to the GeoCoords class.

GeographicLib::TransverseMercatorExact is a drop in replacement for TransverseMercator which uses the exact formulas, based on elliptic functions, for the projection as given by Lee. TransverseMercatorTest is a simple command line utility to test to the TransverseMercator and TransverseMercatorExact.

GeographicLib::Geodesic and GeographicLib::GeodesicLine perform geodesic calculations. The constructor for GeographicLib::Geodesic specifies the ellipsoid and the direct and inverse calculations are implemented as const member functions. GeographicLib::Geocentric::WGS84 is a const static instantiation of Geodesic specific for the WGS84 ellipsoid. In order to perform a series of direct geodesic calculations on a single line, the GeographicLib::GeodesicLine class can be used. This packages all the information needed to specify a geodesic. A const member function returns the coordinates a specified distance from the starting point. Geod is a simple command line utility to perform geodesic calculations.

GeographicLib::Geocentric and GeographicLib::LocalCartesian convert between geodetic and geocentric or a local cartesian system. The constructor for specifies the ellipsoid and the forward and reverse projections are implemented as const member functions. GeographicLib::Geocentric::WGS84 is a const static instantiation of Geocentric specific for the WGS84 ellipsoid. CartConvert is a simple command line utility to provide access to these classes.

GeographicLib::Constants, GeographicLib::DMS, and GeographicLib::EllipticFunction are utility classes which are used internally by the library.

In order to avoid name clashes, all there classes are in the GeographicLib namespace. The header files are included with the GeographicLib/ directory prefix. If compiling within the GeographicLib directory, ".." should be included in the header search path (e.g., with -I..). The cpp files implementing the classes include "using namespace std;", however, for portability, the headers files and the test programs do not.

There's an "install" target in the Makefile which installs the library components into $(PREFIX)/lib, $(PREFIX)/include/GeographicLib, $(PREFIX)/bin. Once installed, the library can be used by setting

in the Makefile.

The low level projection classes, TransverseMercator and PolarStereographic, do not throw exceptions. UTMUPS, MGRS, and GeoCoords all check their arguments and throw std::out_of_range exceptions with a explanatory message. See GeoConvert.cpp for an example of how exceptions can be handled.

Back to Getting Started. Forward to Transverse Mercator Projection. Up to Contents.