Class GeoprocessingLinearUnit


  • public final class GeoprocessingLinearUnit
    extends GeoprocessingParameter

    Corresponds to GPLinearUnit parameter type in the service REST specification.

    Geoprocessing tasks support a set of linear units defined in GeoprocessingLinearUnit.Unit.

    When a linear unit parameter is created with one of the supported GeoprocessingLinearUnit.Unit the value is sent to the service using defined linear unit type.

    When a geoprocessing linear unit parameter is created with a LinearUnit, the value is converted to meters if the type is not supported. For example if the provided linear unit is international miles, the value is converted to meters since only US Survey Miles unit is supported in geoprocessing. After a geoprocessing linear unit is created, the used linear unit type can be checked by calling getLinearUnit().

    When a geoprocessing linear unit is created with a supported linear unit, then no conversion takes place and the value is sent to the service using the defined type.

    When a geoprocessing linear unit is returned as a output parameter, you can get the LinearUnit using the getLinearUnit() method.

    Since:
    100.0.0
    • Constructor Detail

      • GeoprocessingLinearUnit

        public GeoprocessingLinearUnit()
        Creates an instance. Defaults to unit of meters and distance of 0.0.
        Since:
        100.0.0
      • GeoprocessingLinearUnit

        public GeoprocessingLinearUnit​(double distance)
        Creates an instance. Defaults to unit of meters.
        Parameters:
        distance - the distance value
        Since:
        100.0.0
      • GeoprocessingLinearUnit

        public GeoprocessingLinearUnit​(LinearUnit linearUnit)
        Creates an instance. The distance defaults to 0.0. Note that if the given linear unit does not correspond to any of the values in GeoprocessingLinearUnit.Unit, the unit will be changed to meters. Use getLinearUnit() to find out the actual unit being used and any distance set with setDistance(double) will be interpreted as being in that unit.
        Parameters:
        linearUnit - the distance unit
        Throws:
        IllegalArgumentException - if linearUnit is null
        Since:
        100.0.0
      • GeoprocessingLinearUnit

        public GeoprocessingLinearUnit​(LinearUnitId linearUnitId)
        Creates an instance. The distance defaults to 0.0. Note that if the given linear unit does not correspond to any of the values in GeoprocessingLinearUnit.Unit, the unit will be changed to meters.
        Parameters:
        linearUnitId - the distance unit
        Throws:
        IllegalArgumentException - if linearUnitId is null
        Since:
        100.0.0
      • GeoprocessingLinearUnit

        public GeoprocessingLinearUnit​(double distance,
                                       GeoprocessingLinearUnit.Unit unit)
        Creates an instance with a distance and a directly supported unit - no conversion will be applied to the distance value.
        Parameters:
        distance - the distance value
        unit - the unit
        Throws:
        IllegalArgumentException - if unit is null
        Since:
        100.0.0
      • GeoprocessingLinearUnit

        public GeoprocessingLinearUnit​(double distance,
                                       LinearUnit linearUnit)
        Creates an instance. Note that if the given linear unit does not correspond to any of the values in GeoprocessingLinearUnit.Unit, the unit will be changed to meters. This means that the distance property will return a different value to that set.
        Parameters:
        distance - the distance value
        linearUnit - the distance unit
        Throws:
        IllegalArgumentException - if linearUnit is null
        Since:
        100.0.0
      • GeoprocessingLinearUnit

        public GeoprocessingLinearUnit​(double distance,
                                       LinearUnitId linearUnitId)
        Creates an instance. Note that if the given linear unit does not correspond to any of the values in GeoprocessingLinearUnit.Unit, the unit will be changed to meters. This means that the distance property will return a different value to that set.
        Parameters:
        distance - the distance value
        linearUnitId - the ID of the distance unit
        Throws:
        IllegalArgumentException - if linearUnitId is null
        Since:
        100.0.0
    • Method Detail

      • getLinearUnit

        public LinearUnit getLinearUnit()
        Returns the linear unit that is used by the Geoprocessing service. This will be a linear unit that corresponds to an entry in GeoprocessingLinearUnit.Unit.
        Returns:
        the linear unit
        Since:
        100.0.0
      • setUnit

        public void setUnit​(GeoprocessingLinearUnit.Unit unit)
        Sets the unit. Changing the unit does not cause the distance value to be converted to the new unit.
        Parameters:
        unit - the unit to set
        Throws:
        IllegalArgumentException - if linearUnit is null
        Since:
        100.0.0
      • getDistance

        public double getDistance()
        Returns the distance value.
        Returns:
        the distance
        Since:
        100.0.0
      • setDistance

        public void setDistance​(double distance)
        Sets the distance value. The distance will be interpreted to be in the unit returned by getLinearUnit().
        Parameters:
        distance - the distance
        Since:
        100.0.0