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 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 Details

    • 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 the LinearUnitId 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

      public LinearUnit(AreaUnit areaUnit)
      Creates a new linear unit based on the given AreaUnit. Use this method to find the units of linear measurement that correspond to a unit of area measurement. For example, passing in an AreaUnit of type LinearUnitId.METERS will create a LinearUnit of type AreaUnitId.SQUARE_METERS.
      Parameters:
      areaUnit - the area unit for which to create a new linear unit instance
      Since:
      100.0.0
  • Method Details

    • 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 from
      value - the value to convert, in fromUnit 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

      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 to
      value - 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 the convertFrom(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 the convertTo(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