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, bothsoft_max_metersandcost_per_kilometer_above_soft_maxmust be defined and be nonnegative.
Generated from protobuf messagegoogle.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 tosoft_max_meters, with formula:min(distance_meters, soft_max_meters) / 1000.0 * cost_per_kilometer_below_soft_max.This cost is not supported inroute_distance_limit.
↳ cost_per_kilometer_above_soft_max
float
Cost per kilometer incurred if distance is abovesoft_max_meterslimit. 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 tosoft_max_meters, with
formula:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Cloud Optimization V1 Client - Class DistanceLimit (1.0.5)\n\nVersion latestkeyboard_arrow_down\n\n- [1.0.5 (latest)](/php/docs/reference/cloud-optimization/latest/V1.DistanceLimit)\n- [1.0.4](/php/docs/reference/cloud-optimization/1.0.4/V1.DistanceLimit)\n- [0.7.0](/php/docs/reference/cloud-optimization/0.7.0/V1.DistanceLimit)\n- [0.6.5](/php/docs/reference/cloud-optimization/0.6.5/V1.DistanceLimit)\n- [0.5.1](/php/docs/reference/cloud-optimization/0.5.1/V1.DistanceLimit)\n- [0.4.0](/php/docs/reference/cloud-optimization/0.4.0/V1.DistanceLimit)\n- [0.3.4](/php/docs/reference/cloud-optimization/0.3.4/V1.DistanceLimit)\n- [0.2.0](/php/docs/reference/cloud-optimization/0.2.0/V1.DistanceLimit)\n- [0.1.9](/php/docs/reference/cloud-optimization/0.1.9/V1.DistanceLimit) \nReference documentation and code samples for the Google Cloud Optimization V1 Client class DistanceLimit.\n\nA limit defining a maximum distance which can be traveled. It can be either\nhard or soft.\n\nIf a soft limit is defined, both `soft_max_meters` and\n`cost_per_kilometer_above_soft_max` must be defined and be nonnegative.\n\nGenerated from protobuf message `google.cloud.optimization.v1.DistanceLimit`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Optimization \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getMaxMeters\n\nA hard limit constraining the distance to be at most max_meters. The limit\nmust be nonnegative.\n\n### hasMaxMeters\n\n### clearMaxMeters\n\n### setMaxMeters\n\nA hard limit constraining the distance to be at most max_meters. The limit\nmust be nonnegative.\n\n### getSoftMaxMeters\n\nA soft limit not enforcing a maximum distance limit, but when violated\nresults in a cost which adds up to other costs defined in the model,\nwith the same unit.\n\nIf defined soft_max_meters must be less than max_meters and must be\nnonnegative.\n\n### hasSoftMaxMeters\n\n### clearSoftMaxMeters\n\n### setSoftMaxMeters\n\nA soft limit not enforcing a maximum distance limit, but when violated\nresults in a cost which adds up to other costs defined in the model,\nwith the same unit.\n\nIf defined soft_max_meters must be less than max_meters and must be\nnonnegative.\n\n### getCostPerKilometerBelowSoftMax\n\nCost per kilometer incurred, increasing up to `soft_max_meters`, with\nformula: \n\n min(distance_meters, soft_max_meters) / 1000.0 *\n cost_per_kilometer_below_soft_max.\n\nThis cost is not supported in `route_distance_limit`.\n\n### hasCostPerKilometerBelowSoftMax\n\n### clearCostPerKilometerBelowSoftMax\n\n### setCostPerKilometerBelowSoftMax\n\nCost per kilometer incurred, increasing up to `soft_max_meters`, with\nformula: \n\n min(distance_meters, soft_max_meters) / 1000.0 *\n cost_per_kilometer_below_soft_max.\n\nThis cost is not supported in `route_distance_limit`.\n\n### getCostPerKilometerAboveSoftMax\n\nCost per kilometer incurred if distance is above `soft_max_meters` limit.\n\nThe additional cost is 0 if the distance is under the limit, otherwise the\nformula used to compute the cost is the following: \n\n (distance_meters - soft_max_meters) / 1000.0 *\n cost_per_kilometer_above_soft_max.\n\nThe cost must be nonnegative.\n\n### hasCostPerKilometerAboveSoftMax\n\n### clearCostPerKilometerAboveSoftMax\n\n### setCostPerKilometerAboveSoftMax\n\nCost per kilometer incurred if distance is above `soft_max_meters` limit.\n\nThe additional cost is 0 if the distance is under the limit, otherwise the\nformula used to compute the cost is the following: \n\n (distance_meters - soft_max_meters) / 1000.0 *\n cost_per_kilometer_above_soft_max.\n\nThe cost must be nonnegative."]]