GeographicLib  1.35
Public Member Functions | Static Public Attributes | Friends | List of all members
GeographicLib::TransverseMercator Class Reference

Transverse Mercator projection. More...

#include <GeographicLib/TransverseMercator.hpp>

Public Member Functions

 TransverseMercator (real a, real f, real k0)
 
void Forward (real lon0, real lat, real lon, real &x, real &y, real &gamma, real &k) const throw ()
 
void Reverse (real lon0, real x, real y, real &lat, real &lon, real &gamma, real &k) const throw ()
 
void Forward (real lon0, real lat, real lon, real &x, real &y) const throw ()
 
void Reverse (real lon0, real x, real y, real &lat, real &lon) const throw ()
 
Inspector functions
Math::real MajorRadius () const throw ()
 
Math::real Flattening () const throw ()
 
Math::real CentralScale () const throw ()
 

Static Public Attributes

static const TransverseMercator UTM
 

Friends

class Ellipsoid
 

Detailed Description

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%. TransverseMercatorExact is an alternative implementation of the projection using exact formulas which yield accurate (to 8 nm) results over the entire ellipsoid.

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.

See TransverseMercator.cpp for more information on the implementation.

See transversemercator for a discussion of this projection.

Example of use:

// Example of using the GeographicLib::TransverseMercator class
#include <iostream>
#include <exception>
#include <string>
#include <iomanip>
using namespace std;
using namespace GeographicLib;
int main() {
try {
// Alternatively: const TransverseMercator& proj = TransverseMercator::UTM;
double lon0 = -75; // Central meridian for UTM zone 18
{
// Sample forward calculation
double lat = 40.3, lon = -74.7; // Princeton, NJ
double x, y;
proj.Forward(lon0, lat, lon, x, y);
cout << x << " " << y << "\n";
}
{
// Sample reverse calculation
double x = 25e3, y = 4461e3;
double lat, lon;
proj.Reverse(lon0, x, y, lat, lon);
cout << lat << " " << lon << "\n";
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
return 0;
}

TransverseMercatorProj is a command-line utility providing access to the functionality of TransverseMercator and TransverseMercatorExact.

Definition at line 79 of file TransverseMercator.hpp.

Constructor & Destructor Documentation

GeographicLib::TransverseMercator::TransverseMercator ( real  a,
real  f,
real  k0 
)

Constructor for a ellipsoid with

Parameters
[in]aequatorial radius (meters).
[in]fflattening of ellipsoid. Setting f = 0 gives a sphere. Negative f gives a prolate ellipsoid. If f > 1, set flattening to 1/f.
[in]k0central scale factor.
Exceptions
GeographicErrif a, (1 − f ) a, or k0 is not positive.

Definition at line 54 of file TransverseMercator.cpp.

References GeographicLib::Math::isfinite(), GeographicLib::Math::sq(), and STATIC_ASSERT.

Member Function Documentation

void GeographicLib::TransverseMercator::Forward ( real  lon0,
real  lat,
real  lon,
real &  x,
real &  y,
real &  gamma,
real &  k 
) const
throw (
)

Forward projection, from geographic to transverse Mercator.

Parameters
[in]lon0central meridian of the projection (degrees).
[in]latlatitude of point (degrees).
[in]lonlongitude of point (degrees).
[out]xeasting of point (meters).
[out]ynorthing of point (meters).
[out]gammameridian convergence at point (degrees).
[out]kscale of projection at point.

No false easting or northing is added. lat should be in the range [−90°, 90°]; lon and lon0 should be in the range [−540°, 540°).

Definition at line 308 of file TransverseMercator.cpp.

References GeographicLib::Math::AngDiff(), GeographicLib::Math::AngNormalize(), GeographicLib::Math::asinh(), GeographicLib::Math::hypot(), and GeographicLib::Math::sq().

Referenced by GeographicLib::UTMUPS::Forward().

void GeographicLib::TransverseMercator::Reverse ( real  lon0,
real  x,
real  y,
real &  lat,
real &  lon,
real &  gamma,
real &  k 
) const
throw (
)

Reverse projection, from transverse Mercator to geographic.

Parameters
[in]lon0central meridian of the projection (degrees).
[in]xeasting of point (meters).
[in]ynorthing of point (meters).
[out]latlatitude of point (degrees).
[out]lonlongitude of point (degrees).
[out]gammameridian convergence at point (degrees).
[out]kscale of projection at point.

No false easting or northing is added. lon0 should be in the range [−540°, 540°). The value of lon returned is in the range [−180°, 180°).

Definition at line 470 of file TransverseMercator.cpp.

References GeographicLib::Math::AngNormalize(), GeographicLib::Math::hypot(), and GeographicLib::Math::sq().

Referenced by GeographicLib::UTMUPS::Reverse().

void GeographicLib::TransverseMercator::Forward ( real  lon0,
real  lat,
real  lon,
real &  x,
real &  y 
) const
throw (
)
inline

TransverseMercator::Forward without returning the convergence and scale.

Definition at line 157 of file TransverseMercator.hpp.

void GeographicLib::TransverseMercator::Reverse ( real  lon0,
real  x,
real  y,
real &  lat,
real &  lon 
) const
throw (
)
inline

TransverseMercator::Reverse without returning the convergence and scale.

Definition at line 166 of file TransverseMercator.hpp.

Math::real GeographicLib::TransverseMercator::MajorRadius ( ) const
throw (
)
inline
Returns
a the equatorial radius of the ellipsoid (meters). This is the value used in the constructor.

Definition at line 179 of file TransverseMercator.hpp.

Math::real GeographicLib::TransverseMercator::Flattening ( ) const
throw (
)
inline
Returns
f the flattening of the ellipsoid. This is the value used in the constructor.

Definition at line 185 of file TransverseMercator.hpp.

Math::real GeographicLib::TransverseMercator::CentralScale ( ) const
throw (
)
inline
Returns
k0 central scale for the projection. This is the value of k0 used in the constructor and is the scale on the central meridian.

Definition at line 199 of file TransverseMercator.hpp.

Friends And Related Function Documentation

friend class Ellipsoid
friend

Definition at line 102 of file TransverseMercator.hpp.

Member Data Documentation

const TransverseMercator GeographicLib::TransverseMercator::UTM
static

A global instantiation of TransverseMercator with the WGS84 ellipsoid and the UTM scale factor. However, unlike UTM, no false easting or northing is added.

Definition at line 207 of file TransverseMercator.hpp.

Referenced by GeographicLib::UTMUPS::Forward(), and GeographicLib::UTMUPS::Reverse().


The documentation for this class was generated from the following files: