Class Unit

  • Direct Known Subclasses:
    AngularUnit, AreaUnit, LinearUnit

    public class Unit
    extends java.lang.Object
    Defines a unit of measurement.

    The unit is a common base class for different types of measurement (linear, angular, and area) used throughout ArcGIS Runtime. Many function parameters only accept specific types of measurement to reduce the chance of accidental use of inappropriate values, but some generic functions accept all unit types e.g. for translation from ID to text description.

    LinearUnit - Projected coordinate systems define coordinates using linear measurements, for example using meters or miles. They are also used to return distance measurements, for example by some members of GeometryEngine.

    AngularUnit - Geographic coordinate systems define coordinates using angular measurements, for example using degrees or radians.

    AreaUnit - Projected coordinate systems define area units for two dimensional measurements such as the area enclosed by a ring, for example in acres or square kilometers.

    Linear, angular, and area units can be defined by using enumerations of the most common units of measurement. They can also be defined by Well-Known ID (WKID) or Well-Known Text (WKText). Create the unit instances using the Unit base class or the subtype, passing in the enumeration for a specific unit of measurement.

    Construction of related units are also supported so that if, for instance, the LinearUnit (e.g. METERS) is known, then the corresponding AreaUnit (e.g. SQUARE_METERS) can be created based on the LinearUnit.

    Custom unit implementations are not supported.

    Each instance of the various units types has properties for the unit name (singular, plural, and abbreviated) and provides methods for unit conversion between different units of measurement in the same category of measurement.

    All unit names and abbreviations are returned in the English language. Instances of unit are immutable.

    Since:
    100.0.0
    See Also:
    SpatialReference.getUnit()
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static Unit fromUnitId​(int unitId)
      Creates a new Unit instance with the given well-known ID (WKID).
      java.lang.String getAbbreviation()
      Gets the common abbreviation of the English name of this unit of measurement, for example 'm' for meters.
      java.lang.String getDisplayName()
      Gets the English display name of the unit, suitable for displaying in a user interface.
      java.lang.String getName()
      Gets the name of this unit of measurement, which may include underscores, for example Nautical_Mile or Minute_Centesimal.
      java.lang.String getPluralDisplayName()
      Gets the English display name for the plural of this unit of measurement, suitable for displaying in a user interface when the number of units is greater than one.
      int getUnitId()
      Gets the well-known ID (WKID) of this unit of measurement.
      UnitType getUnitType()
      Gets the type of this unit of measurement, linear, area, or angular.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getUnitId

        public int getUnitId()
        Gets the well-known ID (WKID) of this unit of measurement.

        WKIDs are defined by standards bodies or organizations. ArcGIS supports a variety of WKIDs, typically those defined by the European Petroleum Survey Group (EPSG) or Esri, as well as a few other commonly used IDs. Unit WKIDs are unique across all subclasses - AngularUnit, LinearUnit, and AreaUnit. The supported WKIDs for angular, linear, and area units are documented in the 'Geographic coordinate systems' and 'Projected coordinate systems' tables in the developer Guide.

        Returns:
        the well-known ID of this Unit instance
        Since:
        100.0.0
      • getAbbreviation

        public java.lang.String getAbbreviation()
        Gets the common abbreviation of the English name of this unit of measurement, for example 'm' for meters.
        Returns:
        the abbreviation of the name of this Unit
        Since:
        100.0.0
        See Also:
        getDisplayName()
      • getDisplayName

        public java.lang.String getDisplayName()
        Gets the English display name of the unit, suitable for displaying in a user interface. Alternatively, use the getPluralDisplayName() method to return the correct display name for the plural of the unit. Use the getAbbreviation() method to return the standard abbreviated form of this name.
        Returns:
        the display name of this Unit
        Since:
        100.0.0
      • getUnitType

        public UnitType getUnitType()
        Gets the type of this unit of measurement, linear, area, or angular. Different types of Unit are used in different measurement functions.
        Returns:
        the type of this Unit
        Since:
        100.0.0
      • getPluralDisplayName

        public java.lang.String getPluralDisplayName()
        Gets the English display name for the plural of this unit of measurement, suitable for displaying in a user interface when the number of units is greater than one. Alternatively, use the getDisplayName() method to return the correct display name for the singular of this unit.
        Returns:
        the plural display name of this Unit
        Since:
        100.0.0
      • fromUnitId

        public static Unit fromUnitId​(int unitId)
        Creates a new Unit instance with the given well-known ID (WKID). Call getUnitType() on the returned Unit to determine the specific UnitType (angular, area, or linear). The supported WKIDs for angular, linear, and area units are documented in the 'Geographic coordinate systems' and 'Projected coordinate system' tables in the developer Guide.
        Parameters:
        unitId - the ID of the new Unit
        Returns:
        a new Unit instance representing the unit of measurement defined by the given ID
        Since:
        100.0.0