Instances of LinearUnit are immutable. Create instances representing the most commonly used linear units (for
example meters or miles) by passing a LinearUnitId
value to the LinearUnit(LinearUnitId)
constructor}. To get the linear unit corresponding to an existing AreaUnit
, pass the AreaUnit to the
LinearUnit(AreaUnit)
constructor.
To use less common linear units not available in the LinearUnitId enum, call the Unit.fromWkid(int)
factory
method passing in a well-known ID of a linear unit.
Different units of measurement have different ID numbers, often known as Well-Known IDs (WKIDs). The WKID
of a LinearUnit is returned by the inherited Unit.getWkid()
method. The supported WKIDs are documented in the
'Projected coordinate systems' table in the developer Guide.
LinearUnits are used in many of the measurement and distance functions of GeometryEngine
.
Use the convertTo(com.esri.arcgisruntime.geometry.LinearUnit, double)
and convertFrom(com.esri.arcgisruntime.geometry.LinearUnit, double)
methods to convert between different linear 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
ConstructorDescriptionLinearUnit
(AreaUnit areaUnit) Creates a new linear unit based on the givenAreaUnit
.LinearUnit
(LinearUnitId unitId) Creates a new linear unit from a LinearUnitId value. -
Method Summary
Modifier and TypeMethodDescriptiondouble
convertFrom
(LinearUnit fromUnit, double value) Converts a value from the given units to the units of this instance.double
convertTo
(LinearUnit toUnit, double value) Converts a value from the units of this instance to the given units.double
fromMeters
(double value) Converts a value from meters to the units of this instance.Gets the LinearIUnitId value for the type of linear units represented by this instance.double
toMeters
(double value) Converts a value from the units of this instance to meters.Methods inherited from class com.esri.arcgisruntime.geometry.Unit
fromWkid, getAbbreviation, getDisplayName, getName, getPluralDisplayName, getUnitType, getWkid
-
Constructor Details
-
LinearUnit
Creates a new linear unit from a LinearUnitId value. Use this constructor to create an instance of LinearUnit representing any of the most commonly used linear units defined in theLinearUnitId
enumeration.To use less common linear units not available in the enumeration, call the
Unit.fromWkid(int)
factory method passing in a well-known ID of a linear unit.- Parameters:
unitId
- the id of the linear unit to create- Since:
- 100.0.0
- See Also:
-
LinearUnit
Creates a new linear unit based on the givenAreaUnit
. Use this method to find the units of linear measurement that correspond to a unit of area measurement. For example, passing in anAreaUnit
of typeLinearUnitId.METERS
will create a LinearUnit of typeAreaUnitId.SQUARE_METERS
.- Parameters:
areaUnit
- the area unit for which to create a new linear unit instance- Since:
- 100.0.0
-
-
Method Details
-
getLinearUnitId
Gets the LinearIUnitId value for the type of linear units represented by this instance.- Returns:
- the linear 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 fromvalue
- the value to convert, infromUnit
units- Returns:
- the value converted to the units represented by this instance
- Throws:
IllegalArgumentException
- if the fromUnit is null- Since:
- 100.0.0
- See Also:
-
convertTo
Converts a value from the units of this instance to the given units.- Parameters:
toUnit
- he units to convert the value tovalue
- 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
-
fromMeters
public double fromMeters(double value) Converts a value from meters to the units of this instance. This is a convenience method for the common task of conversion of linear measurements from meters. Use theconvertFrom(LinearUnit, double)
method to convert values from other linear units.- Parameters:
value
- the value to convert, in meters- Returns:
- the value converted to the units represented by this instance
- Since:
- 100.0.0
-
toMeters
public double toMeters(double value) Converts a value from the units of this instance to meters. This is a convenience method for the common task of conversion of linear measurements to meters. Use theconvertTo(LinearUnit, double)
method to convert values to other linear units.- Parameters:
value
- the value to convert, in the units represented by this instance- Returns:
- the value converted to meters
- Since:
- 100.0.0
-