java.lang.Object
com.esri.arcgisruntime.geometry.Unit
Direct Known Subclasses:
AngularUnit, AreaUnit, LinearUnit

public class Unit extends Object
Defines a unit of measurement.

Unit is a base class for measurement classes such as LinearUnit, AngularUnit, and AreaUnit. Many method parameters only accept specific types of measurement to reduce the chance of accidental use of inappropriate values, but some generic methods accept all unit types, such as 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:
  • Method Summary

    Modifier and Type
    Method
    Description
    static Unit
    fromWkid(int wkid)
    Creates a unit given its well-known ID.
    Gets the common abbreviation of the English name of this unit of measurement, for example 'm' for meters.
    Gets the English display name of the unit, suitable for displaying in a user interface.
    Gets the name of this unit of measurement, which may include underscores, for example Nautical_Mile or Minute_Centesimal.
    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.
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 200.1.0, use instanceof to determine the unit type
    int
    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 Details

    • getName

      public String getName()
      Gets the name of this unit of measurement, which may include underscores, for example Nautical_Mile or Minute_Centesimal. To display the name of the unit in a user interface, use getDisplayName(), getPluralDisplayName(), or getAbbreviation() instead.
      Returns:
      the name of this Unit
      Since:
      100.0.0
      See Also:
    • 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 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

      public 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

      @Deprecated(since="200.1.0", forRemoval=true) public UnitType getUnitType()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 200.1.0, use instanceof to determine the unit type
      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 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
    • 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