Class TLcdCGRSFormat
- All Implemented Interfaces:
ILcdFormatter,ILcdParser,Serializable,Cloneable
The formatting and parsing of CGRS coordinate strings can be customized using a CGRS format String.
An example of a CGRS coordinate string is 25AC5NE. This string consists of
25: A number identifying the northing component of a 30 minutes square.AC: Letters identifying the easting component of a 30 minutes square.5: One cipher identifying a 10 minute square within this 30 minutes square.NE: Two letters identifying a 5 minute square within this 10 minutes square.
- Since:
- 2021.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.Format
Format.Field -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTLcdCGRSFormat(ILcdBounds aGridBounds, String aCGRSFormat) Creates a newTLcdCGRSFormatthat uses the given grid bounds for its calculations and that uses the given CGRS format to format or parse anILcdPoint. -
Method Summary
Modifier and TypeMethodDescriptionformat(Object aObject, StringBuffer aToAppendTo, FieldPosition aPosition) parseObject(String aString, ParsePosition aPosition) Parses text from a CGRS coordinate string to produce anILcdPointwith longitude latitude coordinates in the same geodetic reference as the grid bounds that were used to construct thisTLcdCGRSFormat.Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObjectMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.util.ILcdFormatter
format
-
Field Details
-
DEFAULT_CGRS_FORMAT_CELL
A default CGRS format which describes a cell- See Also:
-
DEFAULT_CGRS_FORMAT_KEYPAD
A default CGRS format which describes a cell and keypad- See Also:
-
DEFAULT_CGRS_FORMAT_QUADRANT
A default CGRS format which describes a cell, keypad and quadrant- See Also:
-
-
Constructor Details
-
TLcdCGRSFormat
Creates a newTLcdCGRSFormatthat uses the given grid bounds for its calculations and that uses the given CGRS format to format or parse anILcdPoint.The format should be expressed in EBNF notation (expressions enclosed in
[]brackets are optional, expressions enclosed in{}brackets may be omitted or repeated):<pattern> ::= <cellY> {<separator>} <cellX> [{<separator>} <keypad>] [{<separator>} <quadrant>] <cellY> ::= "Y" | "Y", <cellMinimumCharacterLength> <cellX> ::= "X" | "X", <cellMinimumCharacterLength> <keypad> ::= "K" <quadrant> ::= "Q" <cellMinimumCharacterLength> ::= "1" | "2" | "3" <separator> ::= { ? any character ? }When the minimum character length is higher than the amount of actual characters, it will be padded with default characters. For X it will be padded with " " (space), for Y it will be padded with "0" (zero). When the minimum character length is lower than or equal to the amount of characters, the minimum character length has no effect. For example:- "340X5NW" has format "YXKQ"
- "182_ QW_NE_3" has format "Y3_X3_Q_K"
- Parameters:
aGridBounds- given bounds expressed in the WGS84 reference. The values are rounded to the nearest multiple of 30 minutes. This parameter should never benull.aCGRSFormat- given CGRS format, nevernull- Throws:
NullPointerException- ifaGridBoundsoraCGRSFormatis null.
-
-
Method Details
-
format
-
parseObject
Parses text from a CGRS coordinate string to produce anILcdPointwith longitude latitude coordinates in the same geodetic reference as the grid bounds that were used to construct thisTLcdCGRSFormat.The method attempts to parse a string representing a CGRS coordinate, starting at the index given by
aPosition. Parsing does not necessarily use all characters up to the end of the string. If parsing succeeds, the index ofaPositionis updated to the index after the last character used, and the parsed object is returned. The updatedaPositioncan be used to indicate the starting point for the next call to this method. If an error occurs, the index ofaPositionis not changed. The error index ofaPositionis set to the index of the character where the error occurred, andOptional.empty()is returned.- Specified by:
parseObjectin classFormat- Parameters:
aString- AStringrepresenting a CGRS coordinate, part of which should be parsed, nevernull.aPosition- AParsePositionobject with index and error index information as described above, nevernull.- Returns:
- An
Optionalcontaining anILcdPointparsed from the string. In case of error, returnsOptional.empty(). - Throws:
NullPointerException- ifaSourceoraPositionis null.- See Also:
-
parse
Parses a givenStringand creates a newILcdPointwith longitude latitude coordinates in the same geodetic reference as the grid bounds that were used to construct thisTLcdCGRSFormat.- Specified by:
parsein interfaceILcdParser- Parameters:
aString- theStringrepresenting a CGRS coordinate to be parsed, nevernull.- Returns:
- an
ILcdPoint - Throws:
NullPointerException- ifaStringis null.IllegalArgumentException- if theStringcan't be parsed.
-