Package mil.nga.gars
Class GARS
- java.lang.Object
-
- mil.nga.gars.GARS
-
public class GARS extends Object
Global Area Reference System Coordinate- Author:
- osbornb
-
-
Constructor Summary
Constructors Constructor Description GARS(int longitude, String latitude)
Constructor, default southwest corner quadrant (GARSConstants.DEFAULT_QUADRANT
) and keypad (GARSConstants.DEFAULT_KEYPAD
)GARS(int longitude, String latitude, int quadrant, int keypad)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
coordinate()
Get the GARS coordinate with five minute precisionString
coordinate(GridType type)
Get the GARS coordinate with specified grid precisionstatic GARS
create(int longitude, String latitude)
Create, default southwest corner quadrant (GARSConstants.DEFAULT_QUADRANT
) and keypad (GARSConstants.DEFAULT_KEYPAD
)static GARS
create(int longitude, String latitude, int quadrant, int keypad)
Createboolean
equals(Object obj)
static GARS
from(double longitude, double latitude)
Convert the coordinate to GARSstatic GARS
from(Point point)
Encodes a point as a GARS stringint
getKeypad()
Get the 5 minute keypadString
getLatitude()
Get the latitudinal band lettersint
getLongitude()
Get the longitudinal band numberint
getQuadrant()
Get the 15 minute quadrantint
hashCode()
static boolean
isGARS(String gars)
Return whether the given string is valid GARS stringstatic GARS
parse(String gars)
Parse a GARS stringstatic GridType
precision(String gars)
Parse the GARS string for the precisionPoint
toPoint()
Convert to a pointString
toString()
-
-
-
Constructor Detail
-
GARS
public GARS(int longitude, String latitude)
Constructor, default southwest corner quadrant (GARSConstants.DEFAULT_QUADRANT
) and keypad (GARSConstants.DEFAULT_KEYPAD
)- Parameters:
longitude
- longitudinal band numberlatitude
- latitudinal band letters
-
GARS
public GARS(int longitude, String latitude, int quadrant, int keypad)
Constructor- Parameters:
longitude
- longitudinal band numberlatitude
- latitudinal band lettersquadrant
- 15 minute quadrantkeypad
- 5 minute keypad
-
-
Method Detail
-
create
public static GARS create(int longitude, String latitude)
Create, default southwest corner quadrant (GARSConstants.DEFAULT_QUADRANT
) and keypad (GARSConstants.DEFAULT_KEYPAD
)- Parameters:
longitude
- longitudinal band numberlatitude
- latitudinal band letters- Returns:
- GARS
-
create
public static GARS create(int longitude, String latitude, int quadrant, int keypad)
Create- Parameters:
longitude
- longitudinal band numberlatitude
- latitudinal band lettersquadrant
- 15 minute quadrantkeypad
- 5 minute keypad- Returns:
- GARS
-
getLongitude
public int getLongitude()
Get the longitudinal band number- Returns:
- longitude band number
-
getLatitude
public String getLatitude()
Get the latitudinal band letters- Returns:
- latitude band letters
-
getQuadrant
public int getQuadrant()
Get the 15 minute quadrant- Returns:
- quadrant
-
getKeypad
public int getKeypad()
Get the 5 minute keypad- Returns:
- keypad
-
coordinate
public String coordinate()
Get the GARS coordinate with five minute precision- Returns:
- GARS coordinate
-
coordinate
public String coordinate(GridType type)
Get the GARS coordinate with specified grid precision- Parameters:
type
- grid type precision- Returns:
- GARS coordinate
-
toPoint
public Point toPoint()
Convert to a point- Returns:
- point
-
isGARS
public static boolean isGARS(String gars)
Return whether the given string is valid GARS string- Parameters:
gars
- potential GARS string- Returns:
- true if GARS string is valid, false otherwise
-
from
public static GARS from(Point point)
Encodes a point as a GARS string- Parameters:
point
- point- Returns:
- GARS
-
from
public static GARS from(double longitude, double latitude)
Convert the coordinate to GARS- Parameters:
longitude
- longitudelatitude
- latitude- Returns:
- GARS
-
parse
public static GARS parse(String gars) throws ParseException
Parse a GARS string- Parameters:
gars
- GARS string- Returns:
- GARS
- Throws:
ParseException
- upon failure to parse the GARS string
-
precision
public static GridType precision(String gars) throws ParseException
Parse the GARS string for the precision- Parameters:
gars
- GARS string- Returns:
- grid type precision
- Throws:
ParseException
- upon failure to parse the GARS string
-
-