Class Units

Object
Units

public final class Units extends Object
A set of units to use in addition of SI and NonSI.
Since:
2.1
Author:
Martin Desruisseaux (IRD)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static 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 of 1/12 of a Units.YEAR.
    static final Unit<Length>
     
    static final Unit<Dimensionless>
     
    static final Unit<Length>
    Length of 1/72 of a USCustomary.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 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 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.
    Gets an instance of the default system-wide Unit format.
    static Unit<?>
    Parses the text into an instance of unit
    static String
    toName(Unit<?> unit)
    Unit name, willing to use UnitFormat to look up appropriate label if a name has not been not defined.
    static String
    toSymbol(Unit<?> unit)
    Unit symbol, willing to use UnitFormat to look up appropriate label if required.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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
    • 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 of 1/72 of a USCustomary.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 of 1/12 of a Units.YEAR.
    • YEAR

      public static final Unit<Time> YEAR
  • Method Details

    • getDefaultFormat

      public static UnitFormatter getDefaultFormat()
      Gets an instance of the default system-wide Unit format. Use this method instead of SimpleUnitFormat.getInstance(), since custom Geotools units are not known to SimpleUnitFormat.getInstance().
      See Also:
    • toName

      public static String toName(Unit<?> unit)
      Unit name, willing to use UnitFormat to 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 use UnitFormat 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 the equals(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 the UnitFormatter is unable to parse.
      See Also: