Public Member Functions | Private Member Functions | Private Attributes | List of all members
NETGeographicLib::TransverseMercatorExact Class Reference

.NET wrapper for GeographicLib::TransverseMercatorExact. More...

#include <TransverseMercatorExact.h>

Public Member Functions

void Forward (double lon0, double lat, double lon, [System::Runtime::InteropServices::Out] double% x, [System::Runtime::InteropServices::Out] double% y)
 
void Forward (double lon0, double lat, double lon, [System::Runtime::InteropServices::Out] double% x, [System::Runtime::InteropServices::Out] double% y, [System::Runtime::InteropServices::Out] double% gamma, [System::Runtime::InteropServices::Out] double% k)
 
void Reverse (double lon0, double x, double y, [System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon)
 
void Reverse (double lon0, double x, double y, [System::Runtime::InteropServices::Out] double% lat, [System::Runtime::InteropServices::Out] double% lon, [System::Runtime::InteropServices::Out] double% gamma, [System::Runtime::InteropServices::Out] double% k)
 
 TransverseMercatorExact ()
 
 TransverseMercatorExact (double a, double f, double k0, bool extendp)
 
 ~TransverseMercatorExact ()
 

Public Attributes

Inspector functions
property double MajorRadius { double get()
 
property double Flattening { double get()
 
property double CentralScale { double get()
 

Private Member Functions

 !TransverseMercatorExact (void)
 

Private Attributes

GeographicLib::TransverseMercatorExactm_pTransverseMercatorExact
 

Detailed Description

.NET wrapper for GeographicLib::TransverseMercatorExact.

This class allows .NET applications to access GeographicLib::TransverseMercatorExact.

Implementation of the Transverse Mercator Projection given in

Lee gives the correct results for forward and reverse transformations subject to the branch cut rules (see the description of the extendp argument to the constructor). The maximum error is about 8 nm (8 nanometers), ground distance, for the forward and reverse transformations. The error in the convergence is 2 × 10−15", the relative error in the scale is 7 × 10−12%%. See Sec. 3 of arXiv:1002.1417 for details. The method is "exact" in the sense that the errors are close to the round-off limit and that no changes are needed in the algorithms for them to be used with reals of a higher precision. Thus the errors using long double (with a 64-bit fraction) are about 2000 times smaller than using double (with a 53-bit fraction).

This algorithm is about 4.5 times slower than the 6th-order Krüger method, TransverseMercator, taking about 11 us for a combined forward and reverse projection on a 2.66 GHz Intel machine (g++, version 4.3.0, -O3).

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 TransverseMercatorExact::Forward and TransverseMercatorExact::Reverse functions. The latitude of origin is taken to be the equator. See the documentation on TransverseMercator for how to include a false easting, false northing, or a latitude of origin.

See tm-grid.kmz, for an illustration of the transverse Mercator grid in Google Earth.

See GeographicLib::TransverseMercatorExact.cpp for more information on the implementation.

See transversemercator for a discussion of this projection.

C# Example:

using System;
namespace example_TransverseMercatorExact
{
class Program
{
static void Main(string[] args)
{
try {
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, out x, out y);
Console.WriteLine(String.Format("{0} {1}", x, y));
}
{
// Sample reverse calculation
double x = 25e3, y = 4461e3;
double lat, lon;
proj.Reverse(lon0, x, y, out lat, out lon);
Console.WriteLine(String.Format("{0} {1}", lat, lon));
}
}
catch (GeographicErr e) {
Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
}
}
}
}

Managed C++ Example:

// Example of using the GeographicLib::TransverseMercatorExact class
#include <iostream>
#include <iomanip>
#include <exception>
using namespace std;
using namespace GeographicLib;
int main() {
try {
TransverseMercatorExact proj(Constants::WGS84_a(), Constants::WGS84_f(),
Constants::UTM_k0());
// Alternatively:
// const TransverseMercatorExact& proj = TransverseMercatorExact::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;
}
}

Visual Basic Example:

Imports NETGeographicLib
Module example_TransverseMercatorExact
Sub Main()
Try
Dim proj As TransverseMercatorExact = New TransverseMercatorExact() ' WGS84
Dim lon0 As Double = -75 ' Central meridian for UTM zone 18
' Sample forward calculation
Dim lat As Double = 40.3, lon = -74.7 ' Princeton, NJ
Dim x, y As Double
proj.Forward(lon0, lat, lon, x, y)
Console.WriteLine(String.Format("{0} {1}", x, y))
' Sample reverse calculation
x = 25000.0 : y = 4461000.0
proj.Reverse(lon0, x, y, lat, lon)
Console.WriteLine(String.Format("{0} {1}", lat, lon))
Catch ex As GeographicErr
Console.WriteLine(String.Format("Caught exception: {0}", ex.Message))
End Try
End Sub
End Module

INTERFACE DIFFERENCES:
A default constructor is provided that assumes WGS84 parameters and a UTM scale factor.

The MajorRadius, Flattening, and CentralScale functions are implemented as properties.

Definition at line 84 of file TransverseMercatorExact.h.

Constructor & Destructor Documentation

◆ !TransverseMercatorExact()

TransverseMercatorExact::!TransverseMercatorExact ( void  )
private

◆ TransverseMercatorExact() [1/2]

TransverseMercatorExact::TransverseMercatorExact ( double  a,
double  f,
double  k0,
bool  extendp 
)

Constructor for a ellipsoid with

Parameters
[in]aequatorial radius (meters).
[in]fflattening of ellipsoid.
[in]k0central scale factor.
[in]extendpuse extended domain.
Exceptions
GeographicErrif a, f, or k0 is not positive.

The transverse Mercator projection has a branch point singularity at lat = 0 and lonlon0 = 90 (1 − e) or (for TransverseMercatorExact::UTM) x = 18381 km, y = 0m. The extendp argument governs where the branch cut is placed. With extendp = false, the "standard" convention is followed, namely the cut is placed along x > 18381 km, y = 0m. Forward can be called with any lat and lon then produces the transformation shown in Lee, Fig 46. Reverse analytically continues this in the ± x direction. As a consequence, Reverse may map multiple points to the same geographic location; for example, for TransverseMercatorExact::UTM, x = 22051449.037349 m, y = −7131237.022729 m and x = 29735142.378357 m, y = 4235043.607933 m both map to lat = −2°, lon = 88°.

With extendp = true, the branch cut is moved to the lower left quadrant. The various symmetries of the transverse Mercator projection can be used to explore the projection on any sheet. In this mode the domains of lat, lon, x, and y are restricted to

  • the union of
    • lat in [0, 90] and lonlon0 in [0, 90]
    • lat in (-90, 0] and lonlon0 in [90 (1 − e), 90]
  • the union of
    • x/(k0 a) in [0, ∞) and y/(k0 a) in [0, E(e2)]
    • x/(k0 a) in [K(1 − e2) − E(1 − e2), ∞) and y/(k0 a) in (−∞, 0]

See Sec. 5 of arXiv:1002.1417 for a full discussion of the treatment of the branch cut.

The method will work for all ellipsoids used in terrestrial geodesy. The method cannot be applied directly to the case of a sphere (f = 0) because some the constants characterizing this method diverge in that limit, and in practice, f should be larger than about numeric_limits<double>::epsilon(). However, TransverseMercator treats the sphere exactly.

Definition at line 31 of file dotnet/NETGeographicLib/TransverseMercatorExact.cpp.

◆ TransverseMercatorExact() [2/2]

TransverseMercatorExact::TransverseMercatorExact ( )

The default constructor assumes a WGS84 ellipsoid and a UTM scale factor.

Definition at line 50 of file dotnet/NETGeographicLib/TransverseMercatorExact.cpp.

◆ ~TransverseMercatorExact()

NETGeographicLib::TransverseMercatorExact::~TransverseMercatorExact ( )
inline

The destructor calls the finalizer.

Definition at line 152 of file TransverseMercatorExact.h.

Member Function Documentation

◆ Forward() [1/2]

void TransverseMercatorExact::Forward ( double  lon0,
double  lat,
double  lon,
[System::Runtime::InteropServices::Out] double%  x,
[System::Runtime::InteropServices::Out] double%  y 
)

TransverseMercatorExact::Forward without returning the convergence and scale.

Definition at line 97 of file dotnet/NETGeographicLib/TransverseMercatorExact.cpp.

◆ Forward() [2/2]

void TransverseMercatorExact::Forward ( double  lon0,
double  lat,
double  lon,
[System::Runtime::InteropServices::Out] double%  x,
[System::Runtime::InteropServices::Out] double%  y,
[System::Runtime::InteropServices::Out] double%  gamma,
[System::Runtime::InteropServices::Out] double%  k 
)

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°].

Definition at line 65 of file dotnet/NETGeographicLib/TransverseMercatorExact.cpp.

◆ Reverse() [1/2]

void TransverseMercatorExact::Reverse ( double  lon0,
double  x,
double  y,
[System::Runtime::InteropServices::Out] double%  lat,
[System::Runtime::InteropServices::Out] double%  lon 
)

TransverseMercatorExact::Reverse without returning the convergence and scale.

Definition at line 108 of file dotnet/NETGeographicLib/TransverseMercatorExact.cpp.

◆ Reverse() [2/2]

void TransverseMercatorExact::Reverse ( double  lon0,
double  x,
double  y,
[System::Runtime::InteropServices::Out] double%  lat,
[System::Runtime::InteropServices::Out] double%  lon,
[System::Runtime::InteropServices::Out] double%  gamma,
[System::Runtime::InteropServices::Out] double%  k 
)

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. The value of lon returned is in the range [−180°, 180°).

Definition at line 81 of file dotnet/NETGeographicLib/TransverseMercatorExact.cpp.

Member Data Documentation

◆ CentralScale

property double NETGeographicLib::TransverseMercatorExact::CentralScale { double get()
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 230 of file TransverseMercatorExact.h.

◆ Flattening

property double NETGeographicLib::TransverseMercatorExact::Flattening { double get()
Returns
f the flattening of the ellipsoid. This is the value used in the constructor.

Definition at line 224 of file TransverseMercatorExact.h.

◆ m_pTransverseMercatorExact

GeographicLib::TransverseMercatorExact* NETGeographicLib::TransverseMercatorExact::m_pTransverseMercatorExact
private

Definition at line 88 of file TransverseMercatorExact.h.

◆ MajorRadius

property double NETGeographicLib::TransverseMercatorExact::MajorRadius { double get()
Returns
a the equatorial radius of the ellipsoid (meters). This is the value used in the constructor.

Definition at line 218 of file TransverseMercatorExact.h.


The documentation for this class was generated from the following files:
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib::TransverseMercatorExact
An exact implementation of the transverse Mercator projection.
Definition: TransverseMercatorExact.hpp:83
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
NETGeographicLib::TransverseMercatorExact::TransverseMercatorExact
TransverseMercatorExact()
Definition: dotnet/NETGeographicLib/TransverseMercatorExact.cpp:50
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
main
int main(int argc, char **argv)
Definition: cmake/example_cmake_find_gtsam/main.cpp:63
example::lon0
const double lon0
Definition: testGPSFactor.cpp:41
out
std::ofstream out("Result.txt")
y
Scalar * y
Definition: level1_cplx_impl.h:124
std
Definition: BFloat16.h:88
args
Definition: pytypes.h:2210
lon
static const double lon
Definition: testGeographicLib.cpp:34
NETGeographicLib
Definition: Accumulator.h:13
TransverseMercatorExact.hpp
Header for GeographicLib::TransverseMercatorExact class.
lat
static const double lat
Definition: testGeographicLib.cpp:34


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:25:01