Skip to content

Detour and Turn Restrictions

Turn restrictions are rules in the map data that specify that vehicles are not allowed to turn from one road into another. Sometimes it is necessary to remove such a rule from the map data or add a new one.

Remove existing Turn Restrictions

To remove a turn restriction you need the geometry and OpenLR code of the restriction. Use the endpoint [GET] /detour/turnrestrictions/{from}/{to} to query all turn restrictions in a bounding box with a diameter of up to 10 km from the map data.

This example selects the turn restrictions in the bounding box from 50.73614, 7.09503 to 50.73756, 7.09732 from the TomTom map data:

curl -X GET "https://api.maptrip.de/v1/detour/turnrestrictions/50.73614%2C7.09503/50.73756%2C7.09732?provider=tomtom" -H "accept: application/json" -H "Authorization: Bearer <token>"

The result is an array with a single turn restriction:

[
  {
    "coordinates": [
      {
        "lat": 50.736862,
        "lon": 7.096421
      },
      {
        "lat": 50.736873,
        "lon": 7.096448
      },
      {
        "lat": 50.736856,
        "lon": 7.096475
      }
    ],
    "openlr": "CwULhCQUQQrlAwDHADw7HA=="
  }
]

Important

To easily visualize turn restrictions in a map, you can use the endpoint [GET] /mapdata/turnrestrictions/geojson/{from}/{to} which returns a GeoJSON feature collection to show in a map.

To ignore this turn restriction in route calculations, it is sent to the endpoint [POST] /detour/file/{fileid}/turnrestriction/remove (without the array!):

curl -X "POST" "https://api.maptrip.de/v1/detour/file/1234/turnrestriction/remove?provider=TomTom" -H "accept: */*" -H "Authorization: Bearer <token>" -H "Content-Type: application/json" -d "{\"coordinates\": [{\"lat\": 50.736862,\"lon\": 7.096421},{\"lat\": 50.736873,\"lon\": 7.096448},{\"lat\": 50.736856,\"lon\": 7.096475}],\"openlr\": \"CwULhCQUQQrlAwDHADw7HA==\"}"

Add new Turn Restrictions

You can also add new turn restrictions to a Detour file. All you need for a turn restriction from road A to road B is an array of three coordinates: One on road A, one on the intersection, and one on road B:

[
  {
    "lat": 50.93838,
    "lon": 6.95039
  },
  {
    "lat": 50.93846,
    "lon": 6.95042
  },
  {
    "lat": 50.93845,
    "lon": 6.95067
  }
]

To create the new turn restriction these arrays have to be sent to the endpoint [POST] /detour/file/{fileid}/turnrestriction in the POST body:

curl -X "POST" "https://api.maptrip.de/v1/detour/file/1234/turnrestriction?provider=TomTom" -H "accept: */*" -H "Authorization: Bearer <token>" -H "Content-Type: application/json" -d "[{\"lat\": 50.93838,\"lon\": 6.95039},{\"lat\": 50.93846,\"lon\": 6.95042},{\"lat\": 50.93845,\"lon\": 6.95067}]"

Querying Turn Restrictions from a Detour File

There are two endpoints to query turn restrictions from a Detour file: [GET] /detour/file/{fileid}/turnrestriction/all returns all turn restrictions from the specified file, /detour/file/{fileid}/turnrestriction/{turnrestrictionid} just the one with the provided ID. Both endpoints return removed turn restrictions and added turn restrictions. See the attribute SegmentType to differentiate between them.

curl -X "GET" "https://api.maptrip.de/v1/detour/file/1234/turnrestriction/all?provider=TomTom" -H "accept: application/json" -H "Authorization: Bearer <token>"

The (abbreviated) output looks like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
[
  {
    "id": 332657,
    "coordinates": [
      {
        "lat": 0,
        "lon": 0
      }
    ],
    "openlr": "CwUKGiQUHTvjBQCNAJMLCg==",
    "attributes": [
      {
        "name": "SegmentType",
        "value": "DeletedManeuver"
      },
      {
        "name": "description",
        "value": "Turn Restriction"
      },
      {
        "name": "editor_coordinates",
        "value": "7.089041611257949,50.73667164620194;7.089090997240569,50.73676541316029;7.088948229793389,50.73681059072612;7.089027314049545,50.73681801282303;7.088948229793389,50.73681059072612;7.0889862983793295,50.73676609656862"
      },
      {
        "name": "modify_MANEUVERS",
        "value": "delete"
      }
    ]
  },
  {
    "id": 332659,
    "coordinates": [
      {
        "lat": 50.73921,
        "lon": 7.084294
      },
      {
        "lat": 50.739085,
        "lon": 7.085129
      },
      {
        "lat": 50.739748,
        "lon": 7.085431
      }
    ],
    "openlr": "CwUJqCQUyzvqAgByADczMQI=",
    "attributes": [
      {
        "name": "SegmentType",
        "value": "AddedManeuver"
      },
      {
        "name": "description",
        "value": "Turn Restriction from Markthallen to Eifelstr."
      },
      {
        "name": "detourEditor_turnArrowCoords",
        "value": "7.084984377973187,50.73909128288187;7.085140865481373,50.73907195930009;7.085197289602957,50.73916633077078;7.0852169801134375,50.73911735228145;7.085197289602957,50.73916633077078;7.085131298284022,50.73913786943742"
      },
      {
        "name": "modify_MANEUVERS",
        "value": "add"
      }
    ]
  }
]

A single turn restriction from this example can be queried with its ID:

curl -X "GET" "https://api.maptrip.de/v1/detour/file/1234/turnrestriction/332657?provider=TomTom" -H "accept: application/json" -H "Authorization: Bearer <token>"

Deleting Turn Restrictions from a file

Both removed turn restrictions and added turn restrictions can be removed from a Detour file using the endpoint [DELETE] /detour/file/{fileid}/turnrestriction/{turnrestrictionid}. For example you can delete the removed turn restriction from the above example using its ID 332657:

curl -X "DELETE" "https://api.maptrip.de/v1/detour/file/1234/turnrestriction/332657?provider=TomTom" -H "accept: application/json" -H "Authorization: Bearer <token>"

Deleting a removed turn restriction restores the original behavior from the map data, i.e. turning is prohibited at this intersection.