Class TLcdMGRSFormat
- All Implemented Interfaces:
ILcdFormatter
,ILcdParser
,Serializable
,Cloneable
String
into a point object.
When creating a new TLcdMGRSFormat
, an ellipsoid can be passed. The points
converted from and to a MGRS string are lon lat points defined in a reference using this
ellipsoid.
This class offers methods to format coordinates into either UTM MGRS, UPS MGRS, UTM
or UPS notation. The UTM MGRS and UTM notations are used for coordinates within the UTM
latitude bounds, see TLcdUTMGridSystem.NORTH_LAT_LIMIT
and
TLcdUTMGridSystem.SOUTH_LAT_LIMIT
. For points in the polar
regions, outside the UTM latitude bounds, the UPS MGRS and UPS notations are used.
- Since:
- 11.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The precision of the format.static enum
The format type.Nested classes/interfaces inherited from class java.text.Format
Format.Field
-
Constructor Summary
ConstructorDescriptionCreates a newTLcdMGRSFormat
that uses the WGS_84 ellipsoid for its calculations.TLcdMGRSFormat
(ILcdEllipsoid aEllipsoid) Creates a newTLcdMGRSFormat
that uses the given ellipsoid for its calculations.TLcdMGRSFormat
(String aFormat) Creates a newTLcdGARSFormat
that uses the WGS 84 ellipsoid and the given format to format anILcdPoint
. -
Method Summary
Modifier and TypeMethodDescriptionformat
(Object obj, StringBuffer toAppendTo, FieldPosition pos) char
Returns the character to separate the zone/grid letters and the coordinates.Returns the used format type.int
Deprecated.Returns the MGRS pattern used as described inTLcdMGRSFormat(String)
.Returns the precision used to format a MGRS or UTM/UPS String.char
Returns the character to separate the grid zone and the 100km squares when formatting MGRS strings.Parses a givenString
and creates a newObject
with the corresponding type/properties.parseObject
(String source, ParsePosition pos) void
setCoordinateSeparator
(char aCoordinateSeparator) Set the character to separate the zone/grid letters and the coordinates and between the coordinates.void
setFormatType
(TLcdMGRSFormat.FormatType aFormatType) Sets the used format type.void
setNumberOfDigits
(int aNumberOfDigits) Deprecated.void
setPrecision
(TLcdMGRSFormat.FormatPrecision aPrecision) Sets the precision used to format a MGRS or UPS String.void
setZoneSeparator
(char aZoneSeparator) Sets the character to use as separator between the grid zone and the 100km squares when formatting MGRS strings.Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.util.ILcdFormatter
format
-
Constructor Details
-
TLcdMGRSFormat
public TLcdMGRSFormat()Creates a newTLcdMGRSFormat
that uses the WGS_84 ellipsoid for its calculations. -
TLcdMGRSFormat
Creates a newTLcdGARSFormat
that uses the WGS 84 ellipsoid and the given format to format anILcdPoint
.The format should be expressed in the following EBNF notation (expressions enclosed in
[]
brackets are optional, expressions enclosed in{}
brackets may be omitted or repeated):<pattern> ::= <gridZone>, [[<zoneSeparator>] <100kmSquare>], [[<coordinateSeparator>] <easting>], [[<coordinateSeparator>] <northing>] <gridZone> ::= "G" <100kmSquare> ::= "S" <easting> ::= "E" | "E", <precision> <northing> ::= "N" | "N", <precision> <precision> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" <zoneSeparator> ::= { ? any character ? } <coordinateSeparator> ::= { ? any character ? }
For example:"17TPJ 30084 33438"
has format "GS E5 N5""Z"
has format "G"
- Parameters:
aFormat
- a format string, nevernull
- Throws:
NullPointerException
- ifaFormat
is null.- Since:
- 2021.1
-
TLcdMGRSFormat
Creates a newTLcdMGRSFormat
that uses the given ellipsoid for its calculations.- Parameters:
aEllipsoid
- a given ellipsoid.
-
-
Method Details
-
getPattern
Returns the MGRS pattern used as described inTLcdMGRSFormat(String)
.- Returns:
- the current MGRS pattern in EBNF format
- Since:
- 2021.1
-
getFormatType
Returns the used format type.- Returns:
- the used format type.
-
setFormatType
Sets the used format type.- Parameters:
aFormatType
- the format type.
-
getCoordinateSeparator
public char getCoordinateSeparator()Returns the character to separate the zone/grid letters and the coordinates.- Returns:
- the character to separate the zone/grid letters and the coordinates.
- See Also:
-
setCoordinateSeparator
public void setCoordinateSeparator(char aCoordinateSeparator) Set the character to separate the zone/grid letters and the coordinates and between the coordinates. Set the value 0 (not the character '0') to have no spaces between the zone and the coordinates.- Parameters:
aCoordinateSeparator
- the character to separate the zone/grid letters and the coordinates and between the coordinates.- See Also:
-
getZoneSeparator
public char getZoneSeparator()Returns the character to separate the grid zone and the 100km squares when formatting MGRS strings.- Returns:
- the character to separate the grid zone and the 100km squares when formatting MGRS strings.
- See Also:
-
setZoneSeparator
public void setZoneSeparator(char aZoneSeparator) Sets the character to use as separator between the grid zone and the 100km squares when formatting MGRS strings. Set the value to
0
(not the character'0'
) to have no separator between the grid zone and the 100km squares.The default is
0
.- Parameters:
aZoneSeparator
- the character to separate the grid zone and the 100km squares.- See Also:
-
getNumberOfDigits
Deprecated.UsegetPrecision()
Returns the number of digits used to format a MGRS or UTM/UPS String.- Returns:
- the number of digits used to format a MGRS String.
-
setNumberOfDigits
Deprecated.Sets the number of digits used to format a MGRS or UPS String. When formatting points as MGRS Strings, the number of digits used by default is5
. When the number of digits used is 5, the MGRS String has a precision of 1m. When the number of digits used is 4, the precision is 10m, etc...When formatting points as UTM/UPS Strings, the number of digits used by default is
7
. When the number of digits used is 7, the MGRS String has a precision of 1m. When the number of digits used is 6, the precision is 10m, etc...- Parameters:
aNumberOfDigits
- the number of digits used to format a MGRS or UPS/UTM String.
-
getPrecision
Returns the precision used to format a MGRS or UTM/UPS String.- Returns:
- the precision used to format a MGRS String.
-
setPrecision
Sets the precision used to format a MGRS or UPS String. By default a precision of 1 meter is used. Precision of 1000KM and Zone precision can only be used to format UTM/UPS coordinates.- Parameters:
aPrecision
- the precision used to format a MGRS or UPS/UTM String.- Throws:
IllegalArgumentException
- If the format type is MGRS and the format precision is of 1000KM or zone precision.
-
format
-
parseObject
The parsed Object is an
ILcdPoint
.- Specified by:
parseObject
in classFormat
- Returns:
- An
ILcdPoint
parsed from the string. In case of error, returns null.
-
parse
Description copied from interface:ILcdParser
Parses a givenString
and creates a newObject
with the corresponding type/properties.- Specified by:
parse
in interfaceILcdParser
- Parameters:
aString
- theString
to be parsed.- Returns:
- the resulting new
Object
. - Throws:
IllegalArgumentException
- if theString
can't be parsed.
-
getPrecision()