Class SexagesimalConverter

java.lang.Object
org.apache.sis.measure.AbstractConverter
org.apache.sis.measure.SexagesimalConverter
All Implemented Interfaces:
Serializable, javax.measure.UnitConverter
Direct Known Subclasses:
SexagesimalConverter.Inverse

class SexagesimalConverter extends AbstractConverter
A converter from decimal degrees to sexagesimal degrees. Sexagesimal degrees are pseudo-unit in the sign - degrees - decimal point - minutes (two digits) - integer seconds (two digits) - fraction of seconds (any precision) format.

When possible, Apache SIS always handles angles in radians, decimal degrees or any other proportional units. Sexagesimal angles are considered a string representation issue (handled by AngleFormat) rather than a unit issue. Unfortunately, this pseudo-unit is extensively used in the EPSG database, so we have to support it.

Immutability and thread safety

This class and all inner classes are immutable, and thus inherently thread-safe.
Since:
0.3
Version:
1.2
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static final class 
    The inverse of SexagesimalConverter, i.e.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final double
    The value to divide DMS unit by.
    (package private) static final ConventionalUnit<javax.measure.quantity.Angle>
    Pseudo-unit for sexagesimal degree.
    (package private) static final javax.measure.Unit<javax.measure.quantity.Angle>
    Pseudo-unit for sexagesimal degree.
    (package private) static final javax.measure.Unit<javax.measure.quantity.Angle>
    Pseudo-unit for degree - minute - second.
    private static final double
    Small tolerance factor when comparing numbers close to 1.
    (package private) final boolean
    true if the seconds field is present.
    private final javax.measure.UnitConverter
    The inverse of this converter.
    private static final long
    Serial number for compatibility with different versions.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    SexagesimalConverter(boolean hasSeconds, double divider)
    Constructs a converter for sexagesimal units.
    private
    Constructs a converter for sexagesimal units.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    convert(double angle)
    Performs a conversion from fractional degrees to sexagesimal degrees.
    final double
    derivative(double value)
    Considers this converter as non-derivable.
    final boolean
    equals(Object object)
    Compares this converter with the specified object.
    final int
    Returns a hash value for this converter.
    final javax.measure.UnitConverter
    Returns the inverse of this converter.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serial number for compatibility with different versions.
      See Also:
    • EPS

      private static final double EPS
      Small tolerance factor when comparing numbers close to 1. For comparing numbers other than 1, multiply by the number magnitude.
      See Also:
    • DM

      static final ConventionalUnit<javax.measure.quantity.Angle> DM
      Pseudo-unit for sexagesimal degree. Numbers in this pseudo-unit have the following format: sign - degrees - decimal point - minutes (two digits) - fraction of minutes (any precision). Using this unit is loosely equivalent to formatting decimal degrees with the "D.MMm" AngleFormat pattern.

      This unit is non-linear and not practical for computation. Consequently, it should be avoided as much as possible. This pseudo-unit is defined only because used in the EPSG database (code 9111).

    • DMS

      static final javax.measure.Unit<javax.measure.quantity.Angle> DMS
      Pseudo-unit for sexagesimal degree. Numbers in this pseudo-unit have the following format: sign - degrees - decimal point - minutes (two digits) - integer seconds (two digits) - fraction of seconds (any precision). Using this unit is loosely equivalent to formatting decimal degrees with the "D.MMSSs" AngleFormat pattern.

      This unit is non-linear and not practical for computation. Consequently, it should be avoided as much as possible. This pseudo-unit is defined only because extensively used in the EPSG database (code 9110).

    • DMS_SCALED

      static final javax.measure.Unit<javax.measure.quantity.Angle> DMS_SCALED
      Pseudo-unit for degree - minute - second. Numbers in this pseudo-unit have the following format: signed degrees (integer) - arc-minutes (integer) - arc-seconds (real, any precision). Using this unit is loosely equivalent to formatting decimal degrees with the "DMMSS.s" AngleFormat pattern.

      This unit is non-linear and not practical for computation. Consequently, it should be avoided as much as possible. This pseudo-unit is defined only because extensively used in EPSG database (code 9107).

    • hasSeconds

      final boolean hasSeconds
      true if the seconds field is present.
    • divider

      final double divider
      The value to divide DMS unit by. For "degree minute second" (EPSG code 9107), this is 1. For "sexagesimal degree" (EPSG code 9110), this is 10000.
    • inverse

      private final javax.measure.UnitConverter inverse
      The inverse of this converter.
  • Constructor Details

    • SexagesimalConverter

      private SexagesimalConverter(boolean hasSeconds, double divider)
      Constructs a converter for sexagesimal units.
      Parameters:
      hasSeconds - true if the seconds field is present.
      divider - the value to divide DMS unit by. For "degree minute second" (EPSG code 9107), this is 1. For "sexagesimal degree" (EPSG code 9110), this is 10000.
    • SexagesimalConverter

      private SexagesimalConverter(SexagesimalConverter inverse)
      Constructs a converter for sexagesimal units. This constructor is for SexagesimalConverter.Inverse usage only.
  • Method Details

    • inverse

      public final javax.measure.UnitConverter inverse()
      Returns the inverse of this converter.
    • convert

      public double convert(double angle)
      Performs a conversion from fractional degrees to sexagesimal degrees.
    • derivative

      public final double derivative(double value)
      Considers this converter as non-derivable. Actually it would be possible to provide a derivative value for input values other than the discontinuities points, but for now we presume that it is less dangerous to return NaN every time, so the user cannot miss that this function is not derivable everywhere.
      Specified by:
      derivative in class AbstractConverter
      Parameters:
      value - the point at which to compute the derivative. Ignored (can be Double.NaN) if the conversion is linear.
    • equals

      public final boolean equals(Object object)
      Compares this converter with the specified object.
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Returns a hash value for this converter.
      Overrides:
      hashCode in class Object