Package gov.nasa.worldwind.geom.coords
Class MGRSCoord
- java.lang.Object
-
- gov.nasa.worldwind.geom.coords.MGRSCoord
-
public class MGRSCoord extends java.lang.ObjectThis 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-longitudedoubleand the corresponding MGRS coordinate string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MGRSCoordfromLatLon(double latitude, double longitude)Create a WGS84 MGRS coordinate from a pair of latitude and longitudedoublewith the maximum precision of five digits (one meter).static MGRSCoordfromLatLon(double latitude, double longitude, int precision)Create a MGRS coordinate from a pair of latitude and longitudedoublewith the given precision or number of digits (1 to 5).static MGRSCoordfromString(java.lang.String MGRSString)Create a MGRS coordinate from a standard MGRS coordinate text string.doublegetLatitude()doublegetLongitude()java.lang.StringtoString()
-
-
-
Constructor Detail
-
MGRSCoord
public MGRSCoord(double latitude, double longitude, java.lang.String MGRSString)Create an arbitrary MGRS coordinate from a pair of latitude-longitudedoubleand the corresponding MGRS coordinate string.- Parameters:
latitude- the latitudedouble.longitude- the longitudedouble.MGRSString- the corresponding MGRS coordinate string.- Throws:
java.lang.IllegalArgumentException- iflatitudeorlongitudeis 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 longitudedoublewith the maximum precision of five digits (one meter).- Parameters:
latitude- the latitudedouble.longitude- the longitudedouble.- Returns:
- the corresponding
MGRSCoord. - Throws:
java.lang.IllegalArgumentException- iflatitudeorlongitudeis 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 longitudedoublewith 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- iflatitudeorlongitudeis 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 theMGRSStringis null or empty, theglobeis 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:
toStringin classjava.lang.Object
-
-