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 Deprecated Methods 
      Modifier and Type Method Description
      static Unit fromUnitId​(int unitId)
      Deprecated.
      100.14.0.
      static Unit fromWkid​(int wkid)
      Creates a unit given its well-known ID.
      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()
      Deprecated.
      100.14.0.
      UnitType getUnitType()
      Gets the type of this unit of measurement, linear, area, or angular.
      int getWkid()
      Gets the well-known ID for the unit, or 0 for a custom unit.
      • Methods inherited from class java.lang.Object

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

      • getUnitId

        @Deprecated
        public int getUnitId()
        Deprecated.
        100.14.0. Renamed as getWkid(). Use Unit.getWkid() instead.
        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 available for download from the ArcGIS Developers website at https://developers.arcgis.com/downloads/#csdata. See also Coordinate systems and projections in the ArcGIS Runtime API for Java Guide or Coordinate systems and projections in the ArcGIS Runtime API for Android Guide.

        Returns:
        the well-known ID for the unit, or 0 for a custom unit
        Since:
        100.0.0
      • getWkid

        public int getWkid()
        Gets the well-known ID for the unit, or 0 for a custom unit.
        Returns:
        the well-known ID for the unit, or 0 for a custom unit
        Since:
        100.14.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

        @Deprecated
        public static Unit fromUnitId​(int unitId)
        Deprecated.
        100.14.0. Renamed as fromWkid(int). Use Unit.fromWkid(int) instead.
        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 well-known ID of the unit
        Returns:
        a unit. Depending on the well-known ID given, this may be a LinearUnit, AngularUnit, or AreaUnit.
        Since:
        100.0.0
      • fromWkid

        public static Unit fromWkid​(int wkid)
        Creates a unit given its well-known ID.
        Parameters:
        wkid - the well-known ID of the unit
        Returns:
        a unit. Depending on the well-known ID given, this may be a LinearUnit, AngularUnit, or AreaUnit.
        Since:
        100.14.0