GeographicLib: GeographicLib::TransverseMercator Class Reference (original) (raw)

Transverse Mercator projection.

This uses Krüger's method which evaluates the projection and its inverse in terms of a series. See

Krüger's method has been extended from 4th to 6th order. The maximum error is 5 nm (5 nanometers), ground distance, for all positions within 35 degrees of the central meridian. The error in the convergence is 2 × 10−15" and the relative error in the scale is 6 × 10−12%%. See Sec. 4 of arXiv:1002.1417 for details. The speed penalty in going to 6th order is only about 1%.

There's a singularity in the projection at φ = 0°, λ − λ0 = ±(1 − e)90° (≈ ±82.6° for the WGS84 ellipsoid), where e is the eccentricity. Beyond this point, the series ceases to converge and the results from this method will be garbage. To be on the safe side, don't use this method if the angular distance from the central meridian exceeds (1 − 2e)90° (≈ 75° for the WGS84 ellipsoid)

TransverseMercatorExact is an alternative implementation of the projection using exact formulas which yield accurate (to 8 nm) results over the entire ellipsoid. This formulation is accessible in this class by calling the constructor with exact = true.

The ellipsoid parameters and the central scale are set in the constructor. The central meridian (which is a trivial shift of the longitude) is specified as the lon0 argument of the TransverseMercator::Forward and TransverseMercator::Reverse functions. The latitude of origin is taken to be the equator. There is no provision in this class for specifying a false easting or false northing or a different latitude of origin. However these are can be simply included by the calling function. For example, the UTMUPS class applies the false easting and false northing for the UTM projections. A more complicated example is the British National Grid (EPSG:7405) which requires the use of a latitude of origin. This is implemented by the GeographicLib::OSGB class.

This class also returns the meridian convergence gamma and scale k. The meridian convergence is the bearing of grid north (the y axis) measured clockwise from true north.

See TransverseMercator.cpp for more information on the implementation.

See Transverse Mercator projection for a discussion of this projection.

Example of use:

#include

#include

#include

using namespace std;

class UTMalt {

private:

double _lon0;

double _falseeasting, _falsenorthing;

public:

UTMalt(double a,

double f,

int zone,

bool northp)

, _lon0(6 * zone - 183)

, _falseeasting(5e5)

, _falsenorthing(northp ? 0 : 100e5) {

if (!(zone >= 1 && zone <= 60))

}

void Forward(double lat, double lon, double& x, double& y) {

_tm.Forward(_lon0, lat, lon, x, y);

x += _falseeasting;

y += _falsenorthing;

}

void Reverse(double x, double y, double& lat, double& lon) {

x -= _falseeasting;

y -= _falsenorthing;

_tm.Reverse(_lon0, x, y, lat, lon);

}

};

try {

UTMalt tm(6378388, 1/297.0, 30, true);

{

double lat = 40.4, lon = -3.7;

double x, y;

tm.Forward(lat, lon, x, y);

cout << fixed << setprecision(0) << x << " " << y << "\n";

}

{

double x = 441e3, y = 4472e3;

double lat, lon;

tm.Reverse(x, y, lat, lon);

cout << fixed << setprecision(5) << lat << " " << lon << "\n";

}

}

catch (const exception& e) {

cerr << "Caught exception: " << e.what() << "\n";

return 1;

}

}

int main(int argc, const char *const argv[])

Header for GeographicLib::TransverseMercator class.

Constants needed by GeographicLib

Exception handling for GeographicLib.

Transverse Mercator projection.

void Reverse(real lon0, real x, real y, real &lat, real &lon, real &gamma, real &k) const

void Forward(real lon0, real lat, real lon, real &x, real &y, real &gamma, real &k) const

Namespace for GeographicLib.

TransverseMercatorProj is a command-line utility providing access to the functionality of this class.

Definition at line 94 of file TransverseMercator.hpp.