Class LinearUnit
- java.lang.Object
-
- com.esri.arcgisruntime.geometry.Unit
-
- com.esri.arcgisruntime.geometry.LinearUnit
-
public final class LinearUnit extends Unit
Indicates the units of a linear distance, for example the units of a projected spatial reference, or line measurement operation.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 theLinearUnit(LinearUnitId)
constructor}. To get the linear unit corresponding to an existingAreaUnit
, pass the AreaUnit to theLinearUnit(AreaUnit)
constructor. To use less common linear units not available in the LinearUnitId enum, call theUnit.fromUnitId(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.getUnitId()
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 theconvertTo(com.esri.arcgisruntime.geometry.LinearUnit, double)
andconvertFrom(com.esri.arcgisruntime.geometry.LinearUnit, double)
methods to convert between different linear 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
,LinearUnitId
,GeometryEngine.length(Polyline)
,GeometryEngine.distanceBetween(Geometry, Geometry)
-
-
Constructor Summary
Constructors Constructor Description LinearUnit(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
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.LinearUnitId
getLinearUnitId()
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
fromUnitId, fromWkid, getAbbreviation, getDisplayName, getName, getPluralDisplayName, getUnitId, getUnitType, getWkid
-
-
-
-
Constructor Detail
-
LinearUnit
public LinearUnit(LinearUnitId unitId)
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.fromUnitId(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:
Unit.fromUnitId(int)
-
LinearUnit
public LinearUnit(AreaUnit areaUnit)
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 a AreaUnit of typeLinearUnitId.METERS
will create an LinearUnit of typeAreaUnitId.SQUARE_METERS
.- Parameters:
areaUnit
- the area unit for which to create a new linear unit instance- Since:
- 100.0.0
-
-
Method Detail
-
getLinearUnitId
public LinearUnitId 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
public double convertFrom(LinearUnit fromUnit, double value)
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:
java.lang.IllegalArgumentException
- if the fromUnit is null- Since:
- 100.0.0
- See Also:
fromMeters(double)
-
convertTo
public double convertTo(LinearUnit toUnit, double value)
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:
java.lang.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
-
-