NETGeographicLib::LocalCartesian Class Reference

.NET wrapper for GeographicLib::LocalCartesian. More...

#include <NETGeographicLib/LocalCartesian.h>

List of all members.

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]

Detailed Description

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


Constructor & Destructor Documentation

NETGeographicLib::LocalCartesian::LocalCartesian ( double  lat0,
double  lon0,
double  h0,
Geocentric^   earth 
)

Constructor setting the origin.

Parameters:
[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.

Parameters:
[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.

Parameters:
[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().


Member Function Documentation

void NETGeographicLib::LocalCartesian::Reset ( double  lat0,
double  lon0,
double  h0 
)

Reset the origin.

Parameters:
[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.

Parameters:
[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.

Parameters:
[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

  • in east, north, up coordinates (where the components are relative to a local coordinate system at (lat, lon, h)); call this representation v1.
  • in x, y, z coordinates (where the components are relative to the local coordinate system at (lat0, lon0, h0)); call this representation v0.

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.

Parameters:
[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.

Parameters:
[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

  • in east, north, up coordinates (where the components are relative to a local coordinate system at (lat, lon, h)); call this representation v1.
  • in x, y, z coordinates (where the components are relative to the local coordinate system at (lat0, lon0, h0)); call this representation v0.

Then we have v1 = MT v0, where MT is the transpose of M.


Property Documentation

double NETGeographicLib::LocalCartesian::LatitudeOrigin [get]
Returns:
latitude of the origin (degrees).

Definition at line 224 of file LocalCartesian.h.

double NETGeographicLib::LocalCartesian::LongitudeOrigin [get]
Returns:
longitude of the origin (degrees).

Definition at line 229 of file LocalCartesian.h.

double NETGeographicLib::LocalCartesian::HeightOrigin [get]
Returns:
height of the origin (meters).

Definition at line 234 of file LocalCartesian.h.

double NETGeographicLib::LocalCartesian::MajorRadius [get]
Returns:
a the equatorial radius of the ellipsoid (meters). This is the value of a inherited from the Geocentric object used in the constructor.

Definition at line 241 of file LocalCartesian.h.

double NETGeographicLib::LocalCartesian::Flattening [get]
Returns:
f the flattening of the ellipsoid. This is the value inherited from the Geocentric object used in the constructor.

Definition at line 247 of file LocalCartesian.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends

Generated on 6 Oct 2014 for NETGeographicLib by  doxygen 1.6.1