Class CoordinateFormat

java.lang.Object
ucar.unidata.view.geoloc.CoordinateFormat

public class CoordinateFormat extends Object
The CoordinateFormat class to format geo coordinates.
  • Field Details

  • Constructor Details

    • CoordinateFormat

      public CoordinateFormat()
  • Method Details

    • convert

      public static String convert(double coord, CoordinateFormat.Format degF, CoordinateFormat.Format minF, CoordinateFormat.Format secF, CoordinateFormat.Cardinality card)
      Convert a decimal coordinate.
      Parameters:
      coord - the decimal coord
      degF - the deg format
      minF - the min format
      secF - the sec format
      card - the cardinality
      Returns:
      the formatted coordinate string
    • formatLatitude

      public static String formatLatitude(double value, String format)
      Format a longitude to the given format. formatLongitude(double, String, boolean)
      Parameters:
      value - the value to format
      format - the format
      Returns:
      formatted latitude
    • formatLongitude

      public static String formatLongitude(double value, String format, boolean use360)
      Format a latitude or longitude value to the given format. Formats use DD for degrees, MM for minutes, SS for seconds and d, m, s for decimal fractions of degrees, minutes, seconds. H designates the hemisphere (N,S,E,W).
       Examples for value -34.496 degrees
      
           DD:MM:SS      ===>  -34:29:45
             (if longitude and use360 ===> 326:29:45)
           DDH           ===>   34W     (or 34S if longitude)
           DD.d          ===>  -34.5
           DD.dddH       ===>   34.496W (or 34.496S if longitude)
           DD MM'SS.s"   ===>  -34 29'45.6"
      
       
      Parameters:
      value - the value to format
      format - the format
      use360 - if true use 0-360 notation instead of -180 to 180 notation
      Returns:
      formatted longitude