Class TLcdLonLatPointFormat

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

public class TLcdLonLatPointFormat extends Format implements ILcdFormatter, ILcdParser, ILcdLonLatFormatter
Format for points. It allows you to parse and format points from/to longitude latitude coordinates.

The formatting of coordinates is determined by the pattern string that is passed to the constructor of this class. The EBNF for the pattern syntax is

   pattern     = lon, separator, lat | lat, separator, lon
   lon         = "lon(", axiscoord, { precision } ")"
   lat         = "lat(", axiscoord, { precision } ")"
   axiscoord   = axis, coord | coord, axis | sign, coord | splitcoord
   splitcoord  = degrees axis minutes | degrees axis minutes seconds | degrees minutes axis seconds
   coord       = degrees | degrees, minutes | degrees, minutes, seconds
   degrees     = ( "d" | "D" )
   minutes     = ( "m" | "M" )
   seconds     = ( "s" | "S" )
   sign        = "+"
   axis        = "a" | white space, "a" | "a", white space
   precision   = digit
   digit       = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
   separator   = { ? any character ? }
 

The table below details the meaning of each pattern character

SymbolMeaningExample
dInteger degrees354
DInteger degrees with degrees symbol354°
mInteger minutes54
MInteger minutes with minutes symbol54'
sInteger seconds54
SInteger seconds with seconds symbol54"
+Coordinate sign. Results in a '-' if the coordinate is negative-
aHemisphere indicatorN, S, E, W

