public class TLcdMGRSFormat extends Format implements ILcdFormatter, ILcdParser
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.
TLcdUtmMgrsUtil
,
TLcdUpsMgrsUtil
,
TLcdUTMUtil
,
TLcdUPSUtil
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
TLcdMGRSFormat.FormatPrecision
The precision of the format.
|
static class |
TLcdMGRSFormat.FormatType
The format type.
|
Format.Field
Constructor and Description |
---|
TLcdMGRSFormat()
Creates a new
TLcdMGRSFormat that uses the WGS_84 ellipsoid for its calculations. |
TLcdMGRSFormat(ILcdEllipsoid aEllipsoid)
Creates a new
TLcdMGRSFormat that uses the given ellipsoid for its calculations. |
TLcdMGRSFormat(String aFormat)
Creates a new
TLcdGARSFormat that uses the WGS 84 ellipsoid and the given format to format an ILcdPoint . |
Modifier and Type | Method and Description |
---|---|
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos) |
char |
getCoordinateSeparator()
Returns the character to separate the zone/grid letters and the coordinates.
|
TLcdMGRSFormat.FormatType |
getFormatType()
Returns the used format type.
|
int |
getNumberOfDigits()
Deprecated.
Use
getPrecision() |
String |
getPattern()
Returns the MGRS pattern used as described in
TLcdMGRSFormat(String) . |
TLcdMGRSFormat.FormatPrecision |
getPrecision()
Returns the precision used to format a MGRS or UTM/UPS String.
|
char |
getZoneSeparator()
Returns the character to separate the grid zone and the 100km squares when formatting MGRS strings.
|
Object |
parse(String aString)
Parses a given
String and creates a new Object
with the corresponding type/properties. |
Object |
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.
|
clone, format, formatToCharacterIterator, parseObject
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
format
public TLcdMGRSFormat()
TLcdMGRSFormat
that uses the WGS_84 ellipsoid for its calculations.public TLcdMGRSFormat(String aFormat)
TLcdGARSFormat
that uses the WGS 84 ellipsoid and the given format to format an ILcdPoint
.
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"aFormat
- a format string, never null
NullPointerException
- if aFormat
is null.public TLcdMGRSFormat(ILcdEllipsoid aEllipsoid)
TLcdMGRSFormat
that uses the given ellipsoid for its calculations.aEllipsoid
- a given ellipsoid.public String getPattern()
TLcdMGRSFormat(String)
.public TLcdMGRSFormat.FormatType getFormatType()
public void setFormatType(TLcdMGRSFormat.FormatType aFormatType)
aFormatType
- the format type.public char getCoordinateSeparator()
setCoordinateSeparator(char)
public void setCoordinateSeparator(char aCoordinateSeparator)
aCoordinateSeparator
- the character to separate the zone/grid letters and the coordinates and between the coordinates.getCoordinateSeparator()
public char getZoneSeparator()
setZoneSeparator(char)
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
.
aZoneSeparator
- the character to separate the grid zone and the 100km squares.getZoneSeparator()
@Deprecated public int getNumberOfDigits()
getPrecision()
@Deprecated public void setNumberOfDigits(int aNumberOfDigits)
setPrecision(TLcdMGRSFormat.FormatPrecision)
5
.
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...
aNumberOfDigits
- the number of digits used to format a MGRS or UPS/UTM String.public TLcdMGRSFormat.FormatPrecision getPrecision()
public void setPrecision(TLcdMGRSFormat.FormatPrecision aPrecision) throws IllegalArgumentException
aPrecision
- the precision used to format a MGRS or UPS/UTM String.IllegalArgumentException
- If the format type is MGRS and the format precision is
of 1000KM or zone precision.public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos)
public Object parseObject(String source, ParsePosition pos)
The parsed Object is an ILcdPoint
.
parseObject
in class Format
ILcdPoint
parsed from the string. In case of error, returns null.public Object parse(String aString) throws IllegalArgumentException
ILcdParser
String
and creates a new Object
with the corresponding type/properties.parse
in interface ILcdParser
aString
- the String
to be parsed.Object
.IllegalArgumentException
- if the String
can't be parsed.