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

.NET wrapper for GeographicLib::GeoCoords. More...

#include <GeoCoords.h>

Public Member Functions

Initializing the GeoCoords object
 GeoCoords ()
 
 GeoCoords (System::String^ s, bool centerp, bool longfirst)
 
 GeoCoords (double latitude, double longitude, int zone)
 
 GeoCoords (int zone, bool northp, double easting, double northing)
 
 ~GeoCoords ()
 
void Reset (System::String^ s, bool centerp, bool longfirst)
 
void Reset (double latitude, double longitude, int zone)
 
void Reset (int zone, bool northp, double easting, double northing)
 
String representations of the GeoCoords object
System::String GeoRepresentation (int prec, bool longfirst)
 
System::String DMSRepresentation (int prec, bool longfirst, char dmssep)
 
System::String MGRSRepresentation (int prec)
 
System::String UTMUPSRepresentation (int prec, bool abbrev)
 
System::String UTMUPSRepresentation (bool northp, int prec, bool abbrev)
 
System::String AltMGRSRepresentation (int prec)
 
System::String AltUTMUPSRepresentation (int prec, bool abbrev)
 
System::String AltUTMUPSRepresentation (bool northp, int prec, bool abbrev)
 

Public Attributes

property double AltConvergence { double get()
 
property double AltEasting { double get()
 
property double AltNorthing { double get()
 
property double AltScale { double get()
 
Inspector functions
property double MajorRadius { double get()
 
property double Flattening { double get()
 

Private Member Functions

 !GeoCoords ()
 

Private Attributes

GeographicLib::GeoCoordsm_pGeoCoords
 

Querying the GeoCoords object

property double Latitude { double get()
 
property double Longitude { double get()
 
property double Easting { double get()
 
property double Northing { double get()
 
property double Convergence { double get()
 
property double Scale { double get()
 
property bool Northp { bool get()
 
property char Hemisphere { char get()
 
property int Zone { int get()
 
property int AltZone
 
void set (int zone)
 

Detailed Description

.NET wrapper for GeographicLib::GeoCoords.

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

This class stores a geographic position which may be set via the constructors or Reset via

The state consists of the latitude and longitude and the supplied UTM or UPS coordinates (possibly derived from the MGRS coordinates). If latitude and longitude were given then the UTM/UPS coordinates follows the standard conventions.

The mutable state consists of the UTM or UPS coordinates for a alternate zone. A method SetAltZone is provided to set the alternate UPS/UTM zone.

Methods are provided to return the geographic coordinates, the input UTM or UPS coordinates (and associated meridian convergence and scale), or alternate UTM or UPS coordinates (and their associated meridian convergence and scale).

Once the input string has been parsed, you can print the result out in any of the formats, decimal degrees, degrees minutes seconds, MGRS, UTM/UPS.

C# Example:

using System;
namespace example_GeoCoords
{
class Program
{
static void Main(string[] args)
{
try {
// Miscellaneous conversions
double lat = 33.3, lon = 44.4;
GeoCoords c = new GeoCoords(lat, lon, -1);
Console.WriteLine(c.MGRSRepresentation(-3));
c.Reset("18TWN0050", true, false);
Console.WriteLine(c.DMSRepresentation(0, false, 0));
Console.WriteLine(String.Format("Latitude: {0} Longitude: {1}", c.Latitude, c.Longitude));
c.Reset("1d38'W 55d30'N", true, false);
Console.WriteLine(c.GeoRepresentation(0, false));
}
catch (GeographicErr e) {
Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
}
}
}
}

Managed C++ Example:

// Example of using the GeographicLib::GeoCoords class
#include <iostream>
#include <exception>
using namespace std;
using namespace GeographicLib;
int main() {
try {
// Miscellaneous conversions
double lat = 33.3, lon = 44.4;
cout << c.MGRSRepresentation(-3) << "\n";
c.Reset("18TWN0050");
cout << c.DMSRepresentation() << "\n";
cout << c.Latitude() << " " << c.Longitude() << "\n";
c.Reset("1d38'W 55d30'N");
cout << c.GeoRepresentation() << "\n";
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}

Visual Basic Example:

Imports NETGeographicLib
Module example_GeoCoords
Sub Main()
Try
' Miscellaneous conversions
Dim lat As Double = 33.3, lon = 44.4
Dim c As GeoCoords = New GeoCoords(lat, lon, -1)
Console.WriteLine(c.MGRSRepresentation(-3))
c.Reset("18TWN0050", True, False)
Console.WriteLine(c.DMSRepresentation(0, False, 0))
Console.WriteLine(String.Format("Latitude: {0} Longitude: {1}", c.Latitude, c.Longitude))
c.Reset("1d38'W 55d30'N", True, False)
Console.WriteLine(c.GeoRepresentation(0, False))
Catch ex As GeographicErr
Console.WriteLine(String.Format("Caught exception: {0}", ex.Message))
End Try
End Sub
End Module

INTERFACE DIFFERENCES:
The following functions are implemented as properties: MajorRadius, Flattening, Latitude, Longitude, Easting, Northing, Convergence, Scale, Northp, Hemisphere, Zone, AltZone, AltEasting, AltNorthing, AltConvergence, and AltScale.

Definition at line 55 of file GeoCoords.h.

Constructor & Destructor Documentation

◆ !GeoCoords()

GeoCoords::!GeoCoords ( )
private

Definition at line 22 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ GeoCoords() [1/4]

GeoCoords::GeoCoords ( )

The default constructor sets the coordinate as undefined.

Definition at line 32 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ GeoCoords() [2/4]

GeoCoords::GeoCoords ( System::String^  s,
bool  centerp,
bool  longfirst 
)

Construct from a string.

Parameters
[in]s1-element, 2-element, or 3-element string representation of the position.
[in]centerpgoverns the interpretation of MGRS coordinates (see below).
[in]longfirstgoverns the interpretation of geographic coordinates (see below).
Exceptions
GeographicErrif the s is malformed (see below).

Parse as a string and interpret it as a geographic position. The input string is broken into space (or comma) separated pieces and Basic decision on which format is based on number of components

  1. MGRS
  2. "Lat Long" or "Long Lat"
  3. "Zone Easting Northing" or "Easting Northing Zone"

The following inputs are approximately the same (Ar Ramadi Bridge, Iraq)

  • Latitude and Longitude
    • 33.44 43.27
    • N33d26.4' E43d16.2'
    • 43d16'12"E 33d26'24"N
    • 43:16:12E 33:26:24
  • MGRS
    • 38SLC30
    • 38SLC391014
    • 38SLC3918701405
    • 37SHT9708
  • UTM
    • 38N 339188 3701405
    • 897039 3708229 37N

Latitude and Longitude parsing: Latitude precedes longitude, unless a N, S, E, W hemisphere designator is used on one or both coordinates. If longfirst = true (default is false), then longitude precedes latitude in the absence of a hemisphere designator. Thus (with longfirst = false)

  • 40 -75
  • N40 W75
  • -75 N40
  • 75W 40N
  • E-75 -40S

are all the same position. The coordinates may be given in decimal degrees, degrees and decimal minutes, degrees, minutes, seconds, etc. Use d, ', and " to mark off the degrees, minutes and seconds. Various alternative symbols for degrees, minutes, and seconds are allowed. Alternatively, use : to separate these components. (See DMS::Decode for details.) Thus

  • 40d30'30"
  • 40d30'30
  • 40°30'30
  • 40d30.5'
  • 40d30.5
  • 40:30:30
  • 40:30.5
  • 40.508333333

all specify the same angle. The leading sign applies to all components so -1d30 is -(1+30/60) = -1.5. Latitudes must be in the range [−90°, 90°]. Internally longitudes are reduced to the range [−180°, 180°).

UTM/UPS parsing: For UTM zones (−80° ≤ Lat < 84°), the zone designator is made up of a zone number (for 1 to 60) and a hemisphere letter (N or S), e.g., 38N. The latitude zone designer ([C–M] in the southern hemisphere and [N–X] in the northern) should NOT be used. (This is part of the MGRS coordinate.) The zone designator for the poles (where UPS is employed) is a hemisphere letter by itself, i.e., N or S.

MGRS parsing interprets the grid references as square area at the specified precision (1m, 10m, 100m, etc.). If centerp = true (the default), the center of this square is then taken to be the precise position; thus:

  • 38SMB = 38N 450000 3650000
  • 38SMB4484 = 38N 444500 3684500
  • 38SMB44148470 = 38N 444145 3684705

Otherwise, the "south-west" corner of the square is used, i.e.,

  • 38SMB = 38N 400000 3600000
  • 38SMB4484 = 38N 444000 3684000
  • 38SMB44148470 = 38N 444140 3684700

Definition at line 45 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ GeoCoords() [3/4]

GeoCoords::GeoCoords ( double  latitude,
double  longitude,
int  zone 
)

Construct from geographic coordinates.

Parameters
[in]latitude(degrees).
[in]longitude(degrees).
[in]zoneif specified, force the UTM/UPS representation to use a specified zone using the rules given in UTMUPS::zonespec.
Exceptions
GeographicErrif latitude is not in [−90°, 90°].
GeographicErrif zone cannot be used for this location.

Definition at line 62 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ GeoCoords() [4/4]

GeoCoords::GeoCoords ( int  zone,
bool  northp,
double  easting,
double  northing 
)

Construct from UTM/UPS coordinates.

Parameters
[in]zoneUTM zone (zero means UPS).
[in]northphemisphere (true means north, false means south).
[in]easting(meters).
[in]northing(meters).
Exceptions
GeographicErrif zone, easting, or northing is outside its allowed range.

Definition at line 79 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ ~GeoCoords()

NETGeographicLib::GeoCoords::~GeoCoords ( )
inline

The destructor calls the finalizer.

Definition at line 187 of file GeoCoords.h.

Member Function Documentation

◆ AltMGRSRepresentation()

System::String GeoCoords::AltMGRSRepresentation ( int  prec)

MGRS string for the alternate zone. See GeoCoords::MGRSRepresentation.

Parameters
[in]precprecision (relative to about 1m).
Exceptions
std::bad_allocif memory for the string can't be allocated.
Returns
MGRS string.

Definition at line 228 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ AltUTMUPSRepresentation() [1/2]

System::String GeoCoords::AltUTMUPSRepresentation ( bool  northp,
int  prec,
bool  abbrev 
)

UTM/UPS string for the alternate zone, with hemisphere override.

Parameters
[in]northphemisphere override
[in]precprecision (relative to about 1m)
[in]abbrevif true (the default) use abbreviated (n/s) notation for hemisphere; otherwise spell out the hemisphere (north/south)
Exceptions
GeographicErrif the hemisphere override attempts to change UPS n to UPS s or vice verse.
std::bad_allocif memory for the string can't be allocated.
Returns
UTM/UPS string representation: zone designator, easting, and northing.

Definition at line 240 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ AltUTMUPSRepresentation() [2/2]

System::String GeoCoords::AltUTMUPSRepresentation ( int  prec,
bool  abbrev 
)

UTM/UPS string for the alternate zone. See GeoCoords::UTMUPSRepresentation.

Parameters
[in]precprecision (relative to about 1m)
[in]abbrevif true (the default) use abbreviated (n/s) notation for hemisphere; otherwise spell out the hemisphere (north/south)
Exceptions
std::bad_allocif memory for the string can't be allocated.
Returns
UTM/UPS string representation: zone designator, easting, and northing.

Definition at line 234 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ DMSRepresentation()

System::String GeoCoords::DMSRepresentation ( int  prec,
bool  longfirst,
char  dmssep 
)

String representation with latitude and longitude as degrees, minutes, seconds, and hemisphere.

Parameters
[in]precprecision (relative to about 1m)
[in]longfirstif true give longitude first (default = false)
[in]dmssepif non-null, use as the DMS separator character (instead of d, ', " delimiters).
Exceptions
std::bad_allocif memory for the string can't be allocated.
Returns
DMS latitude/longitude string representation.

Precision specifies accuracy of representation as follows:

  • prec = −5 (min), 1°
  • prec = −4, 0.1°
  • prec = −3, 1'
  • prec = −2, 0.1'
  • prec = −1, 1"
  • prec = 0, 0.1" (about 3m)
  • prec = 1, 0.01"
  • prec = 10 (max), 10−11"

Definition at line 203 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ GeoRepresentation()

System::String GeoCoords::GeoRepresentation ( int  prec,
bool  longfirst 
)

String representation with latitude and longitude as signed decimal degrees.

Parameters
[in]precprecision (relative to about 1m).
[in]longfirstif true give longitude first (default = false)
Exceptions
std::bad_allocif memory for the string can't be allocated.
Returns
decimal latitude/longitude string representation.

Precision specifies accuracy of representation as follows:

  • prec = −5 (min), 1°
  • prec = 0, 10−5° (about 1m)
  • prec = 3, 10−8°
  • prec = 9 (max), 10−14°

Definition at line 197 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ MGRSRepresentation()

System::String GeoCoords::MGRSRepresentation ( int  prec)

MGRS string.

Parameters
[in]precprecision (relative to about 1m).
Exceptions
std::bad_allocif memory for the string can't be allocated.
Returns
MGRS string.

This gives the coordinates of the enclosing grid square with size given by the precision. Thus 38N 444180 3684790 converted to a MGRS coordinate at precision −2 (100m) is 38SMB441847 and not 38SMB442848. prec specifies the precision of the MGRS string as follows:

  • prec = −5 (min), 100km
  • prec = −4, 10km
  • prec = −3, 1km
  • prec = −2, 100m
  • prec = −1, 10m
  • prec = 0, 1m
  • prec = 1, 0.1m
  • prec = 6 (max), 1μm

Definition at line 210 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ Reset() [1/3]

void GeoCoords::Reset ( double  latitude,
double  longitude,
int  zone 
)

Reset the location in terms of geographic coordinates. See GeoCoords(double latitude, double longitude, int zone).

Parameters
[in]latitude(degrees).
[in]longitude(degrees).
[in]zoneif specified, force the UTM/UPS representation to use a specified zone using the rules given in UTMUPS::zonespec.
Exceptions
GeographicErrif latitude is not in [−90°, 90°].
GeographicErrif zone cannot be used for this location.

Definition at line 109 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ Reset() [2/3]

void GeoCoords::Reset ( int  zone,
bool  northp,
double  easting,
double  northing 
)

Reset the location in terms of UPS/UPS coordinates. See GeoCoords(int zone, bool northp, double easting, double northing).

Parameters
[in]zoneUTM zone (zero means UPS).
[in]northphemisphere (true means north, false means south).
[in]easting(meters).
[in]northing(meters).
Exceptions
GeographicErrif zone, easting, or northing is outside its allowed range.

Definition at line 122 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ Reset() [3/3]

void GeoCoords::Reset ( System::String^  s,
bool  centerp,
bool  longfirst 
)

Reset the location from a string. See GeoCoords(const std::string& s, bool centerp, bool longfirst).

Parameters
[in]s1-element, 2-element, or 3-element string representation of the position.
[in]centerpgoverns the interpretation of MGRS coordinates.
[in]longfirstgoverns the interpretation of geographic coordinates.
Exceptions
GeographicErrif the s is malformed.

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

◆ set()

void NETGeographicLib::GeoCoords::set ( int  zone)

◆ UTMUPSRepresentation() [1/2]

System::String GeoCoords::UTMUPSRepresentation ( bool  northp,
int  prec,
bool  abbrev 
)

UTM/UPS string with hemisphere override.

Parameters
[in]northphemisphere override
[in]precprecision (relative to about 1m)
[in]abbrevif true (the default) use abbreviated (n/s) notation for hemisphere; otherwise spell out the hemisphere (north/south)
Exceptions
GeographicErrif the hemisphere override attempts to change UPS N to UPS S or vice versa.
std::bad_allocif memory for the string can't be allocated.
Returns
UTM/UPS string representation: zone designator, easting, and northing.

Definition at line 222 of file dotnet/NETGeographicLib/GeoCoords.cpp.

◆ UTMUPSRepresentation() [2/2]

System::String GeoCoords::UTMUPSRepresentation ( int  prec,
bool  abbrev 
)

UTM/UPS string.

Parameters
[in]precprecision (relative to about 1m)
[in]abbrevif true (the default) use abbreviated (n/s) notation for hemisphere; otherwise spell out the hemisphere (north/south)
Exceptions
std::bad_allocif memory for the string can't be allocated.
Returns
UTM/UPS string representation: zone designator, easting, and northing.

Precision specifies accuracy of representation as follows:

  • prec = −5 (min), 100km
  • prec = −3, 1km
  • prec = 0, 1m
  • prec = 3, 1mm
  • prec = 6, 1μm
  • prec = 9 (max), 1nm

Definition at line 216 of file dotnet/NETGeographicLib/GeoCoords.cpp.

Member Data Documentation

◆ AltConvergence

property double NETGeographicLib::GeoCoords::AltConvergence { double get()
Returns
meridian convergence (degrees) for alternate zone.

Definition at line 308 of file GeoCoords.h.

◆ AltEasting

property double NETGeographicLib::GeoCoords::AltEasting { double get()
Returns
easting (meters) for alternate zone.

Definition at line 298 of file GeoCoords.h.

◆ AltNorthing

property double NETGeographicLib::GeoCoords::AltNorthing { double get()
Returns
northing (meters) for alternate zone.

Definition at line 303 of file GeoCoords.h.

◆ AltScale

property double NETGeographicLib::GeoCoords::AltScale { double get()
Returns
scale for alternate zone.

Definition at line 313 of file GeoCoords.h.

◆ AltZone

property int NETGeographicLib::GeoCoords::AltZone
Initial value:
{
int get()

Gets/Sets the current alternate zone (0 = UPS).

Exceptions
GeographicErrif zone cannot be used for this location.

See UTMUPS::zonespec for more information on the interpretation of zone. Note that zone == UTMUPS::STANDARD (the default) use the standard UPS or UTM zone, UTMUPS::MATCH does nothing retaining the existing alternate representation. Before this is called the alternate zone is the input zone.

Definition at line 289 of file GeoCoords.h.

◆ Convergence

property double NETGeographicLib::GeoCoords::Convergence { double get()
Returns
meridian convergence (degrees) for the UTM/UPS projection.

Definition at line 256 of file GeoCoords.h.

◆ Easting

property double NETGeographicLib::GeoCoords::Easting { double get()
Returns
easting (meters)

Definition at line 246 of file GeoCoords.h.

◆ Flattening

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

(The WGS84 value is returned because the UTM and UPS projections are based on this ellipsoid.)

Definition at line 473 of file GeoCoords.h.

◆ Hemisphere

property char NETGeographicLib::GeoCoords::Hemisphere { char get()
Returns
hemisphere letter N or S.

Definition at line 271 of file GeoCoords.h.

◆ Latitude

property double NETGeographicLib::GeoCoords::Latitude { double get()
Returns
latitude (degrees)

Definition at line 236 of file GeoCoords.h.

◆ Longitude

property double NETGeographicLib::GeoCoords::Longitude { double get()
Returns
longitude (degrees)

Definition at line 241 of file GeoCoords.h.

◆ m_pGeoCoords

GeographicLib::GeoCoords* NETGeographicLib::GeoCoords::m_pGeoCoords
private

Definition at line 59 of file GeoCoords.h.

◆ MajorRadius

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

(The WGS84 value is returned because the UTM and UPS projections are based on this ellipsoid.)

Definition at line 465 of file GeoCoords.h.

◆ Northing

property double NETGeographicLib::GeoCoords::Northing { double get()
Returns
northing (meters)

Definition at line 251 of file GeoCoords.h.

◆ Northp

property bool NETGeographicLib::GeoCoords::Northp { bool get()
Returns
hemisphere (false means south, true means north).

Definition at line 266 of file GeoCoords.h.

◆ Scale

property double NETGeographicLib::GeoCoords::Scale { double get()
Returns
scale for the UTM/UPS projection.

Definition at line 261 of file GeoCoords.h.

◆ Zone

property int NETGeographicLib::GeoCoords::Zone { int get()
Returns
the zone corresponding to the input (return 0 for UPS).

Definition at line 276 of file GeoCoords.h.


The documentation for this class was generated from the following files:
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
GeoCoords.hpp
Header for GeographicLib::GeoCoords class.
main
int main(int argc, char **argv)
Definition: cmake/example_cmake_find_gtsam/main.cpp:63
GeographicLib::GeoCoords
Conversion between geographic coordinates.
Definition: GeoCoords.hpp:49
std
Definition: BFloat16.h:88
args
Definition: pytypes.h:2210
lon
static const double lon
Definition: testGeographicLib.cpp:34
get
Container::iterator get(Container &c, Position position)
Definition: stdlist_overload.cpp:29
NETGeographicLib::GeoCoords::GeoCoords
GeoCoords()
Definition: dotnet/NETGeographicLib/GeoCoords.cpp:32
NETGeographicLib
Definition: Accumulator.h:13
lat
static const double lat
Definition: testGeographicLib.cpp:34


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