As an example, the default formatting pattern is "lat(+DMS),lon(+DMS)". This results in a format that generates the latitude coordinate, a comma character and the longitude coordinate. Each coordinate is prefixed with a sign followed by integer degrees, minutes, seconds including their respective unit characters (i.e, °, ' and ").

Since:
11.0
See Also:
  • Field Details

    • DEFAULT

      public static final String DEFAULT
      Default pattern: dd°mm'ss", ddd°mm'ss" .
      See Also:
    • DEFAULT1

      public static final String DEFAULT1

      Default pattern 1: dd°mm'ss.s", ddd°mm'ss.s" .

      Note that the decimal separator depends on the default Locale of the JVM when using the constructor which only specifies the pattern. Use the constructor which also specifies the Locale to have control over the decimal separator.

      See Also:
    • DEFAULT2

      public static final String DEFAULT2

      Default pattern 2: dd°mm'ss.ss", ddd°mm'ss.ss" .

      Note that the decimal separator depends on the default Locale of the JVM when using the constructor which only specifies the pattern. Use the constructor which also specifies the Locale to have control over the decimal separator.

      See Also:
    • NSWE

      public static final String NSWE
      NSWE pattern: ddmmssNdddmmssE .
      See Also:
    • NSWE2

      public static final String NSWE2

      NSWE pattern 2: ddmmss.ssssNdddmmss.ssssE .

      Note that the decimal separator depends on the default Locale of the JVM when using the constructor which only specifies the pattern. Use the constructor which also specifies the Locale to have control over the decimal separator.

      See Also:
    • WENS

      public static final String WENS
      WENS pattern: dddmmssEddmmssN.
      See Also:
    • DEC_DEG_0

      public static final String DEC_DEG_0
      Decimal degrees pattern 0: xx°, xxx° .
      See Also:
    • DEC_DEG_1

      public static final String DEC_DEG_1

      Decimal degrees pattern 1: xx.x°, xxx.x° .

      Note that the decimal separator depends on the default Locale of the JVM when using the constructor which only specifies the pattern. Use the constructor which also specifies the Locale to have control over the decimal separator.

      See Also:
    • DEC_DEG_2

      public static final String DEC_DEG_2

      Decimal degrees pattern 2: xx.xx°, xxx.xx° .

      Note that the decimal separator depends on the default Locale of the JVM when using the constructor which only specifies the pattern. Use the constructor which also specifies the Locale to have control over the decimal separator.

      See Also:
    • DEC_DEG_3

      public static final String DEC_DEG_3

      Decimal degrees pattern 3: xx.xxx°, xxx.xxx° .

      Note that the decimal separator depends on the default Locale of the JVM when using the constructor which only specifies the pattern. Use the constructor which also specifies the Locale to have control over the decimal separator.

      See Also:
    • DEC_DEG_4

      public static final String DEC_DEG_4

      Decimal degrees pattern 4: xx.xxxx°, xxx.xxxx° .

      Note that the decimal separator depends on the default Locale of the JVM when using the constructor which only specifies the pattern. Use the constructor which also specifies the Locale to have control over the decimal separator.

      See Also:
    • DEC_DEG_5

      public static final String DEC_DEG_5

      Decimal degrees pattern 5: xx.xxxxx°, xxx.xxxxx° .

      Note that the decimal separator depends on the default Locale of the JVM when using the constructor which only specifies the pattern. Use the constructor which also specifies the Locale to have control over the decimal separator.

      See Also:
    • DEC_DEG_6

      public static final String DEC_DEG_6

      Decimal degrees pattern 6: xx.xxxxxx°, xxx.xxxxxx° .

      Note that the decimal separator depends on the default Locale of the JVM when using the constructor which only specifies the pattern. Use the constructor which also specifies the Locale to have control over the decimal separator.

      See Also:
    • DEC_MIN_0

      public static final String DEC_MIN_0
      Decimal minutes pattern 0: xx°xx', xxx°xx' .
      See Also:
    • DEC_MIN_1

      public static final String DEC_MIN_1

      Decimal minutes pattern 1: xx°xx.x', xxx°xx.x' .

      Note that the decimal separator depends on the default Locale of the JVM when using the constructor which only specifies the pattern. Use the constructor which also specifies the Locale to have control over the decimal separator.

      See Also:
    • DEC_MIN_2

      public static final String DEC_MIN_2

      Decimal minutes pattern 2: xx°xx.xx', xxx°xx.xx' .

      Note that the decimal separator depends on the default Locale of the JVM when using the constructor which only specifies the pattern. Use the constructor which also specifies the Locale to have control over the decimal separator.

      See Also:
  • Constructor Details

    • TLcdLonLatPointFormat

      public TLcdLonLatPointFormat()
      Creates a new TLcdLonLatFormatter that will use the DEFAULT pattern, for example 30°32'45",-123°45'15". This constructor is equivalent to new TLcdLonLatPointFormat( TLcdLonLatPointFormat.DEFAULT ).
    • TLcdLonLatPointFormat

      public TLcdLonLatPointFormat(String aPattern)
      Creates a new TLcdLonLatFormatter that will use the specified pattern. This constructor is equivalent to new TLcdLonLatPointFormat( aPattern, null ).
      Parameters:
      aPattern - a pattern string as defined in the class documentation.
      Throws:
      IllegalArgumentException - if the formatting pattern is invalid
    • TLcdLonLatPointFormat

      public TLcdLonLatPointFormat(String aPattern, Locale aLocale)
      Creates a new TLcdLonLatFormatter that will use the specified pattern. The given locale will be used to lookup the decimal point character.
      Parameters:
      aPattern - a pattern string as defined in the class documentation.
      aLocale - the locale to use, or null when the default locale should be used
      Throws:
      IllegalArgumentException - if the formatting pattern is invalid
  • Method Details

    • getPattern

      public String getPattern()
      Returns the pattern used by this formatter to format Strings representing lon-lat points.
      Returns:
      the pattern used by this formatter
    • isStrictMode

      public boolean isStrictMode()
      Returns whether or not the parser will act strictly with valid characters or not.
      Returns:
      true when only valid characters will be parsed else false
      Since:
      2019.1
      See Also:
    • setStrictMode

      public void setStrictMode(boolean aStrictMode)
      Set whether or not the parser will only allow strictly valid characters or not.

      Valid characters include:

      • numbers;
      • axis indicators [wWeEnNsS];
      • degree symbol [°];
      • minutes symbol ['];
      • seconds symbol ["];
      • separation character (if used in the pattern)
      • whitespace (as used in the pattern)

      Example of valid input: 14°, 50°

      Example of invalid input: 14°&invalid 50°

      When strict mode is off invalid characters will be seen as a separation character.

      By default strict mode is not enabled.

      Parameters:
      aStrictMode - whether or not the parsers will only allow strictly valid characters or not.
      Since:
      2019.1
    • format

      public StringBuffer format(Object aObject, StringBuffer aStringBuffer, FieldPosition aFieldPosition)
      Specified by:
      format in class Format
    • format

      public String format(double aLon, double aLat)
      Formats the given longitude/latitude coordinate pair as a String, following the current pattern.
      Specified by:
      format in interface ILcdLonLatFormatter
      Parameters:
      aLon - the longitude, expressed in degrees.
      aLat - the latitude, expressed in degrees.
      Returns:
      the formatted String.
    • formatLat

      public String formatLat(double aLat)
      Formats the given latitude coordinate as a String, following the current pattern.
      Specified by:
      formatLat in interface ILcdLonLatFormatter
      Parameters:
      aLat - the latitude, expressed in degrees.
      Returns:
      the formatted String.
    • formatLon

      public String formatLon(double aLon)
      Formats the given longitude coordinate as a String, following the current pattern.
      Specified by:
      formatLon in interface ILcdLonLatFormatter
      Parameters:
      aLon - the longitude, expressed in degrees.
      Returns:
      the formatted String.
    • parse

      public ILcd2DEditablePoint 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.
    • parseObject

      public ILcd2DEditablePoint parseObject(String aSource) throws ParseException
      Overrides:
      parseObject in class Format
      Throws:
      ParseException
    • parseObject

      public ILcd2DEditablePoint parseObject(String aString, ParsePosition aParsePosition)
      Specified by:
      parseObject in class Format
    • equals

      public boolean equals(Object aO)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object