public double CostPerKilometerAboveSoftMax { get; set; }
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:
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.
[[["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."],[[["\u003cp\u003eThis document provides reference documentation for the \u003ccode\u003eDistanceLimit\u003c/code\u003e class within the Google Cloud Optimization v1 API for .NET.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eDistanceLimit\u003c/code\u003e is used to define a maximum travel distance, which can be a hard limit (\u003ccode\u003eMaxMeters\u003c/code\u003e) or a soft limit (\u003ccode\u003eSoftMaxMeters\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eThe class supports cost calculations for distances that exceed the soft limit via the \u003ccode\u003eCostPerKilometerAboveSoftMax\u003c/code\u003e property, or distances incurred before reaching soft limits with \u003ccode\u003eCostPerKilometerBelowSoftMax\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eMultiple versions of the API are available, with the latest being version 2.6.0.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eDistanceLimit\u003c/code\u003e class inherits from object and implements \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, allowing it to be utilized with other protobuff features.\u003c/p\u003e\n"]]],[],null,["# Cloud Optimization v1 API - Class DistanceLimit (2.6.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.6.0 (latest)](/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.DistanceLimit)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.5.0/Google.Cloud.Optimization.V1.DistanceLimit)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.4.0/Google.Cloud.Optimization.V1.DistanceLimit)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.3.0/Google.Cloud.Optimization.V1.DistanceLimit)\n- [2.2.0](/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.2.0/Google.Cloud.Optimization.V1.DistanceLimit)\n- [2.1.0](/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.1.0/Google.Cloud.Optimization.V1.DistanceLimit)\n- [2.0.0](/dotnet/docs/reference/Google.Cloud.Optimization.V1/2.0.0/Google.Cloud.Optimization.V1.DistanceLimit)\n- [1.0.0-beta01](/dotnet/docs/reference/Google.Cloud.Optimization.V1/1.0.0-beta01/Google.Cloud.Optimization.V1.DistanceLimit) \n\n public sealed class DistanceLimit : IMessage\u003cDistanceLimit\u003e, IEquatable\u003cDistanceLimit\u003e, IDeepCloneable\u003cDistanceLimit\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Cloud Optimization v1 API 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\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e DistanceLimit \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[DistanceLimit](/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.DistanceLimit), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[DistanceLimit](/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.DistanceLimit), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[DistanceLimit](/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1.DistanceLimit), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Optimization.V1](/dotnet/docs/reference/Google.Cloud.Optimization.V1/latest/Google.Cloud.Optimization.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Optimization.V1.dll\n\nConstructors\n------------\n\n### DistanceLimit()\n\n public DistanceLimit()\n\n### DistanceLimit(DistanceLimit)\n\n public DistanceLimit(DistanceLimit other)\n\nProperties\n----------\n\n### CostPerKilometerAboveSoftMax\n\n public double CostPerKilometerAboveSoftMax { get; set; }\n\nCost per kilometer incurred if distance is above `soft_max_meters` limit.\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### CostPerKilometerBelowSoftMax\n\n public double CostPerKilometerBelowSoftMax { get; set; }\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### HasCostPerKilometerAboveSoftMax\n\n public bool HasCostPerKilometerAboveSoftMax { get; }\n\nGets whether the \"cost_per_kilometer_above_soft_max\" field is set\n\n### HasCostPerKilometerBelowSoftMax\n\n public bool HasCostPerKilometerBelowSoftMax { get; }\n\nGets whether the \"cost_per_kilometer_below_soft_max\" field is set\n\n### HasMaxMeters\n\n public bool HasMaxMeters { get; }\n\nGets whether the \"max_meters\" field is set\n\n### HasSoftMaxMeters\n\n public bool HasSoftMaxMeters { get; }\n\nGets whether the \"soft_max_meters\" field is set\n\n### MaxMeters\n\n public long MaxMeters { get; set; }\n\nA hard limit constraining the distance to be at most max_meters. The limit\nmust be nonnegative.\n\n### SoftMaxMeters\n\n public long SoftMaxMeters { get; set; }\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."]]