Routing API Developer's Guide

Requesting a Time Aware Route with Itinerary Warnings

To calculate directions that take into account time dependent restrictions, use the CalculateRouteRequest service specifying the start (waypoint0), the destination (waypoint1), and the departure time. Note that you also have to specify an app_id and app_code (see Acquiring Credentials ), type of route calculation and whether to take traffic into account.

The following example requests the fastest route for a car in the presence of a reversible lane without specifying the departure time (trip planning mode).

https://route.ls.hereapi.com/routing/7.2/calculateroute.json
?waypoint0=geo!stopOver!47.47524,-122.20498
&waypoint1=geo!stopOver!47.757346996393736,-122.34468922274789
&routeattributes=sh,bb
&legattributes=li
&maneuverattributes=all
&language=en-us
&mode=fastest;car
&metricSystem=metric
&combineChange=true
&jsonAttributes=41
&apikey={YOUR_APIKEY}
&verboseMode=0
Note: This example uses a HERE API Key to authenticate your request. For information on other possible options, see https://developer.here.com/documentation/authentication. For examples of how to use the other authentication options with the Routing API, see Authentication Examples.

IF you do not specify the departure time, the exact time of entry to the time restricted lane is not known. In such cases, the JSON output contains a "restriction" warning note and time restricted maneuvers are allowed.

note : [ <1 elem>
  0 : {
    type : "restriction"
    code : "timeDependentRestriction"
    text : "Road may be temporarily closed"
  }
]
Figure 1. Example of allowed time restricted maneuver in trip planning mode

The same behaviour is applied when the departure time is set to 2014-07-14T14:02:00, which is outside the forbidden period.

If the departure time is set to 2014-07-14T07:02:00, which is inside the forbidden period, no warning is provided and the route avoids the maneuver.

Figure 2. Example of avoided time restricted maneuver when departure time is inside the forbidden period.

To force routing through a restricted reversible lane (by setting a waypoint exactly on this lane) and set the departure time inside the forbidden period results in a "violation" warning and a route that tries to avoid the restricted segment.

note : [ <1 elem>
  0 : {
    type : "violation"
    code : "timeDependentRestriction"
    text : "Road may be temporarily closed"
  }
]
Figure 3. Example of violated time dependent restriction