Class TLcdGeorefFormat

java.lang.Object
java.text.Format
com.luciad.text.TLcdGeorefFormat
All Implemented Interfaces:
ILcdFormatter, ILcdParser, Serializable, Cloneable

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 square
  • 22 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.

Since:
2015.0
See Also:
  • Method Details

    • create

      public static TLcdGeorefFormat 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 - when aZoneSeparator or aCoordinateSeparator is a digit or letter, or when aNumberOfDigits lies outside the [0, 4] interval.
    • create

      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:
      • "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

      public String getPattern()
      Returns the Georef pattern used as described in create(java.lang.String).
      Returns:
      the current Georef pattern in EBNF format
      Since:
      2021.1
    • format

      public StringBuffer format(Object aObject, StringBuffer aStringBufferToAppendTo, FieldPosition pos)
      Specified by:
      format in class Format
    • parseObject

      public Object parseObject(String source, ParsePosition pos)
      Specified by:
      parseObject in class Format
    • parse

      public Object parse(String aString) throws IllegalArgumentException
      Description copied from interface: ILcdParser
      Parses a given String and creates a new Object with the corresponding type/properties.
      Specified by:
      parse in interface ILcdParser
      Parameters:
      aString - the String to be parsed.
      Returns:
      the resulting new Object.
      Throws:
      IllegalArgumentException - if the String can't be parsed.