Routing API v7 Developer's Guide

Requesting a Route Avoiding an Area

To calculate directions between two coordinates without traveling through a specified area, use the CalculateRouteRequest service specifying the start (waypoint0), endpoint (waypoint1) and area to avoid (avoidareas as a rectangular area, defining the top left and bottom right corners). The string geo! indicates that you are specifying each point using latitude and longitude.

Note that you also have to specify an apiKey or app_id and app_code if you are using the app_id/app_code authentication (see the Identity & Access Management Developer Guide), type of route calculation and whether to take traffic into account.

Note: These examples use a HERE API Key to authenticate your request. For the available authentication options, see the Identity & Access Management Developer Guide.

The following example calculates a route from the Westin Grand hotel (52.516858379, 13.3884717) at Unter den Linden in Berlin to the Staatsoper in Berlin (52.51733824, 13.394678415) avoiding passing the Deutsche Guggenheim (52.51704771, 13.39131492) by specifying a rectangle that contains it (top left 52.517100760,13.3905424488 and bottom right 52.5169701849,13.391808451), and also the fastest route for a car without taking traffic conditions into account.
Figure 1. Example of route avoiding an area
In the following example multiple rectangular areas are specified. The query results in a route avoiding all specified areas.
Note: You need to specify multiple avoid areas and use the "!" character as a separator. You can specify up to 20 areas to avoid.
Figure 2. Example of route avoiding multiple areas

In the following example, an area is specified in a way that it cannot be avoided. Note that the routeattributes request parameter is used to obtain notes.

In this case, the resulting route passes through the specified area and the JSON output contains a "violation" note.

note : [ <1 elem>
  0 : {
    type : "violation"
    code : "routingOptionViolated"
    text : "blockedRoad"
Figure 3. Example of route not possible to avoid specified area