Package org.geotools.measure
Class Units
Object
Units
A set of units to use in addition of
SI
and NonSI
.- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Unit<Time>
Helper definition so someone can align to GeoTools Day Unit type *static final Unit<Angle>
static final Unit<Angle>
Pseudo-unit for degree - minute - second.static final Unit<Length>
static final Unit<Angle>
static final Unit<Length>
static final Unit<Length>
static final Unit<Angle>
static final Unit<Angle>
static final Unit<Time>
Time duration of1/12
of aUnits.YEAR
.static final Unit<Length>
static final Unit<Dimensionless>
static final Unit<Length>
Length of1/72
of aUSCustomary.INCH
static final Unit<Dimensionless>
Parts per million.static final Unit<Angle>
static final Unit<Angle>
static final Unit<Angle>
Pseudo-unit for sexagesimal degree.static final Unit<Time>
-
Method Summary
Modifier and TypeMethodDescriptionstatic <Q extends Quantity<Q>>
Unit<Q>autoCorrect
(Unit<Q> unit) Returns an equivalent unit instance based on the provided unit.static final boolean
equals
(Unit<?> unit1, Unit<?> unit2) Checks whether two units can be considered equivalent.static UnitConverter
getConverterToAny
(Unit<?> fromUnit, Unit<?> toUnit) Gets a UnitConverter between two units, wrapping any raised exception in a IllegalArgumentException.static UnitFormatter
Gets an instance of the default system-wide Unit format.static Unit<?>
Parses the text into an instance of unitstatic String
toName
(Unit<?> unit) Unit name, willing to useUnitFormat
to look up appropriate label if a name has not been not defined.static String
toSymbol
(Unit<?> unit) Unit symbol, willing to useUnitFormat
to look up appropriate label if required.
-
Field Details
-
DEGREE_ANGLE
public static final Unit<Angle> DEGREE_ANGLE -
DEGREE_MINUTE_SECOND
public static final Unit<Angle> DEGREE_MINUTE_SECONDPseudo-unit for degree - minute - second. Numbers in this pseudo-unit has the following format:signed degrees (integer) - arc-minutes (integer) - arc-seconds (real, any precision).
This unit is non-linear and not practical for computation. Consequently, it should be avoid as much as possible. Unfortunately, this pseudo-unit is extensively used in the EPSG database (code 9107).
-
GRADE
public static final Unit<Angle> GRADE -
MICRORADIAN
public static final Unit<Angle> MICRORADIAN -
MINUTE_ANGLE
public static final Unit<Angle> MINUTE_ANGLE -
RADIAN
public static final Unit<Angle> RADIAN -
SEXAGESIMAL_DMS
public static final Unit<Angle> SEXAGESIMAL_DMSPseudo-unit for sexagesimal degree. Numbers in this pseudo-unit has the following format:sign - degrees - decimal point - minutes (two digits) - integer seconds (two digits) - fraction of seconds (any precision).
This unit is non-linear and not pratical for computation. Consequently, it should be avoid as much as possible. Unfortunatly, this pseudo-unit is extensively used in the EPSG database (code 9110).
-
SECOND_ANGLE
public static final Unit<Angle> SECOND_ANGLE -
PPM
public static final Unit<Dimensionless> PPMParts per million. -
ONE
public static final Unit<Dimensionless> ONE -
FOOT
public static final Unit<Length> FOOT -
METRE
public static final Unit<Length> METRE -
KILOMETER
public static final Unit<Length> KILOMETER -
NAUTICAL_MILE
public static final Unit<Length> NAUTICAL_MILE -
PIXEL
public static final Unit<Length> PIXELLength of1/72
of aUSCustomary.INCH
-
DAY
public static final Unit<Time> DAYHelper definition so someone can align to GeoTools Day Unit type * -
MONTH
public static final Unit<Time> MONTHTime duration of1/12
of aUnits.YEAR
. -
YEAR
public static final Unit<Time> YEAR
-
-
Method Details
-
getDefaultFormat
Gets an instance of the default system-wide Unit format. Use this method instead ofSimpleUnitFormat.getInstance()
, since custom Geotools units are not known toSimpleUnitFormat.getInstance()
.- See Also:
-
toName
Unit name, willing to useUnitFormat
to look up appropriate label if a name has not been not defined.This allows us to format units like
PIXEL
. -
toSymbol
Unit symbol, willing to useUnitFormat
to look up appropriate label if required.This allows us to format units like
PIXEL
. -
autoCorrect
public static <Q extends Quantity<Q>> Unit<Q> autoCorrect(Unit<Q> unit) Returns an equivalent unit instance based on the provided unit. First, it tries to get one of the reference units defined in the JSR 385 implementation in use. Units are considered equivalent if theequals(Unit, Unit)
method returns true. If no equivalent reference unit is defined, it returns the provided unit. -
equals
public static final boolean equals(Unit<?> unit1, Unit<?> unit2) Checks whether two units can be considered equivalent. TransformedUnits are considered equivalent if they have the same system unit and their conversion factors to the system unit produce the identity converter when the inverse of the second factor is concatenated with the first factor, considering the precision of a float number. For other types of units, the comparison is delegated to their normal equals method. -
getConverterToAny
public static UnitConverter getConverterToAny(Unit<?> fromUnit, Unit<?> toUnit) Gets a UnitConverter between two units, wrapping any raised exception in a IllegalArgumentException.- Throws:
IllegalArgumentException
- if unit1 can't be converter to unit2
-
parseUnit
Parses the text into an instance of unit- Returns:
- A unit instance
- Throws:
MeasurementParseException
- if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).UnsupportedOperationException
- if theUnitFormatter
is unable to parse.- See Also:
-