Travelling Salesman Problem /tsp
Determining the order of visiting points.
Request format
https://api.visicom.ua/data-api/5.0/core/tsp.json?[waypoints][&round_trip][&locks][&mode][&key][&callback]
Request parameters
| Parameter | Description |
|---|---|
waypoints|w | Array of points for calculation. Maximum 50. The first point is fixed as the start. The point can be specified by object ID or by latitude and longitude in the format lng,lat. Comma , is used as a separator when using IDs. Pipe | is used as a separator when using latitude and longitude. |
round_trip|rt | Boolean value indicating whether to return to the first point. If false, the last point in the waypoints array is considered the finish. Default is true. |
locks|l | Array of coordinates for blocked passages. Each block can be specified by object ID or by latitude and longitude in the format lng,lat. For driving routes, it prevents routing through the blocked location. Relevant only for driving and driving-shortest modes. Comma , separates points when using IDs; pipe | separates points when using lat/lng. |
mode|m | Route calculation mode. Can be driving (optimal route on roads), driving-shortest (shortest route on roads), or direct (straight-line distance). Default is driving. |
key | Authorization key. |
callback | Name of the function for JSONP request. |
Request examples
https://api.visicom.ua/data-api/5.0/core/tsp.json?waypoints=28.71483,50.29734|31.93485,46.98892|31.27979,51.50313|24.01646,49.8392|32.41791,50.90552&key=YOUR_API_KEY
https://api.visicom.ua/data-api/5.0/core/tsp.json?waypoints=31.6032,48.61124|31.93485,46.98892|31.27979,51.50313|24.01646,49.8392|32.41791,50.90552&round_trip=false&key=YOUR_API_KEY
Response
{"list": [
{"index": 0},
{"index": 1},
{"index": 3},
{"index": 4},
{"index": 2},
{"index": 5}
]}
Ordered list of waypoints. Returns a JSON object with a single field list containing an array of indexes corresponding to the points in the waypoints array. Indexing starts from zero.