Trip

Example 3 – Route bypassing restricted areas

When there are restriction areas registered in the Restriction Zones API, you can use them as arguments in the restrictionZones parameter. The route will then deviate from these areas.

If there is a stopping point within the restriction area, Trip API will serve the stopping point via the path with the least overlap with the area.

The image below shows an example of a direct route between two points. We want to create two restriction zones in the areas highlighted in red.

To make the Trip API deviate from these areas, the parameter restrictionZones must be filled in with the two restriction zones created earlier:

{
     "calculationMode": "THE_FASTEST",
     "points": [
        {
            "siteId": "Point 1-Vila-Galvao",
            "latitude": -23.454521350080835,
            "longitude": -46.57105028629302
        },
        {
            "siteId": "Point 2-Aricanduva",
            "latitude": -23.52933420411184,
            "longitude": -46.55395656824112
        }
    ],
    "restrictionZones": [
        "SP_BR381_90_km_Alt_Esq_5_3_Cen_5_45_Dir_5_6",
        "SP_BR381_87_km_Alt_Esq_6_7_Cen_6_7_Dir_6_7"
    ]
}

The result can be seen on the map below:

You can see the full response below, with the coordinates coded as the object:

{
    "id": "60746c7596b979629d88fbe3",
    "clientId": "maplink",
    "totalDistance": 10557,
    "totalNominalDuration": 665,
    "averageSpeed": 57.15,
    "legs": [
        {
            "distance": 10557,
            "nominalDuration": 665,
            "averageSpeed": 57.15,
            "points": [
                {
                    "latitude": -23.454529685684275,
                    "longitude": -46.57101803113189
                },
                {
                    "latitude": -23.455378,
                    "longitude": -46.571206
                },
                {
                    "latitude": -23.456685,
                    "longitude": -46.571394
                },
                {
                    "latitude": -23.457933,
                    "longitude": -46.571506
                },
                {
                    "latitude": -23.465821,
                    "longitude": -46.571676
                },
                {
                    "latitude": -23.466442,
                    "longitude": -46.571655
                },
                {
                    "latitude": -23.466704,
                    "longitude": -46.571613
                },
                {
                    "latitude": -23.467036,
                    "longitude": -46.571523
                },
                {
                    "latitude": -23.467228,
                    "longitude": -46.571455
                },
                {
                    "latitude": -23.467426,
                    "longitude": -46.571359
                },
                {
                    "latitude": -23.467632,
                    "longitude": -46.571239
                },
                {
                    "latitude": -23.467869,
                    "longitude": -46.571073
                },
                {
                    "latitude": -23.46809,
                    "longitude": -46.57089
                },
                {
                    "latitude": -23.468273,
                    "longitude": -46.570707
                },
                {
                    "latitude": -23.468437,
                    "longitude": -46.570512
                },
                {
                    "latitude": -23.46858,
                    "longitude": -46.570319
                },
                {
                    "latitude": -23.468724,
                    "longitude": -46.570088
                },
                {
                    "latitude": -23.472334,
                    "longitude": -46.563526
                },
                {
                    "latitude": -23.472647,
                    "longitude": -46.563086
                },
                {
                    "latitude": -23.473181,
                    "longitude": -46.562443
                },
                {
                    "latitude": -23.474189,
                    "longitude": -46.561426
                },
                {
                    "latitude": -23.47474,
                    "longitude": -46.56104
                },
                {
                    "latitude": -23.475011,
                    "longitude": -46.56089
                },
                {
                    "latitude": -23.475461,
                    "longitude": -46.560705
                },
                {
                    "latitude": -23.47566,
                    "longitude": -46.560632
                },
                {
                    "latitude": -23.477506,
                    "longitude": -46.560265
                },
                {
                    "latitude": -23.478013,
                    "longitude": -46.560216
                },
                {
                    "latitude": -23.489297,
                    "longitude": -46.55944
                },
                {
                    "latitude": -23.491673,
                    "longitude": -46.559396
                },
                {
                    "latitude": -23.492423,
                    "longitude": -46.559429
                },
                {
                    "latitude": -23.494951,
                    "longitude": -46.559578
                },
                {
                    "latitude": -23.495221,
                    "longitude": -46.559638
                },
                {
                    "latitude": -23.49644,
                    "longitude": -46.559807
                },
                {
                    "latitude": -23.496909,
                    "longitude": -46.559907
                },
                {
                    "latitude": -23.497132,
                    "longitude": -46.55997
                },
                {
                    "latitude": -23.49739,
                    "longitude": -46.560054
                },
                {
                    "latitude": -23.497557,
                    "longitude": -46.560125
                },
                {
                    "latitude": -23.497823,
                    "longitude": -46.560257
                },
                {
                    "latitude": -23.498176,
                    "longitude": -46.560481
                },
                {
                    "latitude": -23.498438,
                    "longitude": -46.560682
                },
                {
                    "latitude": -23.498649,
                    "longitude": -46.560864
                },
                {
                    "latitude": -23.49878,
                    "longitude": -46.560998
                },
                {
                    "latitude": -23.499346,
                    "longitude": -46.561699
                },
                {
                    "latitude": -23.50041,
                    "longitude": -46.563157
                },
                {
                    "latitude": -23.500543,
                    "longitude": -46.563314
                },
                {
                    "latitude": -23.500713,
                    "longitude": -46.56349
                },
                {
                    "latitude": -23.503395,
                    "longitude": -46.567293
                },
                {
                    "latitude": -23.504024,
                    "longitude": -46.568062
                },
                {
                    "latitude": -23.50545,
                    "longitude": -46.569615
                },
                {
                    "latitude": -23.505634,
                    "longitude": -46.569902
                },
                {
                    "latitude": -23.506817,
                    "longitude": -46.571473
                },
                {
                    "latitude": -23.506896,
                    "longitude": -46.571594
                },
                {
                    "latitude": -23.507072,
                    "longitude": -46.571509
                },
                {
                    "latitude": -23.507196,
                    "longitude": -46.571456
                },
                {
                    "latitude": -23.508001,
                    "longitude": -46.571201
                },
                {
                    "latitude": -23.508212,
                    "longitude": -46.571172
                },
                {
                    "latitude": -23.508261,
                    "longitude": -46.57117
                },
                {
                    "latitude": -23.513415,
                    "longitude": -46.571337
                },
                {
                    "latitude": -23.513461,
                    "longitude": -46.571353
                },
                {
                    "latitude": -23.51349,
                    "longitude": -46.571382
                },
                {
                    "latitude": -23.513503,
                    "longitude": -46.571425
                },
                {
                    "latitude": -23.513508,
                    "longitude": -46.571459
                },
                {
                    "latitude": -23.513501,
                    "longitude": -46.571531
                },
                {
                    "latitude": -23.51369,
                    "longitude": -46.571352
                },
                {
                    "latitude": -23.513908,
                    "longitude": -46.571159
                },
                {
                    "latitude": -23.513972,
                    "longitude": -46.571109
                },
                {
                    "latitude": -23.51492,
                    "longitude": -46.570202
                },
                {
                    "latitude": -23.515991,
                    "longitude": -46.569284
                },
                {
                    "latitude": -23.516111,
                    "longitude": -46.569171
                },
                {
                    "latitude": -23.516164,
                    "longitude": -46.569125
                },
                {
                    "latitude": -23.516657,
                    "longitude": -46.568638
                },
                {
                    "latitude": -23.51691,
                    "longitude": -46.568476
                },
                {
                    "latitude": -23.517923,
                    "longitude": -46.56852
                },
                {
                    "latitude": -23.517961,
                    "longitude": -46.568508
                },
                {
                    "latitude": -23.517994,
                    "longitude": -46.568493
                },
                {
                    "latitude": -23.518133,
                    "longitude": -46.568396
                },
                {
                    "latitude": -23.518172,
                    "longitude": -46.568352
                },
                {
                    "latitude": -23.518209,
                    "longitude": -46.568297
                },
                {
                    "latitude": -23.518277,
                    "longitude": -46.568186
                },
                {
                    "latitude": -23.518283,
                    "longitude": -46.568045
                },
                {
                    "latitude": -23.518232,
                    "longitude": -46.56793
                },
                {
                    "latitude": -23.518202,
                    "longitude": -46.567871
                },
                {
                    "latitude": -23.518167,
                    "longitude": -46.567815
                },
                {
                    "latitude": -23.518099,
                    "longitude": -46.56776
                },
                {
                    "latitude": -23.51802,
                    "longitude": -46.567719
                },
                {
                    "latitude": -23.517944,
                    "longitude": -46.567699
                },
                {
                    "latitude": -23.517799,
                    "longitude": -46.567682
                },
                {
                    "latitude": -23.517514,
                    "longitude": -46.567663
                },
                {
                    "latitude": -23.517671,
                    "longitude": -46.562146
                },
                {
                    "latitude": -23.517748,
                    "longitude": -46.561831
                },
                {
                    "latitude": -23.517779,
                    "longitude": -46.561738
                },
                {
                    "latitude": -23.517791,
                    "longitude": -46.561686
                },
                {
                    "latitude": -23.518245,
                    "longitude": -46.561393
                },
                {
                    "latitude": -23.518648,
                    "longitude": -46.561211
                },
                {
                    "latitude": -23.519091,
                    "longitude": -46.560954
                },
                {
                    "latitude": -23.52188,
                    "longitude": -46.559088
                },
                {
                    "latitude": -23.522084,
                    "longitude": -46.55894
                },
                {
                    "latitude": -23.523725,
                    "longitude": -46.557836
                },
                {
                    "latitude": -23.524892,
                    "longitude": -46.557144
                },
                {
                    "latitude": -23.525163,
                    "longitude": -46.556963
                },
                {
                    "latitude": -23.526088,
                    "longitude": -46.556228
                },
                {
                    "latitude": -23.526439,
                    "longitude": -46.555879
                },
                {
                    "latitude": -23.526559,
                    "longitude": -46.555777
                },
                {
                    "latitude": -23.529327635811413,
                    "longitude": -46.55394657567329
                }
            ]
        }
    ],
    "source": "MAPLINK",
    "createdAt": 1618242678188
}