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 Summary
ConstructorDescriptionAreaUnit
(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
Modifier and TypeMethodDescriptiondouble
convertFrom
(AreaUnit fromUnit, double area) Converts a value from the given units to the units of this instance.double
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.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
fromWkid, getAbbreviation, getDisplayName, getName, getPluralDisplayName, getUnitType, getWkid
-
Constructor Details
-
AreaUnit
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.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
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:
-
-
Method Details
-
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
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:
IllegalArgumentException
- iffromUnit
is null- Since:
- 100.0.0
- See Also:
-
convertTo
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:
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
-