Class TLcdGeorefFormat
- All Implemented Interfaces:
ILcdFormatter
,ILcdParser
,Serializable
,Cloneable
A class representing a format for Georef points. It has the capability to format lon lat
points as a String
. It can also parse a Georef String
representation back
into a lon lat point object.
Georef formatting is based on the longitude and latitude values of a point. An example of a georef String is
NKEF2250
. This String consists of
NK
: 2 letters identifying a 15 degrees square.EF
: 2 letters identifying a 1 degree square within this 15 degree square22
and50
: 2 sets of numbers identifying the longitude and latitude minutes within this 1 degree square. The amount of digits per number can be increased to add sub-minute precision.
The formatting and parsing of georef Strings can be customized using a georef format String. This format String
makes it possible to specify different separators, or add extra digits to the georef String. See the
create(String)
method for more information and examples.
- Since:
- 2015.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.text.Format
Format.Field
-
Method Summary
Modifier and TypeMethodDescriptionstatic TLcdGeorefFormat
create()
Creates a new georef format without separators and with a precision of 1 minute.static TLcdGeorefFormat
create
(char aZoneSeparator, char aCoordinateSeparator, int aNumberOfDigits) Returns a new georef format with the given coordinate separators, and number of digits.static TLcdGeorefFormat
Creates a new georef format, based on a georef format String.format
(Object aObject, StringBuffer aStringBufferToAppendTo, FieldPosition pos) Returns the Georef pattern used as described increate(java.lang.String)
.Parses a givenString
and creates a newObject
with the corresponding type/properties.parseObject
(String source, ParsePosition pos) 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
-
Method Details
-
create
Creates a new georef format without separators and with a precision of 1 minute.- Returns:
- a new georef format
-
create
public static TLcdGeorefFormat create(char aZoneSeparator, char aCoordinateSeparator, int aNumberOfDigits) Returns a new georef format with the given coordinate separators, and number of digits.- Parameters:
aZoneSeparator
- the character to separate the 15 and 1 degree letters. Set the value 0 (not the character '0') to have no separator.aCoordinateSeparator
- the character to separate the 1 degree letters and the coordinates. Set the value 0 (not the character '0') to have no separator between the coordinates.aNumberOfDigits
- the number of digits after the decimal point of the minutes (MM.xx and mm.xx). It must be a value between 0 and 4 inclusive corresponding to a precision of 1 minute up to 0.0001 minutes respectively.- Returns:
- a new georef format
- Throws:
IllegalArgumentException
- whenaZoneSeparator
oraCoordinateSeparator
is a digit or letter, or whenaNumberOfDigits
lies outside the [0, 4] interval.
-
create
Creates a new georef format, based on a georef format String. The format in BNF notation (expressions enclosed in
[]
brackets are optional, expressions enclosed in{}
brackets may be omitted or repeated):<pattern> ::= [<degrees15>] [<separator> <degrees>] [<minutes>] <degrees15> ::= "D" <degrees> ::= "d" <minutes> ::= [<separator> <x> <separator> <y>] <x> ::= "X" <minutes_precision> <y> ::= "Y" <minutes_precision> <minutes_precision> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" <separator> ::= { ? any character ? }
When specifying the minutes precision, the value of 2 corresponds with a precision of 1 minute (can be represented by 2 digits, e.g. 37'). A value of 3 corresponds with a precision of 0.1 minute, ...etc. For example:- "GJ PJ 3716" has format "D d X2Y2"
- "GJ-PJ-37000-16000" has format "D-d-X5-Y5"
- Parameters:
aGeorefFormat
- the georef format String.- Returns:
- a new georef format.
- Throws:
IllegalArgumentException
- when the given georef format String can not be used. For example, when the 'D' or 'd' characters are missing, the resulting georef Strings can not be parsed back to a lon lat point. An exception will also be thrown when the separators consist of letters or digits.
-
getPattern
Returns the Georef pattern used as described increate(java.lang.String)
.- Returns:
- the current Georef pattern in EBNF format
- Since:
- 2021.1
-
format
-
parseObject
- Specified by:
parseObject
in classFormat
-
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.
-