public class TLcdGeorefFormat extends Format implements ILcdFormatter, ILcdParser
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
and 50
: 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.
TLcdGeorefUtil
,
Serialized FormFormat.Field
Modifier and Type | Method and Description |
---|---|
static 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 |
create(String aGeorefFormat)
Creates a new georef format, based on a georef format String.
|
StringBuffer |
format(Object aObject,
StringBuffer aStringBufferToAppendTo,
FieldPosition pos) |
String |
getPattern()
Returns the Georef pattern used as described in
create(java.lang.String) . |
Object |
parse(String aString)
Parses a given
String and creates a new Object
with the corresponding type/properties. |
Object |
parseObject(String source,
ParsePosition pos) |
clone, format, formatToCharacterIterator, parseObject
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
format
public static TLcdGeorefFormat create()
public static TLcdGeorefFormat create(char aZoneSeparator, char aCoordinateSeparator, int aNumberOfDigits)
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.IllegalArgumentException
- when aZoneSeparator
or aCoordinateSeparator
is a
digit or letter, or when aNumberOfDigits
lies outside the [0, 4] interval.public static TLcdGeorefFormat create(String aGeorefFormat)
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:
aGeorefFormat
- the georef format String.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.public String getPattern()
create(java.lang.String)
.public StringBuffer format(Object aObject, StringBuffer aStringBufferToAppendTo, FieldPosition pos)
public Object parseObject(String source, ParsePosition pos)
parseObject
in class Format
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.