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 class
The inverse ofSexagesimalConverter
, i.e. -
Field Summary
FieldsModifier and TypeFieldDescription(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
ConstructorsModifierConstructorDescriptionprivate
SexagesimalConverter
(boolean hasSeconds, double divider) Constructs a converter for sexagesimal units.private
SexagesimalConverter
(SexagesimalConverter inverse) Constructs a converter for sexagesimal units. -
Method Summary
Modifier and TypeMethodDescriptiondouble
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
Compares this converter with the specified object.final int
hashCode()
Returns a hash value for this converter.final javax.measure.UnitConverter
inverse()
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"
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> 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"
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_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"
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 hasSecondstrue
if 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
-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
Constructs a converter for sexagesimal units. This constructor is forSexagesimalConverter.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 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.
-