.NET wrapper for GeographicLib::LocalCartesian. More...
#include <NETGeographicLib/LocalCartesian.h>
Public Member Functions | |
LocalCartesian (double lat0, double lon0, double h0, Geocentric^ earth) | |
LocalCartesian (double lat0, double lon0, double h0) | |
LocalCartesian (Geocentric^ earth) | |
LocalCartesian () | |
~LocalCartesian () | |
void | Reset (double lat0, double lon0, double h0) |
void | Forward (double lat, double lon, double h,[System::Runtime::InteropServices::Out] double% x,[System::Runtime::InteropServices::Out] double% y,[System::Runtime::InteropServices::Out] double% z) |
void | Forward (double lat, double lon, double h,[System::Runtime::InteropServices::Out] double% x,[System::Runtime::InteropServices::Out] double% y,[System::Runtime::InteropServices::Out] double% z,[System::Runtime::InteropServices::Out] array< double, 2 >^%M) |
void | Reverse (double x, double y, double z,[System::Runtime::InteropServices::Out] double% lat,[System::Runtime::InteropServices::Out] double% lon,[System::Runtime::InteropServices::Out] double% h) |
void | Reverse (double x, double y, double z,[System::Runtime::InteropServices::Out] double% lat,[System::Runtime::InteropServices::Out] double% lon,[System::Runtime::InteropServices::Out] double% h,[System::Runtime::InteropServices::Out] array< double, 2 >^%M) |
Properties | |
Inspector functions | |
double | LatitudeOrigin [get] |
double | LongitudeOrigin [get] |
double | HeightOrigin [get] |
double | MajorRadius [get] |
double | Flattening [get] |
.NET wrapper for GeographicLib::LocalCartesian.
This class allows .NET applications to access GeographicLib::LocalCartesian.
Convert between geodetic coordinates latitude = lat, longitude = lon, height = h (measured vertically from the surface of the ellipsoid) to local cartesian coordinates (x, y, z). The origin of local cartesian coordinate system is at lat = lat0, lon = lon0, h = h0. The z axis is normal to the ellipsoid; the y axis points due north. The plane z = - h0 is tangent to the ellipsoid.
The conversions all take place via geocentric coordinates using a Geocentric object.
C# Example:
using System; using NETGeographicLib; namespace example_LocalCartesian { class Program { static void Main(string[] args) { try { Geocentric earth = new Geocentric(); const double lat0 = 48 + 50/60.0, lon0 = 2 + 20/60.0; // Paris LocalCartesian proj = new LocalCartesian(lat0, lon0, 0, earth); { // Sample forward calculation double lat = 50.9, lon = 1.8, h = 0; // Calais double x, y, z; proj.Forward(lat, lon, h, out x, out y, out z); Console.WriteLine(String.Format("{0} {1} {2}", x, y, z)); } { // Sample reverse calculation double x = -38e3, y = 230e3, z = -4e3; double lat, lon, h; proj.Reverse(x, y, z, out lat, out lon, out h); Console.WriteLine(String.Format("{0} {1} {2}", lat, lon, h)); } } catch (GeographicErr e) { Console.WriteLine(String.Format("Caught exception: {0}", e.Message)); } } } }
Managed C++ Example:
using namespace System; using namespace NETGeographicLib; int main(array<System::String ^> ^/*args*/) { try { Geocentric^ earth = gcnew Geocentric(); const double lat0 = 48 + 50/60.0, lon0 = 2 + 20/60.0; // Paris LocalCartesian^ proj = gcnew LocalCartesian(lat0, lon0, 0, earth); { // Sample forward calculation double lat = 50.9, lon = 1.8, h = 0; // Calais double x, y, z; proj->Forward(lat, lon, h, x, y, z); Console::WriteLine(String::Format("{0} {1} {2}", x, y, z)); } { // Sample reverse calculation double x = -38e3, y = 230e3, z = -4e3; double lat, lon, h; proj->Reverse(x, y, z, lat, lon, h); Console::WriteLine(String::Format("{0} {1} {2}", lat, lon, h)); } } catch (GeographicErr^ e) { Console::WriteLine(String::Format("Caught exception: {0}", e->Message)); return -1; } return 0; }
Visual Basic Example:
Imports NETGeographicLib Module example_LocalCartesian Sub Main() Try Dim earth As Geocentric = New Geocentric() Dim lat0 As Double = 48 + 50 / 60.0, lon0 = 2 + 20 / 60.0 ' Paris Dim proj As LocalCartesian = New LocalCartesian(lat0, lon0, 0, earth) ' Sample forward calculation Dim lat As Double = 50.9, lon = 1.8, h = 0 ' Calais Dim x, y, z As Double proj.Forward(lat, lon, h, x, y, z) Console.WriteLine(String.Format("{0} {1} {2}", x, y, z)) ' Sample reverse calculation x = -38000.0 : y = 230000.0 : z = -4000.0 proj.Reverse(x, y, z, lat, lon, h) Console.WriteLine(String.Format("{0} {1} {2}", lat, lon, h)) Catch ex As GeographicErr Console.WriteLine(String.Format("Caught exception: {0}", ex.Message)) End Try End Sub End Module
INTERFACE DIFFERENCES:
Constructors have been provided that assume WGS84 parameters.
The following functions are implemented as properties: LatitudeOrigin, LongitudeOrigin, HeightOrigin, MajorRadius, and Flattening.
The rotation matrices returned by the Forward and Reverse functions are 2D, 3 3 arrays rather than vectors.
Definition at line 48 of file LocalCartesian.h.
NETGeographicLib::LocalCartesian::LocalCartesian | ( | double | lat0, | |
double | lon0, | |||
double | h0, | |||
Geocentric^ | earth | |||
) |
Constructor setting the origin.
[in] | lat0 | latitude at origin (degrees). |
[in] | lon0 | longitude at origin (degrees). |
[in] | h0 | height above ellipsoid at origin (meters); default 0. |
[in] | earth | Geocentric object for the transformation; default Geocentric::WGS84. |
lat0 should be in the range [90, 90]; lon0 should be in the range [540, 540).
NETGeographicLib::LocalCartesian::LocalCartesian | ( | double | lat0, | |
double | lon0, | |||
double | h0 | |||
) |
Constructor setting the origin and assuming a WGS84 ellipsoid.
[in] | lat0 | latitude at origin (degrees). |
[in] | lon0 | longitude at origin (degrees). |
[in] | h0 | height above ellipsoid at origin (meters); default 0. |
lat0 should be in the range [90, 90]; lon0 should be in the range [540, 540).
NETGeographicLib::LocalCartesian::LocalCartesian | ( | Geocentric^ | earth | ) |
Constructor that uses the provided ellipsoid.
[in] | earth | Geocentric object for the transformation; default Geocentric::WGS84. |
Sets lat0 = 0, lon0 = 0, h0 = 0.
NETGeographicLib::LocalCartesian::LocalCartesian | ( | ) |
The default constructor assumes the WGS84 ellipsoid.
Sets lat0 = 0, lon0 = 0, h0 = 0.
Referenced by ~LocalCartesian().
NETGeographicLib::LocalCartesian::~LocalCartesian | ( | ) | [inline] |
The destructor calls the finalizer.
Definition at line 105 of file LocalCartesian.h.
References LocalCartesian().
void NETGeographicLib::LocalCartesian::Reset | ( | double | lat0, | |
double | lon0, | |||
double | h0 | |||
) |
Reset the origin.
[in] | lat0 | latitude at origin (degrees). |
[in] | lon0 | longitude at origin (degrees). |
[in] | h0 | height above ellipsoid at origin (meters); default 0. |
lat0 should be in the range [90, 90]; lon0 should be in the range [540, 540).
void NETGeographicLib::LocalCartesian::Forward | ( | double | lat, | |
double | lon, | |||
double | h, | |||
[System::Runtime::InteropServices::Out] double% | x, | |||
[System::Runtime::InteropServices::Out] double% | y, | |||
[System::Runtime::InteropServices::Out] double% | z | |||
) |
Convert from geodetic to local cartesian coordinates.
[in] | lat | latitude of point (degrees). |
[in] | lon | longitude of point (degrees). |
[in] | h | height of point above the ellipsoid (meters). |
[out] | x | local cartesian coordinate (meters). |
[out] | y | local cartesian coordinate (meters). |
[out] | z | local cartesian coordinate (meters). |
lat should be in the range [90, 90]; lon should be in the range [540, 540).
void NETGeographicLib::LocalCartesian::Forward | ( | double | lat, | |
double | lon, | |||
double | h, | |||
[System::Runtime::InteropServices::Out] double% | x, | |||
[System::Runtime::InteropServices::Out] double% | y, | |||
[System::Runtime::InteropServices::Out] double% | z, | |||
[System::Runtime::InteropServices::Out] array< double, 2 >^% | M | |||
) |
Convert from geodetic to local cartesian coordinates and return rotation matrix.
[in] | lat | latitude of point (degrees). |
[in] | lon | longitude of point (degrees). |
[in] | h | height of point above the ellipsoid (meters). |
[out] | x | local cartesian coordinate (meters). |
[out] | y | local cartesian coordinate (meters). |
[out] | z | local cartesian coordinate (meters). |
[out] | M | a 3 3 rotation matrix. |
lat should be in the range [90, 90]; lon should be in the range [540, 540).
Let v be a unit vector located at (lat, lon, h). We can express v as column vectors in one of two ways
Then we have v0 = M v1.
void NETGeographicLib::LocalCartesian::Reverse | ( | double | x, | |
double | y, | |||
double | z, | |||
[System::Runtime::InteropServices::Out] double% | lat, | |||
[System::Runtime::InteropServices::Out] double% | lon, | |||
[System::Runtime::InteropServices::Out] double% | h | |||
) |
Convert from local cartesian to geodetic coordinates.
[in] | x | local cartesian coordinate (meters). |
[in] | y | local cartesian coordinate (meters). |
[in] | z | local cartesian coordinate (meters). |
[out] | lat | latitude of point (degrees). |
[out] | lon | longitude of point (degrees). |
[out] | h | height of point above the ellipsoid (meters). |
The value of lon returned is in the range [180, 180).
void NETGeographicLib::LocalCartesian::Reverse | ( | double | x, | |
double | y, | |||
double | z, | |||
[System::Runtime::InteropServices::Out] double% | lat, | |||
[System::Runtime::InteropServices::Out] double% | lon, | |||
[System::Runtime::InteropServices::Out] double% | h, | |||
[System::Runtime::InteropServices::Out] array< double, 2 >^% | M | |||
) |
Convert from local cartesian to geodetic coordinates and return rotation matrix.
[in] | x | local cartesian coordinate (meters). |
[in] | y | local cartesian coordinate (meters). |
[in] | z | local cartesian coordinate (meters). |
[out] | lat | latitude of point (degrees). |
[out] | lon | longitude of point (degrees). |
[out] | h | height of point above the ellipsoid (meters). |
[out] | M | a 3 3 rotation matrix. |
Let v be a unit vector located at (lat, lon, h). We can express v as column vectors in one of two ways
Then we have v1 = MT v0, where MT is the transpose of M.
double NETGeographicLib::LocalCartesian::LatitudeOrigin [get] |
Definition at line 224 of file LocalCartesian.h.
double NETGeographicLib::LocalCartesian::LongitudeOrigin [get] |
Definition at line 229 of file LocalCartesian.h.
double NETGeographicLib::LocalCartesian::HeightOrigin [get] |
Definition at line 234 of file LocalCartesian.h.
double NETGeographicLib::LocalCartesian::MajorRadius [get] |
Definition at line 241 of file LocalCartesian.h.
double NETGeographicLib::LocalCartesian::Flattening [get] |
Definition at line 247 of file LocalCartesian.h.