Package gov.nasa.worldwind.geom.coords
Class MGRSCoord
- java.lang.Object
-
- 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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MGRSCoord
fromLatLon(Angle latitude, Angle longitude)
Create a WGS84 MGRS coordinate from a pair of latitude and longitudeAngle
with the maximum precision of five digits (one meter).static MGRSCoord
fromLatLon(Angle latitude, Angle longitude, int precision)
Create a WGS84 MGRS coordinate from a pair of latitude and longitudeAngle
with the given precision or number of digits.static MGRSCoord
fromLatLon(Angle latitude, Angle longitude, Globe globe)
Create a MGRS coordinate from a pair of latitude and longitudeAngle
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 longitudeAngle
with the given precision or number of digits (1 to 5).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()
-
-
-
Constructor Detail
-
MGRSCoord
public MGRSCoord(Angle latitude, Angle longitude, java.lang.String MGRSString)
Create an arbitrary MGRS coordinate from a pair of latitude-longitudeAngle
and the corresponding MGRS coordinate string.- Parameters:
latitude
- the latitudeAngle
.longitude
- the longitudeAngle
.MGRSString
- the corresponding MGRS coordinate string.- Throws:
java.lang.IllegalArgumentException
- iflatitude
orlongitude
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 longitudeAngle
with the maximum precision of five digits (one meter).- Parameters:
latitude
- the latitudeAngle
.longitude
- the longitudeAngle
.- Returns:
- the corresponding
MGRSCoord
. - Throws:
java.lang.IllegalArgumentException
- iflatitude
orlongitude
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 longitudeAngle
with the given precision or number of digits.- Parameters:
latitude
- the latitudeAngle
.longitude
- the longitudeAngle
.precision
- the number of digits used for easting and northing (1 to 5).- Returns:
- the corresponding
MGRSCoord
. - Throws:
java.lang.IllegalArgumentException
- iflatitude
orlongitude
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 longitudeAngle
with the maximum precision of five digits (one meter).- Parameters:
latitude
- the latitudeAngle
.longitude
- the longitudeAngle
.globe
- theGlobe
.- Returns:
- the corresponding
MGRSCoord
. - Throws:
java.lang.IllegalArgumentException
- iflatitude
orlongitude
is null, theglobe
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 longitudeAngle
with the given precision or number of digits (1 to 5).- Parameters:
latitude
- the latitudeAngle
.longitude
- the longitudeAngle
.globe
- theGlobe
- 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
- iflatitude
orlongitude
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
- theGlobe
- can be null (will use WGS84).- Returns:
- the corresponding
MGRSCoord
. - Throws:
java.lang.IllegalArgumentException
- if theMGRSString
is null or empty, theglobe
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 classjava.lang.Object
-
-