Routing API v7 Developer's Guide

Enabling a Truck Route Violating a Restriction

A position derived from a postal code or a city is imprecise and may be located in the area forbidden for a given truck. To calculate a truck route using imprecise positions, like an approximate city-to-city route, use the calculateroute service specifying the truck restriction penalty type soft (truckRestrictionPenalty=soft). Note that the soft penalty requires the route notes to be enabled in the response.

You also have to specify an apiKey or app_id and app_code if you are using the app_id/app_code authentication (see Acquiring Credentials).

In the following example we request a route for a truck which is 5 meters high. The truckRestrictionsPenalty is set to soft and notes are enabled both in the routeAttributes and maneuverAttributes. The route ends on a link forbidden for vehicles higher than 4 meters. The returned route for the given truck uses this link. The response includes notes indicating that the route violates the truck restriction.

https://route.ls.hereapi.com/routing/7.2/calculateroute.json
?apiKey={YOUR_API_KEY}
&mode=fastest;truck
&waypoint0=geo!52.534924,13.199499
&waypoint1=geo!52.534614,13.199362
&height=5
&truckRestrictionPenalty=soft
&routeattributes=notes
&maneuverattributes=notes
Note: This example uses a HERE API Key to authenticate your request. For information on other possible options, see Authentication Guide. For examples of how to use the other authentication options with the Routing API v7, see Authentication Examples.

Example response for route violating truck restriction


<Route>
...
  <Leg>
    ...
    <Maneuver ...>
      ...
      <Note>
        <Type>violation</Type>
        <Code>truckRestriction</Code>
      </Note>
    </Maneuver>
    ...
  </Leg>

  <Note>
    <Type>violation</Type>
    <Code>routingOptionViolated</Code>
    <Text>truckRestriction</Text>
  </Note>
</Route>