# Google Cloud Optimization V1 Client - Class DistanceLimit (1.1.3)

1.1.3 (latest) 1.1.2 1.0.5 0.7.0 0.6.5 0.5.1 0.4.0 0.3.4 0.2.0 0.1.9 Reference documentation and code samples for the Google Cloud Optimization V1 Client class DistanceLimit.

A limit defining a maximum distance which can be traveled. It can be either
hard or soft.

If a soft limit is defined, both `soft_max_meters` and
`cost_per_kilometer_above_soft_max` must be defined and be nonnegative.

Generated from protobuf message `google.cloud.optimization.v1.DistanceLimit`

## Namespace

Google \\ Cloud \\ Optimization \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ max_meters` | `int|string` A hard limit constraining the distance to be at most max_meters. The limit must be nonnegative. |
| `↳ soft_max_meters` | `int|string` A soft limit not enforcing a maximum distance limit, but when violated results in a cost which adds up to other costs defined in the model, with the same unit. If defined soft_max_meters must be less than max_meters and must be nonnegative. |
| `↳ cost_per_kilometer_below_soft_max` | `float` Cost per kilometer incurred, increasing up to `soft_max_meters`, with formula: `min(distance_meters, soft_max_meters) / 1000.0 * cost_per_kilometer_below_soft_max.` This cost is not supported in `route_distance_limit`. |
| `↳ cost_per_kilometer_above_soft_max` | `float` Cost per kilometer incurred if distance is above `soft_max_meters` limit. The additional cost is 0 if the distance is under the limit, otherwise the formula used to compute the cost is the following: `(distance_meters - soft_max_meters) / 1000.0 * cost_per_kilometer_above_soft_max.` The cost must be nonnegative. |

### getMaxMeters

A hard limit constraining the distance to be at most max_meters. The limit
must be nonnegative.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int|string` |   |

### hasMaxMeters

### clearMaxMeters

### setMaxMeters

A hard limit constraining the distance to be at most max_meters. The limit
must be nonnegative.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int|string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getSoftMaxMeters

A soft limit not enforcing a maximum distance limit, but when violated
results in a cost which adds up to other costs defined in the model,
with the same unit.

If defined soft_max_meters must be less than max_meters and must be
nonnegative.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int|string` |   |

### hasSoftMaxMeters

### clearSoftMaxMeters

### setSoftMaxMeters

A soft limit not enforcing a maximum distance limit, but when violated
results in a cost which adds up to other costs defined in the model,
with the same unit.

If defined soft_max_meters must be less than max_meters and must be
nonnegative.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int|string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCostPerKilometerBelowSoftMax

Cost per kilometer incurred, increasing up to `soft_max_meters`, with
formula:

      min(distance_meters, soft_max_meters) / 1000.0 *
      cost_per_kilometer_below_soft_max.

This cost is not supported in `route_distance_limit`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `float` |   |

### hasCostPerKilometerBelowSoftMax

### clearCostPerKilometerBelowSoftMax

### setCostPerKilometerBelowSoftMax

Cost per kilometer incurred, increasing up to `soft_max_meters`, with
formula:

      min(distance_meters, soft_max_meters) / 1000.0 *
      cost_per_kilometer_below_soft_max.

This cost is not supported in `route_distance_limit`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `float` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCostPerKilometerAboveSoftMax

Cost per kilometer incurred if distance is above `soft_max_meters` limit.

The additional cost is 0 if the distance is under the limit, otherwise the
formula used to compute the cost is the following:

      (distance_meters - soft_max_meters) / 1000.0 *
      cost_per_kilometer_above_soft_max.

The cost must be nonnegative.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `float` |   |

### hasCostPerKilometerAboveSoftMax

### clearCostPerKilometerAboveSoftMax

### setCostPerKilometerAboveSoftMax

Cost per kilometer incurred if distance is above `soft_max_meters` limit.

The additional cost is 0 if the distance is under the limit, otherwise the
formula used to compute the cost is the following:

      (distance_meters - soft_max_meters) / 1000.0 *
      cost_per_kilometer_above_soft_max.

The cost must be nonnegative.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `float` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |