Optimization

TSS

Solves a Traveling Salesman Problem (TSP) using the coordinates provided and returns the most optimal visiting order, original order, route geometry, and total distance and time taken. The route starts and ends at the first coordinate.

GET
/api/route/tss

Solves a Traveling Salesman Problem (TSP) using the coordinates provided and returns the most optimal visiting order, original order, route geometry, and total distance and time taken. The route starts and ends at the first coordinate.

Query Parameters

json*string

The stops, as [{lat,lng},{lat,lng},…]. The first stop is where the round trip starts and ends. Up to 10 stops.

apiKey*string

A valid API key for authentication and access control.

Response Body

The best visiting order as a round trip from the first stop.

application/json
  1. response
msg?string
best_order?array<>

Stops in visiting order, starting and ending at the first stop. original_index is the position in the list you sent.

original_order?array<>

Stops in the order you sent them.

total_distance?number

Length of the round trip in kilometers.

time_taken?number

Travel time for the round trip in seconds.

Direction?array<array<number>>

The route as [lat, lng] points. Note the capital D.

curl -X GET 'https://mapapi.gebeta.app/api/route/tss?json=%5B%7B8.987685259188599%2C38.764792722654455%7D%2C%7B8.9879443%2C38.7651287%7D%2C%7B9.087685259188599%2C38.764792722654455%7D%5D&apiKey=your_api_key_here'
{  "msg": "Ok",  "best_order": [    {      "lat": 9.056218,      "lon": 38.705173    },    {      "lat": 9.030789,      "lon": 38.730922,      "index": 1,      "original_index": 1    },    {      "lat": 9.047741,      "lon": 38.756671,      "index": 2,      "original_index": 2    },    {      "lat": 9.056218,      "lon": 38.705173,      "index": 3,      "original_index": 3    }  ],  "original_order": [    {      "lat": 9.056218147277832,      "lon": 38.70517349243164    },    {      "lat": 9.030789375305176,      "lon": 38.73092269897461,      "index": 1    },    {      "lat": 9.047741889953613,      "lon": 38.75667190551758,      "index": 2    },    {      "lat": 9.056218147277832,      "lon": 38.70517349243164,      "index": 3    }  ],  "total_distance": 19.698,  "time_taken": 2774.798,  "Direction": [    [      9.055978,      38.704943    ]  ]}