Public Types | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
NETGeographicLib::Geoid Class Reference

.NET wrapper for GeographicLib::Geoid. More...

#include <Geoid.h>

Public Types

enum  ConvertFlag { ConvertFlag::ELLIPSOIDTOGEOID = -1, ConvertFlag::NONE = 0, ConvertFlag::GEOIDTOELLIPSOID = 1 }
 

Public Member Functions

Setting up the geoid
 Geoid (System::String^name, System::String^path, bool cubic, bool threadsafe)
 
 ~Geoid ()
 
void CacheArea (double south, double west, double north, double east)
 
void CacheAll ()
 
void CacheClear ()
 
Compute geoid heights
double Height (double lat, double lon)
 
double ConvertHeight (double lat, double lon, double h, ConvertFlag d)
 

Static Public Member Functions

static System::String DefaultGeoidName ()
 
static System::String DefaultGeoidPath ()
 

Public Attributes

Inspector functions
property System::String Description { System::String^ get()
 
property System::String DateTime { System::String^ get()
 
property System::String GeoidFile { System::String^ get()
 
property System::String GeoidName { System::String^ get()
 
property System::String GeoidDirectory { System::String^ get()
 
property System::String Interpolation { System::String^ get()
 
property double MaxError { double get()
 
property double RMSError { double get()
 
property double Offset { double get()
 
property double Scale { double get()
 
property bool ThreadSafe { bool get()
 
property bool Cache { bool get()
 
property double CacheWest { double get()
 
property double CacheEast { double get()
 
property double CacheNorth { double get()
 
property double CacheSouth { double get()
 
property double MajorRadius { double get()
 
property double Flattening { double get()
 

Private Member Functions

 !Geoid (void)
 

Private Attributes

const GeographicLib::Geoidm_pGeoid
 

Detailed Description

.NET wrapper for GeographicLib::Geoid.

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

This class evaluated the height of one of the standard geoids, EGM84, EGM96, or EGM2008 by bilinear or cubic interpolation into a rectangular grid of data. These geoid models are documented in

The geoids are defined in terms of spherical harmonics. However in order to provide a quick and flexible method of evaluating the geoid heights, this class evaluates the height by interpolation into a grid of precomputed values.

The geoid height, N, can be used to convert a height above the ellipsoid, h, to the corresponding height above the geoid (roughly the height above mean sea level), H, using the relations

   h = N + H;   H = −N + h.

See geoid for details of how to install the data sets, the data format, estimates of the interpolation errors, and how to use caching.

This class is typically not thread safe in that a single instantiation cannot be safely used by multiple threads because of the way the object reads the data set and because it maintains a single-cell cache. If multiple threads need to calculate geoid heights they should all construct thread-local instantiations. Alternatively, set the optional threadsafe parameter to true in the constructor. This causes the constructor to read all the data into memory and to turn off the single-cell caching which results in a Geoid object which is thread safe.

C# Example:

using System;
namespace example_Geoid
{
class Program
{
static void Main(string[] args)
{
try {
Geoid egm96 = new Geoid("egm96-5", "", true, false);
// Convert height above egm96 to height above the ellipsoid
double lat = 42, lon = -75, height_above_geoid = 20;
double
geoid_height = egm96.Height(lat, lon),
height_above_ellipsoid = (height_above_geoid +
(double)Geoid.ConvertFlag.GEOIDTOELLIPSOID * geoid_height);
Console.WriteLine(height_above_ellipsoid);
}
catch (GeographicErr e) {
Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
}
}
}
}

Managed C++ Example:

// Example of using the GeographicLib::Geoid class
#include <iostream>
#include <exception>
using namespace std;
using namespace GeographicLib;
int main() {
try {
Geoid egm96("egm96-5");
// Convert height above egm96 to height above the ellipsoid
double lat = 42, lon = -75, height_above_geoid = 20;
double
geoid_height = egm96(lat, lon),
height_above_ellipsoid = (height_above_geoid +
Geoid::GEOIDTOELLIPSOID * geoid_height);
cout << height_above_ellipsoid << "\n";
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}

Visual Basic Example:

Imports NETGeographicLib
Module example_Geoid
Sub Main()
Try
Dim egm96 As Geoid = New Geoid("egm96-5", "", True, False)
' Convert height above egm96 to height above the ellipsoid
Dim lat As Double = 42, lon = -75, height_above_geoid = 20
Dim geoid_height As Double = egm96.Height(lat, lon)
Dim height_above_ellipsoid As Double = (height_above_geoid +
CDbl(Geoid.ConvertFlag.GEOIDTOELLIPSOID) * geoid_height)
Console.WriteLine(height_above_ellipsoid)
Catch ex As GeographicErr
Console.WriteLine(String.Format("Caught exception: {0}", ex.Message))
End Try
End Sub
End Module

INTERFACE DIFFERENCES:
The () operator has been replaced with Height method.

The following functions are implemented as properties: Description, DateTime, GeoidFile, GeoidName, GeoidDirectory, Interpolation, MaxError, RMSError, Offset, Scale, ThreadSafe, Cache, CacheWest, CacheEast, CacheNorth, CacheSouth, MajorRadius, and Flattening.

Definition at line 71 of file Geoid.h.

Member Enumeration Documentation

Flags indicating conversions between heights above the geoid and heights above the ellipsoid.

Enumerator
ELLIPSOIDTOGEOID 

The multiplier for converting from heights above the geoid to heights above the ellipsoid.

NONE 

No conversion.

GEOIDTOELLIPSOID 

The multiplier for converting from heights above the ellipsoid to heights above the geoid.

Definition at line 84 of file Geoid.h.

Constructor & Destructor Documentation

Geoid::!Geoid ( void  )
private

Definition at line 19 of file dotnet/NETGeographicLib/Geoid.cpp.

Geoid::Geoid ( System::String^  name,
System::String^  path,
bool  cubic,
bool  threadsafe 
)

Construct a geoid.

Parameters
[in]namethe name of the geoid.
[in]path(optional) directory for data file.
[in]cubic(optional) interpolation method; false means bilinear, true (the default) means cubic.
[in]threadsafe(optional), if true, construct a thread safe object. The default is false
Exceptions
GeographicErrif the data file cannot be found, is unreadable, or is corrupt.
GeographicErrif threadsafe is true but the memory necessary for caching the data can't be allocated.

The data file is formed by appending ".pgm" to the name. If path is specified (and is non-empty), then the file is loaded from directory, path. Otherwise the path is given by DefaultGeoidPath(). If the threadsafe parameter is true, the data set is read into memory, the data file is closed, and single-cell caching is turned off; this results in a Geoid object which is thread safe.

Definition at line 29 of file dotnet/NETGeographicLib/Geoid.cpp.

NETGeographicLib::Geoid::~Geoid ( )
inline

The destructor calls the finalizer.

Definition at line 130 of file Geoid.h.

Member Function Documentation

void Geoid::CacheAll ( )

Cache all the data.

Exceptions
GeographicErrif the memory necessary for caching the data can't be allocated (in this case, you will have no cache and can try again with a smaller area).
GeographicErrif there's a problem reading the data.
GeographicErrif this is called on a threadsafe Geoid.

On most computers, this is fast for data sets with grid resolution of 5' or coarser. For a 1' grid, the required RAM is 450MB; a 2.5' grid needs 72MB; and a 5' grid needs 18MB.

Definition at line 64 of file dotnet/NETGeographicLib/Geoid.cpp.

void Geoid::CacheArea ( double  south,
double  west,
double  north,
double  east 
)

Set up a cache.

Parameters
[in]southlatitude (degrees) of the south edge of the cached area.
[in]westlongitude (degrees) of the west edge of the cached area.
[in]northlatitude (degrees) of the north edge of the cached area.
[in]eastlongitude (degrees) of the east edge of the cached area.
Exceptions
GeographicErrif the memory necessary for caching the data can't be allocated (in this case, you will have no cache and can try again with a smaller area).
GeographicErrif there's a problem reading the data.
GeographicErrif this is called on a threadsafe Geoid.

Cache the data for the specified "rectangular" area bounded by the parallels south and north and the meridians west and east. east is always interpreted as being east of west, if necessary by adding 360° to its value. south and north should be in the range [−90°, 90°].

Definition at line 51 of file dotnet/NETGeographicLib/Geoid.cpp.

void Geoid::CacheClear ( )

Clear the cache. This never throws an error. (This does nothing with a thread safe Geoid.)

Definition at line 77 of file dotnet/NETGeographicLib/Geoid.cpp.

double Geoid::ConvertHeight ( double  lat,
double  lon,
double  h,
ConvertFlag  d 
)

Convert a height above the geoid to a height above the ellipsoid and vice versa.

Parameters
[in]latlatitude of the point (degrees).
[in]lonlongitude of the point (degrees).
[in]hheight of the point (degrees).
[in]da Geoid::convertflag specifying the direction of the conversion; Geoid::GEOIDTOELLIPSOID means convert a height above the geoid to a height above the ellipsoid; Geoid::ELLIPSOIDTOGEOID means convert a height above the ellipsoid to a height above the geoid.
Exceptions
GeographicErrif there's a problem reading the data; this never happens if (lat, lon) is within a successfully cached area.
Returns
converted height (meters).

Definition at line 96 of file dotnet/NETGeographicLib/Geoid.cpp.

System::String Geoid::DefaultGeoidName ( )
static
Returns
the default name for the geoid.

This is the value of the environment variable GEOGRAPHICLIB_GEOID_NAME, if set, otherwise, it is "egm96-5". The Geoid class does not use this function; it is just provided as a convenience for a calling program when constructing a Geoid object.

Definition at line 125 of file dotnet/NETGeographicLib/Geoid.cpp.

System::String Geoid::DefaultGeoidPath ( )
static
Returns
the default path for geoid data files.

This is the value of the environment variable GEOGRAPHICLIB_GEOID_PATH, if set; otherwise, it is $GEOGRAPHICLIB_DATA/geoids if the environment variable GEOGRAPHICLIB_DATA is set; otherwise, it is a compile-time default (/usr/local/share/GeographicLib/geoids on non-Windows systems and C:/ProgramData/GeographicLib/geoids on Windows systems).

Definition at line 111 of file dotnet/NETGeographicLib/Geoid.cpp.

double Geoid::Height ( double  lat,
double  lon 
)

Compute the geoid height at a point

Parameters
[in]latlatitude of the point (degrees).
[in]lonlongitude of the point (degrees).
Exceptions
GeographicErrif there's a problem reading the data; this never happens if (lat, lon) is within a successfully cached area.
Returns
geoid height (meters).

The latitude should be in [−90°, 90°].

Definition at line 83 of file dotnet/NETGeographicLib/Geoid.cpp.

Member Data Documentation

property bool NETGeographicLib::Geoid::Cache { bool get()
Returns
true if a data cache is active.

Definition at line 290 of file Geoid.h.

property double NETGeographicLib::Geoid::CacheEast { double get()
Returns
east edge of the cached area; the cache excludes this edge.

Definition at line 300 of file Geoid.h.

property double NETGeographicLib::Geoid::CacheNorth { double get()
Returns
north edge of the cached area; the cache includes this edge.

Definition at line 305 of file Geoid.h.

property double NETGeographicLib::Geoid::CacheSouth { double get()
Returns
south edge of the cached area; the cache excludes this edge unless it's the south pole.

Definition at line 311 of file Geoid.h.

property double NETGeographicLib::Geoid::CacheWest { double get()
Returns
west edge of the cached area; the cache includes this edge.

Definition at line 295 of file Geoid.h.

property System::String NETGeographicLib::Geoid::DateTime { System::String^ get()
Returns
date of the data file; if absent, return "UNKNOWN".

Definition at line 225 of file Geoid.h.

property System::String NETGeographicLib::Geoid::Description { System::String^ get()
Returns
geoid description, if available, in the data file; if absent, return "NONE".

Definition at line 220 of file Geoid.h.

property double NETGeographicLib::Geoid::Flattening { double get()
Returns
f the flattening of the WGS84 ellipsoid.

(The WGS84 value is returned because the supported geoid models are all based on this ellipsoid.)

Definition at line 327 of file Geoid.h.

property System::String NETGeographicLib::Geoid::GeoidDirectory { System::String^ get()
Returns
directory used to load the geoid data.

Definition at line 241 of file Geoid.h.

property System::String NETGeographicLib::Geoid::GeoidFile { System::String^ get()
Returns
full file name used to load the geoid data.

Definition at line 230 of file Geoid.h.

property System::String NETGeographicLib::Geoid::GeoidName { System::String^ get()
Returns
"name" used to load the geoid data (from the first argument of the constructor).

Definition at line 236 of file Geoid.h.

property System::String NETGeographicLib::Geoid::Interpolation { System::String^ get()
Returns
interpolation method ("cubic" or "bilinear").

Definition at line 246 of file Geoid.h.

const GeographicLib::Geoid* NETGeographicLib::Geoid::m_pGeoid
private

Definition at line 75 of file Geoid.h.

property double NETGeographicLib::Geoid::MajorRadius { double get()
Returns
a the equatorial radius of the WGS84 ellipsoid (meters).

(The WGS84 value is returned because the supported geoid models are all based on this ellipsoid.)

Definition at line 319 of file Geoid.h.

property double NETGeographicLib::Geoid::MaxError { double get()
Returns
estimate of the maximum interpolation and quantization error (meters).

This relies on the value being stored in the data file. If the value is absent, return −1.

Definition at line 255 of file Geoid.h.

property double NETGeographicLib::Geoid::Offset { double get()
Returns
offset (meters).

This in used in converting from the pixel values in the data file to geoid heights.

Definition at line 272 of file Geoid.h.

property double NETGeographicLib::Geoid::RMSError { double get()
Returns
estimate of the RMS interpolation and quantization error (meters).

This relies on the value being stored in the data file. If the value is absent, return −1.

Definition at line 264 of file Geoid.h.

property double NETGeographicLib::Geoid::Scale { double get()
Returns
scale (meters).

This in used in converting from the pixel values in the data file to geoid heights.

Definition at line 280 of file Geoid.h.

property bool NETGeographicLib::Geoid::ThreadSafe { bool get()
Returns
true if the object is constructed to be thread safe.

Definition at line 285 of file Geoid.h.


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


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