Package org.geotools.measure
Class Units
- Object
-
- Units
-
public final class Units extends Object
A set of units to use in addition ofSIandNonSI.- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
-
-
Field Summary
Fields Modifier and Type Field Description static Unit<Time>DAYHelper definition so someone can align to GeoTools Day Unit type *static Unit<Angle>DEGREE_ANGLEstatic Unit<Angle>DEGREE_MINUTE_SECONDPseudo-unit for degree - minute - second.static Unit<Length>FOOTstatic Unit<Angle>GRADEstatic Unit<Length>KILOMETERstatic Unit<Length>METREstatic Unit<Angle>MICRORADIANstatic Unit<Angle>MINUTE_ANGLEstatic Unit<Time>MONTHTime duration of1/12of aUnits.YEAR.static Unit<Length>NAUTICAL_MILEstatic Unit<Dimensionless>ONEstatic Unit<Length>PIXELLength of1/72of aUSCustomary.INCHstatic Unit<Dimensionless>PPMParts per million.static Unit<Angle>RADIANstatic Unit<Angle>SECOND_ANGLEstatic Unit<Angle>SEXAGESIMAL_DMSPseudo-unit for sexagesimal degree.static Unit<Time>YEAR
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <Q extends Quantity<Q>>
Unit<Q>autoCorrect(Unit<Q> unit)Returns an equivalent unit instance based on the provided unit.static booleanequals(Unit<?> unit1, Unit<?> unit2)Checks whether two units can be considered equivalent.static UnitConvertergetConverterToAny(Unit<?> fromUnit, Unit<?> toUnit)Gets a UnitConverter between two units, wrapping any raised exception in a IllegalArgumentException.static UnitFormattergetDefaultFormat()Gets an instance of the default system-wide Unit format.static Unit<?>parseUnit(String name)Parses the text into an instance of unitstatic StringtoName(Unit<?> unit)Unit name, willing to useUnitFormatto look up appropriate label if a name has not been not defined.static StringtoSymbol(Unit<?> unit)Unit symbol, willing to useUnitFormatto look up appropriate label if required.
-
-
-
Field Detail
-
DEGREE_ANGLE
public static final Unit<Angle> DEGREE_ANGLE
-
DEGREE_MINUTE_SECOND
public static final Unit<Angle> DEGREE_MINUTE_SECOND
Pseudo-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_DMS
Pseudo-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> PPM
Parts 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> PIXEL
Length of1/72of aUSCustomary.INCH
-
DAY
public static final Unit<Time> DAY
Helper definition so someone can align to GeoTools Day Unit type *
-
MONTH
public static final Unit<Time> MONTH
Time duration of1/12of aUnits.YEAR.
-
YEAR
public static final Unit<Time> YEAR
-
-
Method Detail
-
getDefaultFormat
public static UnitFormatter 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:
UnitFormat.getInstance()
-
toName
public static String toName(Unit<?> unit)
Unit name, willing to useUnitFormatto look up appropriate label if a name has not been not defined.This allows us to format units like
PIXEL.
-
toSymbol
public static String toSymbol(Unit<?> unit)
Unit symbol, willing to useUnitFormatto 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
public static Unit<?> parseUnit(String name)
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 theUnitFormatteris unable to parse.- See Also:
UnitFormatter.parse(CharSequence)
-
-