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

.NET wrapper for GeographicLib::TransverseMercator. More...

#include <TransverseMercator.h>

Public Member Functions

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 Forward (double lon0, double lat, double lon, [System::Runtime::InteropServices::Out] double%x, [System::Runtime::InteropServices::Out] double%y)
 
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)
 
void Reverse (double lon0, double x, double y, [System::Runtime::InteropServices::Out] double%lat, [System::Runtime::InteropServices::Out] double%lon)
 
 TransverseMercator (double a, double f, double k0)
 
 TransverseMercator ()
 
 ~TransverseMercator ()
 

Public Attributes

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

Private Member Functions

 !TransverseMercator (void)
 

Private Attributes

const GeographicLib::TransverseMercatorm_pTransverseMercator
 

Detailed Description

.NET wrapper for GeographicLib::TransverseMercator.

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

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 GeographicLib::TransverseMercator.cpp for more information on the implementation.

See transversemercator for a discussion of this projection.

C# Example:

using System;
namespace example_TransverseMercator
{
class Program
{
static void Main(string[] args)
{
try {
TransverseMercator proj = new TransverseMercator(); // WGS84
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::TransverseMercator class
#include <iostream>
#include <iomanip>
#include <exception>
using namespace std;
using namespace GeographicLib;
// Define a UTM projection for an arbitrary ellipsoid
class UTMalt {
private:
TransverseMercator _tm; // The projection
double _lon0; // Central longitude
double _falseeasting, _falsenorthing;
public:
UTMalt(double a, // equatorial radius
double f, // flattening
int zone, // the UTM zone + hemisphere
bool northp)
: _tm(a, f, Constants::UTM_k0())
, _lon0(6 * zone - 183)
, _falseeasting(5e5)
, _falsenorthing(northp ? 0 : 100e5) {
if (!(zone >= 1 && zone <= 60))
throw GeographicErr("zone not in [1,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);
}
};
int main() {
try {
UTMalt tm(6378388, 1/297.0, 30, true); // International ellipsoid, zone 30n
{
// Sample forward calculation
double lat = 40.4, lon = -3.7; // Madrid
double x, y;
tm.Forward(lat, lon, x, y);
cout << fixed << setprecision(0) << x << " " << y << "\n";
}
{
// Sample reverse calculation
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;
}
}

Visual Basic Example:

Imports NETGeographicLib
Module example_TransverseMercator
Sub Main()
Try
Dim proj As TransverseMercator = New TransverseMercator() ' 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 77 of file TransverseMercator.h.

Constructor & Destructor Documentation

TransverseMercator::!TransverseMercator ( void  )
private
TransverseMercator::TransverseMercator ( double  a,
double  f,
double  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.
[in]k0central scale factor.
Exceptions
GeographicErrif a, (1 − f ) a, or k0 is not positive.

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

TransverseMercator::TransverseMercator ( )

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

Definition at line 48 of file dotnet/NETGeographicLib/TransverseMercator.cpp.

NETGeographicLib::TransverseMercator::~TransverseMercator ( )
inline

The destructor calls the finalizer.

Definition at line 106 of file TransverseMercator.h.

Member Function Documentation

void TransverseMercator::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 62 of file dotnet/NETGeographicLib/TransverseMercator.cpp.

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

TransverseMercator::Forward without returning the convergence and scale.

Definition at line 92 of file dotnet/NETGeographicLib/TransverseMercator.cpp.

void TransverseMercator::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 77 of file dotnet/NETGeographicLib/TransverseMercator.cpp.

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

TransverseMercator::Reverse without returning the convergence and scale.

Definition at line 103 of file dotnet/NETGeographicLib/TransverseMercator.cpp.

Member Data Documentation

property double NETGeographicLib::TransverseMercator::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 182 of file TransverseMercator.h.

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

Definition at line 176 of file TransverseMercator.h.

const GeographicLib::TransverseMercator* NETGeographicLib::TransverseMercator::m_pTransverseMercator
private

Definition at line 81 of file TransverseMercator.h.

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

Definition at line 170 of file TransverseMercator.h.


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


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:59:12