Package mil.nga.mgrs
Class MGRS
- java.lang.Object
-
- mil.nga.mgrs.MGRS
-
public class MGRS extends Object
Military Grid Reference System Coordinate- Author:
- wnewman, osbornb
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intaccuracy()Get the MGRS coordinate accuracy number of digitsstatic intaccuracy(String mgrs)Get the MGRS coordinate accuracy number of digitsStringcoordinate()Get the MGRS coordinate with one meter precisionStringcoordinate(int accuracy)Get the MGRS coordinate with the accuracy number of digits in the easting and northing values.Stringcoordinate(GridType type)Get the MGRS coordinate with specified grid precisionstatic MGRScreate(int zone, char band, char column, char row, long easting, long northing)Createstatic MGRScreate(int zone, char band, long easting, long northing)Createstatic MGRSfrom(double longitude, double latitude)Convert the coordinate to MGRSstatic MGRSfrom(Point point)Encodes a point as a MGRS stringchargetBand()Get the band letterchargetColumn()Get the column letterstatic chargetColumnLetter(int zoneNumber, double easting)Get the column letter from the zone number and eastingstatic chargetColumnLetter(UTM utm)Get the column letter from the UTMStringgetColumnRowId()Get the two letter column and row 100k designatorstatic StringgetColumnRowId(double easting, double northing, int zoneNumber)Get the two letter column and row 100k designator for a given UTM easting, northing and zone number valuelonggetEasting()Get the eastingStringgetEastingAndNorthing(GridType type)Get the easting and northing concatenated value in the grid type precisionGridZonegetGridZone()Get the GZD grid zoneHemispheregetHemisphere()Get the hemispherelonggetNorthing()Get the northingchargetRow()Get the row letterstatic chargetRowLetter(int zoneNumber, double northing)Get the row letter from the zone number and northingstatic chargetRowLetter(UTM utm)Get the row letter from the UTMdoublegetUTMEasting()Get the UTM eastingdoublegetUTMNorthing()Get the UTM northingintgetZone()Get the zone numberstatic booleanisMGRS(String mgrs)Return whether the given string is valid MGRS stringstatic MGRSparse(String mgrs)Parse a MGRS stringGridTypeprecision()Get the MGRS coordinate grid precisionstatic GridTypeprecision(String mgrs)Parse the MGRS string for the precisionPointtoPoint()Convert to a pointStringtoString()UTMtoUTM()Convert to UTM coordinate
-
-
-
Constructor Detail
-
MGRS
public MGRS(int zone, char band, char column, char row, long easting, long northing)Constructor- Parameters:
zone- zone numberband- band lettercolumn- column letterrow- row lettereasting- eastingnorthing- northing
-
MGRS
public MGRS(int zone, char band, long easting, long northing)Constructor- Parameters:
zone- zone numberband- band lettereasting- eastingnorthing- northing
-
-
Method Detail
-
create
public static MGRS create(int zone, char band, char column, char row, long easting, long northing)
Create- Parameters:
zone- zone numberband- band lettercolumn- column letterrow- row lettereasting- eastingnorthing- northing- Returns:
- MGRS
-
create
public static MGRS create(int zone, char band, long easting, long northing)
Create- Parameters:
zone- zone numberband- band lettereasting- eastingnorthing- northing- Returns:
- MGRS
-
getZone
public int getZone()
Get the zone number- Returns:
- zone number
-
getBand
public char getBand()
Get the band letter- Returns:
- band letter
-
getColumn
public char getColumn()
Get the column letter- Returns:
- column letter
-
getRow
public char getRow()
Get the row letter- Returns:
- row letter
-
getEasting
public long getEasting()
Get the easting- Returns:
- easting
-
getNorthing
public long getNorthing()
Get the northing- Returns:
- northing
-
getHemisphere
public Hemisphere getHemisphere()
Get the hemisphere- Returns:
- hemisphere
-
coordinate
public String coordinate()
Get the MGRS coordinate with one meter precision- Returns:
- MGRS coordinate
-
coordinate
public String coordinate(GridType type)
Get the MGRS coordinate with specified grid precision- Parameters:
type- grid type precision- Returns:
- MGRS coordinate
-
getEastingAndNorthing
public String getEastingAndNorthing(GridType type)
Get the easting and northing concatenated value in the grid type precision- Parameters:
type- grid type precision- Returns:
- easting and northing value
-
coordinate
public String coordinate(int accuracy)
Get the MGRS coordinate with the accuracy number of digits in the easting and northing values. Accuracy must be inclusively between 0 (GridType.HUNDRED_KILOMETER) and 5 (GridType.METER).- Parameters:
accuracy- accuracy digits between 0 (inclusive) and 5 (inclusive)- Returns:
- MGRS coordinate
-
precision
public GridType precision()
Get the MGRS coordinate grid precision- Returns:
- grid type precision
-
accuracy
public int accuracy()
Get the MGRS coordinate accuracy number of digits- Returns:
- accuracy digits
-
getColumnRowId
public String getColumnRowId()
Get the two letter column and row 100k designator- Returns:
- the two letter column and row 100k designator
-
getGridZone
public GridZone getGridZone()
Get the GZD grid zone- Returns:
- GZD grid zone
-
toPoint
public Point toPoint()
Convert to a point- Returns:
- point
-
toUTM
public UTM toUTM()
Convert to UTM coordinate- Returns:
- UTM
-
getUTMEasting
public double getUTMEasting()
Get the UTM easting- Returns:
- UTM easting
-
getUTMNorthing
public double getUTMNorthing()
Get the UTM northing- Returns:
- UTM northing
-
isMGRS
public static boolean isMGRS(String mgrs)
Return whether the given string is valid MGRS string- Parameters:
mgrs- potential MGRS string- Returns:
- true if MGRS string is valid, false otherwise
-
from
public static MGRS from(Point point)
Encodes a point as a MGRS string- Parameters:
point- point- Returns:
- MGRS
-
from
public static MGRS from(double longitude, double latitude)
Convert the coordinate to MGRS- Parameters:
longitude- longitudelatitude- latitude- Returns:
- MGRS
- Since:
- 2.1.1
-
parse
public static MGRS parse(String mgrs) throws ParseException
Parse a MGRS string- Parameters:
mgrs- MGRS string- Returns:
- MGRS
- Throws:
ParseException- upon failure to parse the MGRS string
-
precision
public static GridType precision(String mgrs) throws ParseException
Parse the MGRS string for the precision- Parameters:
mgrs- MGRS string- Returns:
- grid type precision
- Throws:
ParseException- upon failure to parse the MGRS string
-
accuracy
public static int accuracy(String mgrs) throws ParseException
Get the MGRS coordinate accuracy number of digits- Parameters:
mgrs- MGRS string- Returns:
- accuracy digits
- Throws:
ParseException- upon failure to parse the MGRS string
-
getColumnRowId
public static String getColumnRowId(double easting, double northing, int zoneNumber)
Get the two letter column and row 100k designator for a given UTM easting, northing and zone number value- Parameters:
easting- eastingnorthing- northingzoneNumber- zone number- Returns:
- the two letter column and row 100k designator
-
getColumnLetter
public static char getColumnLetter(UTM utm)
Get the column letter from the UTM- Parameters:
utm- UTM- Returns:
- column letter
-
getColumnLetter
public static char getColumnLetter(int zoneNumber, double easting)Get the column letter from the zone number and easting- Parameters:
zoneNumber- zone numbereasting- easting- Returns:
- column letter
-
getRowLetter
public static char getRowLetter(UTM utm)
Get the row letter from the UTM- Parameters:
utm- UTM- Returns:
- row letter
-
getRowLetter
public static char getRowLetter(int zoneNumber, double northing)Get the row letter from the zone number and northing- Parameters:
zoneNumber- zone numbernorthing- northing- Returns:
- row letter
-
-