Package skyview.data

Class CoordinateFormatter

java.lang.Object
skyview.data.CoordinateFormatter

public class CoordinateFormatter
extends java.lang.Object
This class provides methods to encode coordinates to a variety of precisions in both sexagesimal and decimal representations.
  • Constructor Summary

    Constructors 
    Constructor Description
    CoordinateFormatter()  
  • Method Summary

    Modifier and Type Method Description
    java.lang.String decimal​(double value, int precision)
    Format a number with a specified precision.
    java.lang.String format​(double value, int precision)
    Render a value using the current rules.
    static void main​(java.lang.String[] args)  
    void setSeparators​(java.lang.String[] separators)
    Specify the two separators to be used between the three numbers in sexagesimal output.
    void setSexagesimal​(boolean flag)  
    void setZeroFill​(boolean flag)  
    java.lang.String sexagesimal​(double value, int precision)
    Create a sexagesimal string representing the coordinate value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • sexagesimal

      public java.lang.String sexagesimal​(double value, int precision)
      Create a sexagesimal string representing the coordinate value.
      Parameters:
      value - A double precision value which is to be converted to a string representation. The user should convert to hours prior to this call if the string is to be in hours.
      precision - A integer value giving the precision to which the value is to be shown.
      Less than 3
      Degrees (or hours), e.g. 24
      3
      Deg.f e.g., 24.3
      4
      Deg mm e.g., 24 18
      5
      Deg mm.f e.g., 25 18.3
      6
      Deg mm ss e.g., 25 18 18
      7
      Deg mm ss.s e.g., 25 18 18.2
      8
      Deg mm ss.ss e.g., 25 18 18.24
      Greater than 8
      Deg mm ss.sss e.g., 25 18 18.238
    • decimal

      public java.lang.String decimal​(double value, int precision)
      Format a number with a specified precision. The precision is 2 more than the number of decimal places. E.g., to get 4 decimal places use a precision of 6.
    • setZeroFill

      public void setZeroFill​(boolean flag)
    • setSexagesimal

      public void setSexagesimal​(boolean flag)
    • setSeparators

      public void setSeparators​(java.lang.String[] separators)
      Specify the two separators to be used between the three numbers in sexagesimal output. The default is blank separators. E.g., to get output of the form 10:20:30 then this.setSeparators(new String[]{":", ":"}); before rendering.
      Parameters:
      separators -
    • format

      public java.lang.String format​(double value, int precision)
      Render a value using the current rules. Note that any scaling between hours/degrees should be done before rendering.
    • main

      public static void main​(java.lang.String[] args)