Avoid Sharp turns and U-turns

Products Used: Directions API & Navigation API


NextBillion.ai’s routing APIs provide a powerful “avoid” parameter to configure routes to suit different business requirements of fleet management. Users can leverage the available options to avoid routing through highways, tolls, service roads and dangerous u-turns or sharp_turns. These features provide a high-degree of flexibility to serve the routing constraints of different vehicles as well as meet business requirements.

We will take a look at a couple of examples to see their impact on the suggested routes.

Avoid U turns

In this example, we will request a directions using the Directions API with

  • An “origin” and “destination” for the pick-up van trip
  • “mode” option set to “car”
  • “avoid” configuration set to “uturn”

Directions API request

1curl --location 'https://api.nextbillion.io/directions/json?origin=38.83377917,-77.11917420&destination=38.83397747,-77.11895667&mode=car&key=<your_api_key>&option=flexible&avoid=uturn'

Directions API response

1{
2 "status": "Ok",
3 "routes": [
4 {
5 "geometry": "gv_lFziuuMAMIiAKkAE_AC]Cq@Ig@I]??CKGUGS??CK??EKM]Wk@??KUCECGKSQ[MWMQQU\\CT?BRBJJT@?VG`BILEHEHGpDcD??LTHRN`@??BH??KJq@r@YX[Z??k@j@]Z??OPc@`@A?ML??UPQLMH?@KJIF??BJFR??FT@HFRBTDRBNBR?BBX?@Db@@BCXBb@HrA",
6 "distance": 1043.755,
7 "duration": 202.879,
8 "start_location": {
9 "latitude": 38.83379,
10 "longitude": -77.11918
11 },
12 "end_location": {
13 "latitude": 38.83397,
14 "longitude": -77.11896
15 },
16 "legs": [
17 {
18 "distance": {

Notice that if the avoid option is removed from the input request the route suggested is quite different and does go through a highway.

Avoid service roads

In this example, we will request step-by-step instructions using the Navigation API to generate a route suitable for a freight truck by avoiding any sharp turns and u-turns. We specify:

  • An “origin” and “destination”
  • “mode” option set to “truck”
  • “avoid” configuration set to “sharp_turn” and “uturn”
1curl --location 'https://api.nextbillion.io/navigation/json?origin=33.3220362,-117.2358124&destination=33.329168,-117.24246&mode=truck&key=<your_api_key>&option=flexible&avoid=service_road'
1{
2 "status": "Ok",
3 "routes": [
4 {
5 "geometry": "gbyp~@feor~EaDH}DQiDYaDk@aDeA_HwCiN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33.322036,
10 "longitude": -117.235812
11 },
12 "end_location": {
13 "latitude": 33.329168,
14 "longitude": -117.24246
15 },
16 "legs": [
17 {
18 "distance": {

Visit product documentation (Directions API | Navigation API) to know more about the available features.