Class SexagesimalConverter
- All Implemented Interfaces:
Serializable,javax.measure.UnitConverter
- Direct Known Subclasses:
SexagesimalConverter.Inverse
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 ClassesModifier and TypeClassDescriptionprivate static final classThe inverse ofSexagesimalConverter, i.e. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final doubleThe 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 doubleSmall tolerance factor when comparing numbers close to 1.(package private) final booleantrueif the seconds field is present.private final javax.measure.UnitConverterThe inverse of this converter.private static final longSerial number for compatibility with different versions. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateSexagesimalConverter(boolean hasSeconds, double divider) Constructs a converter for sexagesimal units.privateSexagesimalConverter(SexagesimalConverter inverse) Constructs a converter for sexagesimal units. -
Method Summary
Modifier and TypeMethodDescriptiondoubleconvert(double angle) Performs a conversion from fractional degrees to sexagesimal degrees.final doublederivative(double value) Considers this converter as non-derivable.final booleanCompares this converter with the specified object.final inthashCode()Returns a hash value for this converter.final javax.measure.UnitConverterinverse()Returns the inverse of this converter.Methods inherited from class org.apache.sis.measure.AbstractConverter
coefficients, concatenate, convert, derivative, doubleValue, epsilonEquals, getConversionSteps, isIdentity, isLinear, scale
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for compatibility with different versions.- See Also:
-
EPS
private static final double EPSSmall tolerance factor when comparing numbers close to 1. For comparing numbers other than 1, multiply by the number magnitude.- See Also:
-
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"AngleFormatpattern.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> DMSPseudo-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"AngleFormatpattern.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_SCALEDPseudo-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"AngleFormatpattern.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 hasSecondstrueif the seconds field is present. -
divider
final double dividerThe 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 inverseThe inverse of this converter.
-
-
Constructor Details
-
SexagesimalConverter
private SexagesimalConverter(boolean hasSeconds, double divider) Constructs a converter for sexagesimal units.- Parameters:
hasSeconds-trueif 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
Constructs a converter for sexagesimal units. This constructor is forSexagesimalConverter.Inverseusage 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:
derivativein classAbstractConverter- Parameters:
value- the point at which to compute the derivative. Ignored (can beDouble.NaN) if the conversion is linear.
-
equals
Compares this converter with the specified object. -
hashCode
public final int hashCode()Returns a hash value for this converter.
-