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.
-
-
Constructor Summary
Constructors Constructor Description MGRSCoord(double latitude, double longitude, java.lang.String MGRSString)
Create an arbitrary MGRS coordinate from a pair of latitude-longitudedouble
and the corresponding MGRS coordinate string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MGRSCoord
fromLatLon(double latitude, double longitude)
Create a WGS84 MGRS coordinate from a pair of latitude and longitudedouble
with the maximum precision of five digits (one meter).static MGRSCoord
fromLatLon(double latitude, double longitude, int precision)
Create a MGRS coordinate from a pair of latitude and longitudedouble
with the given precision or number of digits (1 to 5).static MGRSCoord
fromString(java.lang.String MGRSString)
Create a MGRS coordinate from a standard MGRS coordinate text string.double
getLatitude()
double
getLongitude()
java.lang.String
toString()
-
-
-
Constructor Detail
-
MGRSCoord
public MGRSCoord(double latitude, double longitude, java.lang.String MGRSString)
Create an arbitrary MGRS coordinate from a pair of latitude-longitudedouble
and the corresponding MGRS coordinate string.- Parameters:
latitude
- the latitudedouble
.longitude
- the longitudedouble
.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(double latitude, double longitude)
Create a WGS84 MGRS coordinate from a pair of latitude and longitudedouble
with the maximum precision of five digits (one meter).- Parameters:
latitude
- the latitudedouble
.longitude
- the longitudedouble
.- Returns:
- the corresponding
MGRSCoord
. - Throws:
java.lang.IllegalArgumentException
- iflatitude
orlongitude
is null, or the conversion to MGRS coordinates fails.
-
fromLatLon
public static MGRSCoord fromLatLon(double latitude, double longitude, int precision)
Create a MGRS coordinate from a pair of latitude and longitudedouble
with the given precision or number of digits (1 to 5).- Parameters:
latitude
- the latitudedouble
.longitude
- the longitudedouble
.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)
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.- 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 double getLatitude()
-
getLongitude
public double getLongitude()
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-