|
|
| 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) |
|
|
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) |
|
.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
- latitude and longitude
- UTM or UPS coordinates
- a string representation of these or an MGRS coordinate string
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 {
double lat = 33.3, lon = 44.4;
c.
Reset(
"18TWN0050",
true,
false);
Console.WriteLine(String.Format(
"Latitude: {0} Longitude: {1}", c.
Latitude, c.
Longitude));
c.
Reset(
"1d38'W 55d30'N",
true,
false);
}
Console.WriteLine(String.Format("Caught exception: {0}", e.Message));
}
}
}
}
.NET wrapper for GeographicLib::GeoCoords.
System::String ^ GeoRepresentation(int prec, bool longfirst)
System::String ^ MGRSRepresentation(int prec)
void Reset(System::String^ s, bool centerp, bool longfirst)
System::String ^ DMSRepresentation(int prec, bool longfirst, char dmssep)
Exception class for NETGeographicLib.
Managed C++ Example:
using namespace System;
int main(array<System::String ^> ^)
{
try {
double lat = 33.3, lon = 44.4;
c->
Reset(
"18TWN0050",
true,
false);
Console::WriteLine(String::Format(
"Latitude: {0} Longitude: {1}", c->
Latitude, c->
Longitude));
c->
Reset(
"1d38'W 55d30'N",
true,
false);
}
Console::WriteLine(String::Format("Caught exception: {0}", e->Message));
return -1;
}
return 0;
}
int main(int argc, const char *const argv[])
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: EquatorialRadius, Flattening, Latitude, Longitude, Easting, Northing, Convergence, Scale, Northp, Hemisphere, Zone, AltZone, AltEasting, AltNorthing, AltConvergence, and AltScale.
Definition at line 55 of file GeoCoords.h.
NETGeographicLib::GeoCoords::GeoCoords |
( |
System::String^ |
s, |
|
|
bool |
centerp, |
|
|
bool |
longfirst |
|
) |
| |
Construct from a string.
- Parameters
-
[in] | s | 1-element, 2-element, or 3-element string representation of the position. |
[in] | centerp | governs the interpretation of MGRS coordinates (see below). |
[in] | longfirst | governs the interpretation of geographic coordinates (see below). |
- Exceptions
-
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
- MGRS
- "Lat Long" or "Long Lat"
- "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