Package org.apache.sis.measure
Class SexagesimalConverter.Inverse
java.lang.Object
org.apache.sis.measure.AbstractConverter
org.apache.sis.measure.SexagesimalConverter
org.apache.sis.measure.SexagesimalConverter.Inverse
- All Implemented Interfaces:
Serializable
,javax.measure.UnitConverter
- Enclosing class:
- SexagesimalConverter
The inverse of
SexagesimalConverter
, i.e. the converter from sexagesimal degrees to decimal degrees.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
Serial number for compatibility with different versions.Fields inherited from class org.apache.sis.measure.SexagesimalConverter
divider, DM, DMS, DMS_SCALED, hasSeconds
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
convert
(double angle) Performs a conversion from sexagesimal degrees to fractional degrees.private static double
fixRoundingError
(double remainder, double magnitude) After calculation of the remaining seconds or minutes, trims the rounding errors presumably caused by rounding errors in floating point arithmetic.private static IllegalArgumentException
illegalField
(double value, double field, int unit) Creates an exception for an illegal field.Methods inherited from class org.apache.sis.measure.SexagesimalConverter
derivative, equals, hashCode, inverse
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:
-
-
Constructor Details
-
Inverse
Constructs a converter.
-
-
Method Details
-
fixRoundingError
private static double fixRoundingError(double remainder, double magnitude) After calculation of the remaining seconds or minutes, trims the rounding errors presumably caused by rounding errors in floating point arithmetic. This is required for avoiding the following conversion issue:- Sexagesimal value: 46.570866 (from 46°57'8.66"N in EPSG:2056 projected CRS)
- value * 10000 = 465708.66000000003
- deg = 46, min = 57, deg = 8.660000000032596
- Parameters:
remainder
- the value to fix, after other fields (degrees and/or minutes) have been subtracted.magnitude
- value ofremainder
before the degrees and/or minutes were subtracted.
-
convert
Performs a conversion from sexagesimal degrees to fractional degrees.- Specified by:
convert
in interfacejavax.measure.UnitConverter
- Overrides:
convert
in classSexagesimalConverter
- Throws:
IllegalArgumentException
- If the given angle cannot be converted.
-
illegalField
Creates an exception for an illegal field.- Parameters:
value
- the user supplied angle value.field
- the value of the illegal field.unit
- 0 for minutes or 1 for seconds.- Returns:
- the exception to throw.
-