Class TLcdLonLatFormatter

java.lang.Object
com.luciad.util.TLcdLonLatFormatter
All Implemented Interfaces:
ILcdCloneable, ILcdLonLatFormatter, Serializable, Cloneable

public class TLcdLonLatFormatter extends Object implements Serializable, ILcdCloneable, ILcdLonLatFormatter
This class provides various methods for formatting longitude/latitude coordinate pairs as String objects. The pattern property determines the format. The following patterns are provided:
  • dd°mm'ss",ddd°mm'ss"
  • dd°mm'ss.s",ddd°mm's.ss"
  • dd°mm'ss.ss",ddd°mm'ss.ss"
  • ddmmssNdddmmssE
  • ddmmss.ssssNdddmmss.ssssE
  • dddmmssEddmmssN
  • xx°,xxx°
  • xx.x°,xxx.x°
  • xx.xx°,xxx.xx°
  • xx.xxx°,xxx.xxx°
  • xx.xxxx°,xxx.xxxx°
  • xx.xxxxx°,xxx.xxxxx°
  • xx.xxxxxx°,xxx.xxxxxx°
  • xx°xx',xxx°xx'
  • xx°xx.x',xxx°xx.x'
  • xx°xx.xx',xxx°xx.xx'
  • x°,x°
  • x.x°,x.x°
  • x.xx°,x.xx°
  • x',x'
  • x.x',x.x'
  • x.xx',x.xx'
  • x",x"
  • x.x",x.x"
  • x.xx",x.xx"
They can be specified using the constant pattern String objects of this class. The decimal separator may change depending on the locale. The longitude/latitude separator may be changed with the method setLonLatSeparatorChar(char). This class is not thread safe, but an instance of this class can be shared by separate threads at the same time as long as the pattern and the separator character are not being modified in the process.
See Also:
  • Field Details

  • Constructor Details

    • TLcdLonLatFormatter

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

      public TLcdLonLatFormatter(String aPattern)
      Creates a new TLcdLonLatFormatter that will use the specified pattern.
      Parameters:
      aPattern - one of the pattern String constants defined in this class.
  • Method Details

    • setLonLatSeparatorChar

      public static void setLonLatSeparatorChar(char aLonLatSeparatorChar)
      Sets the character to separate longitudes and latitudes. This character is used in the method format(double, double).
      Parameters:
      aLonLatSeparatorChar -
    • getLonLatSeparator

      public static char getLonLatSeparator()
    • setPattern

      public void setPattern(String aPattern)
      Sets the pattern following which Strings will be formatted.
      Parameters:
      aPattern - one of the pattern String constants defined in this class.
    • getPattern

      public String getPattern()
    • 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 pair as a String, following the current pattern.
      Specified by:
      formatLon in interface ILcdLonLatFormatter
      Parameters:
      aLon - the longitude, expressed in degrees.
      Returns:
      the formatted String.
    • clone

      public Object clone()
      Description copied from interface: ILcdCloneable

      Makes Object.clone() public.

      When for example extending from java.lang.Object, it can be implemented like this:
      
       public Object clone() {
         try {
           return super.clone();
         } catch ( CloneNotSupportedException e ) {
           // Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
           throw new RuntimeException( e );
         }
       }
       
      Specified by:
      clone in interface ILcdCloneable
      Overrides:
      clone in class Object
      See Also: