Class Units

java.lang.Object
org.locationtech.proj4j.geoapi.Units

final class Units extends Object
Predefined constants for the units of measurement. The actual JSR-385 implementation is left at user's choice.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final javax.measure.Unit<javax.measure.quantity.Angle>
    Angular unit.
    private static Units
    The default instance, created when first needed.
    final javax.measure.Unit<javax.measure.quantity.Length>
    Linear unit.
    final javax.measure.Unit<javax.measure.quantity.Dimensionless>
    Scale unit.
    final javax.measure.Unit<javax.measure.quantity.Dimensionless>
    Scale unit.
    final javax.measure.Unit<javax.measure.quantity.Angle>
    Angular unit.
    final javax.measure.spi.SystemOfUnits
    The implementation-dependent system of units for creating base units.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Units(javax.measure.spi.SystemOfUnits system)
    Creates a new set of units which will use the given system of units.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static javax.measure.Unit<javax.measure.quantity.Dimensionless>
    getDimensionless(javax.measure.spi.SystemOfUnits system)
    Returns the dimensionless unit.
    static Units
    Returns the default units factory.
    (package private) final Unit
    proj4j(javax.measure.Unit<?> unit)
    Returns the given JSR-385 unit of measurement as a PROJ4J instance.

    Methods inherited from class Object

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

    • instance

      private static Units instance
      The default instance, created when first needed.
      See Also:
    • system

      public final javax.measure.spi.SystemOfUnits system
      The implementation-dependent system of units for creating base units.
    • metre

      public final javax.measure.Unit<javax.measure.quantity.Length> metre
      Linear unit.
    • degree

      public final javax.measure.Unit<javax.measure.quantity.Angle> degree
      Angular unit.
    • radian

      public final javax.measure.Unit<javax.measure.quantity.Angle> radian
      Angular unit.
    • one

      public final javax.measure.Unit<javax.measure.quantity.Dimensionless> one
      Scale unit.
    • ppm

      public final javax.measure.Unit<javax.measure.quantity.Dimensionless> ppm
      Scale unit.
  • Constructor Details

    • Units

      private Units(javax.measure.spi.SystemOfUnits system)
      Creates a new set of units which will use the given system of units.
      Parameters:
      system - the system of units to use for creating base units
  • Method Details

    • getInstance

      public static Units getInstance()
      Returns the default units factory.. This factory uses the unit service provider which is current at the time of the first invocation of this method.
      Returns:
      the default units factory
    • getDimensionless

      private static javax.measure.Unit<javax.measure.quantity.Dimensionless> getDimensionless(javax.measure.spi.SystemOfUnits system)
      Returns the dimensionless unit. This is a workaround for what seems to be a bug in the reference implementation 1.0.1 of unit API.
      Parameters:
      system - the system of units from which to get the dimensionless unit.
      Returns:
      the dimensionless unit.
    • proj4j

      final Unit proj4j(javax.measure.Unit<?> unit)
      Returns the given JSR-385 unit of measurement as a PROJ4J instance. Note that there is no method in the reverse direction (from PROJ4J to JSR-385) because current PROJ4J does not tell us whether the unit is linear or angular.
      Parameters:
      unit - the unit of measurement
      Returns:
      the PROJ4J equivalent unit
      Throws:
      UnconvertibleInstanceException - if the unit cannot be mapped