NASA World Wind

gov.nasa.worldwind.geom.coords
Class MGRSCoord

java.lang.Object
  extended by gov.nasa.worldwind.geom.coords.MGRSCoord

public class MGRSCoord
extends java.lang.Object

This class holds an immutable MGRS coordinate string along with the corresponding latitude and longitude.


Constructor Summary
MGRSCoord(Angle latitude, Angle longitude, java.lang.String MGRSString)
          Create an arbitrary MGRS coordinate from a pair of latitude-longitude Angle and the corresponding MGRS coordinate string.
 
Method Summary
static MGRSCoord fromLatLon(Angle latitude, Angle longitude)
          Create a WGS84 MGRS coordinate from a pair of latitude and longitude Angle with the maximum precision of five digits (one meter).
static MGRSCoord fromLatLon(Angle latitude, Angle longitude, Globe globe)
          Create a MGRS coordinate from a pair of latitude and longitude Angle with the maximum precision of five digits (one meter).
static MGRSCoord fromLatLon(Angle latitude, Angle longitude, Globe globe, int precision)
          Create a MGRS coordinate from a pair of latitude and longitude Angle with the given precision or number of digits (1 to 5).
static MGRSCoord fromLatLon(Angle latitude, Angle longitude, int precision)
          Create a WGS84 MGRS coordinate from a pair of latitude and longitude Angle with the given precision or number of digits.
static MGRSCoord fromString(java.lang.String MGRSString, Globe globe)
          Create a MGRS coordinate from a standard MGRS coordinate text string.
 Angle getLatitude()
           
 Angle getLongitude()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MGRSCoord

public MGRSCoord(Angle latitude,
                 Angle longitude,
                 java.lang.String MGRSString)
Create an arbitrary MGRS coordinate from a pair of latitude-longitude Angle and the corresponding MGRS coordinate string.

Parameters:
latitude - the latitude Angle.
longitude - the longitude Angle.
MGRSString - the corresponding MGRS coordinate string.
Throws:
java.lang.IllegalArgumentException - if latitude or longitude is null, or the MGRSString is null or empty.
Method Detail

fromLatLon

public static MGRSCoord fromLatLon(Angle latitude,
                                   Angle longitude)
Create a WGS84 MGRS coordinate from a pair of latitude and longitude Angle with the maximum precision of five digits (one meter).

Parameters:
latitude - the latitude Angle.
longitude - the longitude Angle.
Returns:
the corresponding MGRSCoord.
Throws:
java.lang.IllegalArgumentException - if latitude or longitude is null, or the conversion to MGRS coordinates fails.

fromLatLon

public static MGRSCoord fromLatLon(Angle latitude,
                                   Angle longitude,
                                   Globe globe)
Create a MGRS coordinate from a pair of latitude and longitude Angle with the maximum precision of five digits (one meter).

Parameters:
latitude - the latitude Angle.
longitude - the longitude Angle.
globe - the Globe.
Returns:
the corresponding MGRSCoord.
Throws:
java.lang.IllegalArgumentException - if latitude or longitude is null, the globe is null, or the conversion to MGRS coordinates fails.

fromLatLon

public static MGRSCoord fromLatLon(Angle latitude,
                                   Angle longitude,
                                   Globe globe,
                                   int precision)
Create a MGRS coordinate from a pair of latitude and longitude Angle with the given precision or number of digits (1 to 5).

Parameters:
latitude - the latitude Angle.
longitude - the longitude Angle.
globe - the Globe - can be null (will use WGS84).
precision - the number of digits used for easting and northing (1 to 5).
Returns:
the corresponding MGRSCoord.
Throws:
java.lang.IllegalArgumentException - if latitude or longitude is null, or the conversion to MGRS coordinates fails.

fromLatLon

public static MGRSCoord fromLatLon(Angle latitude,
                                   Angle longitude,
                                   int precision)
Create a WGS84 MGRS coordinate from a pair of latitude and longitude Angle with the given precision or number of digits.

Parameters:
latitude - the latitude Angle.
longitude - the longitude Angle.
precision - the number of digits used for easting and northing (1 to 5).
Returns:
the corresponding MGRSCoord.
Throws:
java.lang.IllegalArgumentException - if latitude or longitude is null, or the conversion to MGRS coordinates fails.

fromString

public static MGRSCoord fromString(java.lang.String MGRSString,
                                   Globe globe)
Create a MGRS coordinate from a standard MGRS coordinate text string.

The string will be converted to uppercase and stripped of all spaces before being evaluated.

Valid examples:
32TLP5626635418
32 T LP 56266 35418
11S KU 528 111

Parameters:
MGRSString - the MGRS coordinate text string.
globe - the Globe - can be null (will use WGS84).
Returns:
the corresponding MGRSCoord.
Throws:
java.lang.IllegalArgumentException - if the MGRSString is null or empty, the globe is null, or the conversion to geodetic coordinates fails (invalid coordinate string).

getLatitude

public Angle getLatitude()

getLongitude

public Angle getLongitude()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

NASA World Wind