GuidesAPI Reference
Guides

How to save time with clusters of destinations

The user is looking for the fastest way through a number of destinations located in a residential area. The waypoints located on a road between two junctions shall be kept together.

Request

curl -H "Authorization: Bearer BEARER_TOKEN" "https://wps.hereapi.com/v8/findsequence2?mode=fastest;car;traffic:disabled;&start=Start;50.116300,8.628638&end=End;50.116300,8.628638&destination1=A;50.117780,8.630247&destination2=B;50.118227,8.630328&destination3=C;50.118357,8.630335&destination4=D;50.117922,8.630277&destination5=E;50.117841,8.631541&destination6=F;50.117783,8.632024&destination7=G;50.117766,8.632335&clustering=topologySegment"

Response

The service puts the waypoints at a topology segment together in the sequence. This is reflected by the attribute cluster in the waypoints section of the response. Note that the waypoint with the identifier "E" doesn't belong to any cluster. It's the only destination on its topology segment. The interconnection section is shortened in the example response.

{
  "results": [
    {
      "waypoints": [
        {
          "id": "Start",
          "lat": 50.1163,
          "lng": 8.628638,
          "sequence": 0,
          "estimatedArrival": null,
          "estimatedDeparture": null,
          "fulfilledConstraints": []
        },
        {
          "id": "C",
          "lat": 50.118357,
          "lng": 8.630335,
          "sequence": 1,
          "estimatedArrival": null,
          "estimatedDeparture": null,
          "fulfilledConstraints": [],
          "cluster": 0
        },
        {
          "id": "B",
          "lat": 50.118227,
          "lng": 8.630328,
          "sequence": 2,
          "estimatedArrival": null,
          "estimatedDeparture": null,
          "fulfilledConstraints": [],
          "cluster": 0
        },
        {
          "id": "D",
          "lat": 50.117922,
          "lng": 8.630277,
          "sequence": 3,
          "estimatedArrival": null,
          "estimatedDeparture": null,
          "fulfilledConstraints": [],
          "cluster": 1
        },
        {
          "id": "A",
          "lat": 50.11778,
          "lng": 8.630247,
          "sequence": 4,
          "estimatedArrival": null,
          "estimatedDeparture": null,
          "fulfilledConstraints": [],
          "cluster": 1
        },
        {
          "id": "E",
          "lat": 50.117841,
          "lng": 8.631541,
          "sequence": 5,
          "estimatedArrival": null,
          "estimatedDeparture": null,
          "fulfilledConstraints": []
        },
        {
          "id": "F",
          "lat": 50.117783,
          "lng": 8.632024,
          "sequence": 6,
          "estimatedArrival": null,
          "estimatedDeparture": null,
          "fulfilledConstraints": [],
          "cluster": 2
        },
        {
          "id": "G",
          "lat": 50.117766,
          "lng": 8.632335,
          "sequence": 7,
          "estimatedArrival": null,
          "estimatedDeparture": null,
          "fulfilledConstraints": [],
          "cluster": 2
        },
        {
          "id": "End",
          "lat": 50.1163,
          "lng": 8.628638,
          "sequence": 8,
          "estimatedArrival": null,
          "estimatedDeparture": null,
          "fulfilledConstraints": []
        }
      ],
      "distance": "1840",
      "time": "279",
      "interconnections": [
        {
          "fromWaypoint": "Start",
          "toWaypoint": "C",
          "distance": 537,
          "time": 97,
          "rest": 0,
          "waiting": 0
        },
        {
          "fromWaypoint": "C",
          "toWaypoint": "B",
          "distance": 14,
          "time": 2,
          "rest": 0,
          "waiting": 0
        },
        {
          "fromWaypoint": "B",
          "toWaypoint": "D",
          "distance": 32,
          "time": 4,
          "rest": 0,
          "waiting": 0
        },
        {
          "fromWaypoint": "D",
          "toWaypoint": "A",
          "distance": 16,
          "time": 3,
          "rest": 0,
          "waiting": 0
        },
        {
          "fromWaypoint": "A",
          "toWaypoint": "E",
          "distance": 77,
          "time": 11,
          "rest": 0,
          "waiting": 0
        },
        {
          "fromWaypoint": "E",
          "toWaypoint": "F",
          "distance": 35,
          "time": 5,
          "rest": 0,
          "waiting": 0
        },
        {
          "fromWaypoint": "F",
          "toWaypoint": "G",
          "distance": 22,
          "time": 4,
          "rest": 0,
          "waiting": 0
        },
        {
          "fromWaypoint": "G",
          "toWaypoint": "End",
          "distance": 1107,
          "time": 153,
          "rest": 0,
          "waiting": 0
        }
      ],
      "description": "Targeted best time; without traffic",
      "timeBreakdown": {
        "driving": 279,
        "service": 0,
        "rest": 0,
        "waiting": 0,
        "break": 0
      }
    }
  ],
  "errors": [],
  "processingTimeDesc": "112ms",
  "responseCode": "200",
  "warnings": null,
  "requestId": "173fa809-0224-490e-b84d-475e2070b633"
}