Class AreaUnit
- 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 theAreaUnit(AreaUnitId)
constructor. To use less common area units not available in the AreaUnitId enum, call theUnit.fromUnitId(int)
factory method passing in a well-known ID of an area unit. To get the area unit corresponding to an existingLinearUnit
, pass the LinearUnit to theAreaUnit(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.getUnitId()
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 theconvertTo(com.esri.arcgisruntime.geometry.AreaUnit, double)
andconvertFrom(com.esri.arcgisruntime.geometry.AreaUnit, double)
methods to convert between different area units. Convenience methods are also available to convertfrom
andto
square meters. All unit names and abbreviations returned fromUnit.getName()
,Unit.getDisplayName()
,Unit.getPluralDisplayName()
, andUnit.getAbbreviation()
are returned in English.- Since:
- 100.0.0
- See Also:
Unit
,AreaUnitId
,GeometryEngine.area(Polygon)
,GeometryEngine.area(Envelope)
-
-
Constructor Summary
Constructors Constructor Description AreaUnit(AreaUnitId unitId)
Creates a new area unit from an AreaUnitId value.AreaUnit(LinearUnit linearUnit)
Creates a new area unit based on the givenLinearUnit
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
convertFrom(AreaUnit fromUnit, double area)
Converts a value from the given units to the units of this instance.double
convertTo(AreaUnit toUnit, double area)
Converts a value from the units of this instance to the given units.double
fromSquareMeters(double area)
Converts a value from square meters to the units of this instance.AreaUnitId
getAreaUnitId()
Gets the AreaIUnitId value for the type of area units represented by this instance.double
toSquareMeters(double area)
Converts a value from the units of this instance to square meters.-
Methods inherited from class com.esri.arcgisruntime.geometry.Unit
fromUnitId, fromWkid, getAbbreviation, getDisplayName, getName, getPluralDisplayName, getUnitId, getUnitType, getWkid
-
-
-
-
Constructor Detail
-
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 theAreaUnitId
enumeration.To use less common area units not available in the enumeration, call the
Unit.fromUnitId(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:
Unit.fromUnitId(int)
-
AreaUnit
public AreaUnit(LinearUnit linearUnit)
Creates a new area unit based on the givenLinearUnit
. Use this method to find the units of area measurement for a 2D Geometry, by passing in the LinearUnits of the geometry'sSpatialReference
. For example, passing in a LinearUnit of typeLinearUnitId.METERS
will create an AreaUnit of typeAreaUnitId.SQUARE_METERS
.- Parameters:
linearUnit
- the linear unit for which to create a new area unit instance- Since:
- 100.0.0
- See Also:
LinearUnit(AreaUnit)
-
-
Method Detail
-
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 fromarea
- the value to convert, infromUnit
units- Returns:
- the value converted to the units represented by this instance
- Throws:
java.lang.IllegalArgumentException
- iffromUnit
is null- Since:
- 100.0.0
- See Also:
fromSquareMeters(double)
-
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 toarea
- the value to convert, in the units represented by this instance- Returns:
- the value converted to the
toUnit
units - Throws:
java.lang.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 theconvertFrom(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 theconvertTo(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
-
-