Routing API 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 app_id and app_code (see Acquiring Credentials), type of route calculation and whether to take traffic into account.

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: Multiple avoid areas have to be specified using character "!" as separator.
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 routeattributes request parameter is used to obtain notes.

In such case resulting route passes through specified area and 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.