api.automapa.comv3 - all systems normal

Optimise stop order (sync)

Routes.optimize

Reorders up to 10 waypoints into the optimal sequence. Synchronous.

POST/v3/Routes/optimizeapi.automapa.com

Body parameters

BodyTypeDescription
pointsdouble[][] REQUIREDArray of [x, y] coordinates.
typeinteger REQUIRED1 = by time, 2 = by length.
fixedEndboolTreat last point as fixed destination. Default true.
routeobjectavoidTolls / avoidFerries / avoidHighways flags.
objectobjectVehicle configuration (same shape as Routes.route).

Example request

{
    "points": [
        [
            15.1138007,
            53.8820782
        ],
        [
            22.9360664,
            50.3353755
        ],
        [
            17.5527656,
            51.3344674
        ],
        [
            23.1008613,
            53.4851805
        ],
        [
            18.772248,
            51.2245124
        ],
        [
            20.9365546,
            54.2431568
        ],
        [
            14.9819648,
            51.6150267
        ]
    ],
    "type": 1
}

Example response

{
    "result": {
        "order": "0,6,2,4,1,3,5",
        "points": [
            [
                15.1138007,
                53.8820782
            ],
            [
                14.9819648,
                51.6150267
            ],
            [
                17.5527656,
                51.3344674
            ],
            [
                18.772248,
                51.2245124
            ],
            [
                22.9360664,
                50.3353755
            ],
            [
                23.1008613,
                53.4851805
            ],
            [
                20.9365546,
                54.2431568
            ]
        ],
        "sections": [
            {
                "x": 15.1138007,
                "y": 53.8820782,
                "eta": 0,
                "dist": 0
            },
            {
                "x": 14.9897812,
                "y": 51.6133711,
                "eta": 236,
                "dist": 355237
            },
            {
                "x": 17.5544531,
                "y": 51.3357187,
                "eta": 405,
                "dist": 602441
            }
        ]
    }
}

result fields

result fieldsTypeDescription
orderstringComma-separated optimal indices, e.g. "0,6,2,4,1,3,5".
pointsdouble[][]Reordered point list.
sections[].xdoubleGPS x.
sections[].ydoubleGPS y.
sections[].etaintegerCumulative ETA from start (min).
sections[].distintegerCumulative distance from start (m).