java.lang.Object
com.esri.arcgisruntime.geometry.Unit
com.esri.arcgisruntime.geometry.AreaUnit

public final class AreaUnit extends Unit
Indicates the units of an area measurement operation.

Instances of AreaUnit are immutable. Create instances representing the most commonly used area units (for example acres or square meters) by passing an AreaUnitId value to the AreaUnit(AreaUnitId) constructor. To use less common area units not available in the AreaUnitId enum, call the Unit.fromWkid(int) factory method passing in a well-known ID of an area unit. To get the area unit corresponding to an existing LinearUnit, pass the LinearUnit to the AreaUnit(LinearUnit) constructor.

Different units of measurement have different ID numbers, often known as Well-Known IDs (WKIDs). The WKID of an AreaUnit is returned by the inherited Unit.getWkid() method. The supported WKIDs are documented in the 'Projected coordinate systems' table in the developer Guide.

AreaUnits are used in area measurement functions of GeometryEngine}. Use the convertTo(com.esri.arcgisruntime.geometry.AreaUnit, double) and convertFrom(com.esri.arcgisruntime.geometry.AreaUnit, double) methods to convert between different area units. Convenience methods are also available to convert from and to square meters. All unit names and abbreviations returned from Unit.getName(), Unit.getDisplayName(), Unit.getPluralDisplayName(), and Unit.getAbbreviation() are returned in English.

Since:
100.0.0
See Also:
  • Constructor Details

    • AreaUnit

      public AreaUnit(AreaUnitId unitId)
      Creates a new area unit from an AreaUnitId value. Use this constructor to create an instance of AreaUnit representing any of the most commonly used area units defined in the AreaUnitId enumeration.

      To use less common area units not available in the enumeration, call the Unit.fromWkid(int) factory method passing in a well-known ID of an area unit.

      Parameters:
      unitId - the id of the area unit to create
      Since:
      100.0.0
      See Also:
    • AreaUnit

      public AreaUnit(LinearUnit linearUnit)
      Creates a new area unit based on the given LinearUnit. Use this method to find the units of area measurement for a 2D Geometry, by passing in the LinearUnits of the geometry's SpatialReference. For example, passing in a LinearUnit of type LinearUnitId.METERS will create an AreaUnit of type AreaUnitId.SQUARE_METERS.
      Parameters:
      linearUnit - the linear unit for which to create a new area unit instance
      Since:
      100.0.0
      See Also:
  • Method Details

    • getAreaUnitId

      public AreaUnitId getAreaUnitId()
      Gets the AreaIUnitId value for the type of area units represented by this instance.
      Returns:
      the area unit ID
      Since:
      100.0.0
    • convertFrom

      public double convertFrom(AreaUnit fromUnit, double area)
      Converts a value from the given units to the units of this instance.
      Parameters:
      fromUnit - the units to convert from
      area - the value to convert, in fromUnit units
      Returns:
      the value converted to the units represented by this instance
      Throws:
      IllegalArgumentException - if fromUnit is null
      Since:
      100.0.0
      See Also:
    • convertTo

      public double convertTo(AreaUnit toUnit, double area)
      Converts a value from the units of this instance to the given units.
      Parameters:
      toUnit - the units to convert the value to
      area - the value to convert, in the units represented by this instance
      Returns:
      the value converted to the toUnit units
      Throws:
      IllegalArgumentException - if the toUnit is null
      Since:
      100.0.0
    • fromSquareMeters

      public double fromSquareMeters(double area)
      Converts a value from square meters to the units of this instance. This is a convenience method for the common task of conversion of area measurements from square meters. Use the convertFrom(AreaUnit, double) method to convert values from other area units.
      Parameters:
      area - the value to convert, in square meters
      Returns:
      the value converted to the units represented by this instance
      Since:
      100.0.0
    • toSquareMeters

      public double toSquareMeters(double area)
      Converts a value from the units of this instance to square meters. This is a convenience method for the common task of conversion of area measurements to square meters. Use the convertTo(AreaUnit, double) method to convert values to other area units.
      Parameters:
      area - the value to convert, in the units represented by this instance
      Returns:
      the value converted to square meters
      Since:
      100.0.0