Avoid Sharp Turns and U-turns

Products Used: Directions API & Navigation API


The avoid feature in NextBillion’s.ai routing APIs ensures that the trucks don’t need to take the routes with impractical u-turns or other sharp turns. This can protect against potentially dangerous maneuvers and subsequent repair costs. Depending on the information needed, users can use this feature either in NextBillion.ai’s Directions API to get desired route directions along with ETA and distance information, or they can also use Navigation API to get turn-by-turn navigation instructions as well along with other information about the route.

Following is a sample Directions API request with following parameters:

  • A pair of origin & destination locations

  • mode option set to truck

  • option property set to flexible

  • avoid option set to uturn and sharp_turn. Users can go with a single value as well.

Directions API request:

1curl --location 'https://api.nextbillion.io/directions/json?origin=39.30420612,-76.62259137&destination=39.30386899,-76.62362166&option=flexible&mode=truck&key=<your_api_key>&avoid=uturn|sharp_turn'

Directions API response:

Notice that the Direction service suggests a route with a U-turn if the avoid parameter is not used for the given pair of origin and destination pairs.

1{
2 "status": "Ok",
3 "routes": [
4 {
5 "geometry": "gr{nFdjtrMDb@BRBNDTRzA??DP??BT@@D\\F\\FV?BFPJRHLDDRXhA`BZf@PS??vAqBJOPWBCT[LQ??LOz@kANSz@iA??NRND??nBhC??e@n@uAhB?@e@n@UXA?mB`CA@Y\\??W[S]MOCEaAuAW[??i@u@_@g@MSQWEGEKGMEKEQ??CQAI??Mu@",
6 "distance": 1155.583,
7 "duration": 211.077,
8 "start_location": {
9 "latitude": 39.3042,
10 "longitude": -76.62259
11 },
12 "end_location": {
13 "latitude": 39.30386,
14 "longitude": -76.62362
15 },
16 "legs": [
17 {
18 "distance": {

Let’s take a look at how a Navigation API call would look like for the exact same parameters as the above example.

1curl --location 'https://api.nextbillion.io/navigation/json?origin=39.30420612,-76.62259137&destination=39.30386899,-76.62362166&option=flexible&mode=truck&key=<your_api_key>&avoid=uturn|sharp_turn'

Notice that this API only responds with the turn-by-turn navigation instructions along with ETA and distance information for a route taken while avoiding roads with tolls.

1{
2 "status": "Ok",
3 "routes": [
4 {
5 "geometry": "q_}}iAzntcqC`A`Jh@fEh@fDr@|EhEr[??p@lDBHt@|E@FfAhHfApHnAxFJXpAvDlB`ElBtCl@z@`E~FpVv]lGnKpDcEDExZyb@rBuCtDuFZe@|EqGvC{D??zByCbR}VvCcExQ{UDExChEfD~@@?`b@|i@??cK`NuYd`@EDwJbNiF|FAB}a@|g@CBiGvHEDcFcHwEiHeCeDk@u@oSyYkF{GAAgLoOuH}KsCaEkDcF{@uAiAuBeAiCy@eCw@kD?Ao@kD[qB?AcCwO",
6 "distance": 1155.583,
7 "duration": 211.077,
8 "start_location": {
9 "latitude": 39.304201,
10 "longitude": -76.62259
11 },
12 "end_location": {
13 "latitude": 39.30386,
14 "longitude": -76.623618
15 },
16 "legs": [
17 {
18 "distance": {

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