Route Via Intermediate Waypoint

For a detour from the best route, specify the via parameter in your request.

For a list of via waypoints, the resulting route looks as follows:

  1. from the origin to the first via
  2. to any subsequent via in the requested order
  3. the last via until the destination

A passThrough option can be set for each via parameter. In case passThrough is set to true, the router will try to avoid following scenarios at the waypoint during route calculation:

  • Introducing a stopover
  • Splitting the route into sections
  • Changing the direction of travel

Additionally, specify return=passthrough to get information about passthrough via waypoints in the response. This includes the location that the passthrough via was matched and an offset into the polyline if the polyline was requested as well.

Example with a stopover waypoint

curl -X GET \
  'https://router.hereapi.com/v8/routes?transportMode=car&return=polyline,summary&origin=52.51375,13.42462&destination=52.52332,13.42800&via=52.52426,13.43000'
{
  "routes": [
    {
      "id": "3e63833f-bee5-406b-9636-8fd131f2eb26",
      "sections": [
        {
          "id": "27bf6c8c-fc16-49f4-822f-c2a2f07d3437",
          "type": "vehicle",
          "departure": {
            "time": "2020-06-29T17:04:53+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.513748,
                "lng": 13.424624
              },
              "originalLocation": {
                "lat": 52.51375,
                "lng": 13.42462
              }
            }
          },
          "arrival": {
            "time": "2020-06-29T17:07:22+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.5242323,
                "lng": 13.4301462
              },
              "originalLocation": {
                "lat": 52.52426,
                "lng": 13.43
              },
              "waypoint": 0
            }
          },
          "summary": {
            "duration": 149,
            "length": 1281,
            "baseDuration": 149
          },
          "polyline": "BGo9llkDg_rzZkF0G8LoQ4NoQgP8QoLgKgyB0tB4XoVoLsJ0K4IwWoQsOsJ8LwHoLoGkS0KkN8GsJ0F8GgF4D4DsE0FwHoLUgK8BkIkDkIgFwHgFwCgFUgF7B4DjDsErEsE_EkD7GoLUgFoB0F8B8Q0FsE8BkmBkSgtBwWkS8GwH8B8GoBosCgKkhBsE0FU0FUgZjD8VgKoGkD4F8C",
          "transport": {
            "mode": "car"
          }
        },
        {
          "id": "1c009836-6836-4285-bc9d-e9efc5fefb37",
          "type": "vehicle",
          "departure": {
            "time": "2020-06-29T17:07:22+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.5242323,
                "lng": 13.4301462
              },
              "originalLocation": {
                "lat": 52.52426,
                "lng": 13.43
              },
              "waypoint": 0
            }
          },
          "arrival": {
            "time": "2020-06-29T17:07:55+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.5232227,
                "lng": 13.4280044
              },
              "originalLocation": {
                "lat": 52.5233199,
                "lng": 13.428
              }
            }
          },
          "summary": {
            "duration": 33,
            "length": 222,
            "baseDuration": 33
          },
          "polyline": "BGws6lkDk42zZ3F7CnGjD7V_JrEzF3DjDzK_EvHrE7BjhBTzoBN_Z",
          "transport": {
            "mode": "car"
          }
        }
      ]
    }
  ]
}

Screenshot

The requested route is going from (A) to (B).

Route with via waypoint
Figure 1. Route with via waypoint

Example with a passthrough waypoint

Below example is using the same coordinates for origin, destination and via, but setting passThough=true for the via waypoint.

As a result, the responded route contains only one leg stretching from origin to destination, thus avoiding the route to be split at the intermediate waypoint, contrary to previous example.

curl -X GET \
  'https://router.hereapi.com/v8/routes?transportMode=car&return=polyline,summary,passthrough&origin=52.51375,13.42462&destination=52.52332,13.42800&via=52.52426,13.43000!passThrough=true'
{
  "routes": [
    {
      "id": "338a34f2-60c2-4ced-b9c4-074c3c2f8039",
      "sections": [
        {
          "id": "c4052a8e-7a53-4203-8606-b50260ad7b5c",
          "type": "vehicle",
          "departure": {
            "time": "2020-06-29T16:59:53+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.513748,
                "lng": 13.424624
              },
              "originalLocation": {
                "lat": 52.51375,
                "lng": 13.42462
              }
            }
          },
          "arrival": {
            "time": "2020-06-29T17:04:09+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.5232227,
                "lng": 13.4280044
              },
              "originalLocation": {
                "lat": 52.5233199,
                "lng": 13.428
              }
            }
          },
          "summary": {
            "duration": 256,
            "length": 1970,
            "baseDuration": 256
          },
          "passthrough": [
            {
              "place": {
                "type": "place",
                "location": {
                  "lat": 52.5242323,
                  "lng": 13.4301462
                },
                "originalLocation": {
                  "lat": 52.52426,
                  "lng": 13.43
                },
                "waypoint": 0
              },
              "offset": 49
            }
          ],
          "polyline": "BGo9llkDg_rzZkF0G8LoQ4NoQgP8QoLgKgyB0tB4XoVoLsJ0K4IwWoQsOsJ8LwHoLoGkS0KkN8GsJ0F8GgF4D4DsE0FwHoLUgK8BkIkDkIgFwHgFwCgFUgF7B4DjDsErEsE_EkD7GoLUgFoB0F8B8Q0FsE8BkmBkSgtBwWkS8GwH8B8GoBosCgKkhBsE0FU0FUgZjD8VgKoGkD4F8CgNwGgKgFkI4DgFoBoGUsEnBsEvC3IkSvHkNvWsiBjN0ZjX8kB_OkXjD4DvC8BvCUjIUT7VnBrvCA7L7BnnCnBnV7BjhBTzoBN_Z",
          "transport": {
            "mode": "car"
          }
        }
      ]
    }
  ]
}

Screenshot

With passThrough option set to true, the router did not introduce an u-turn at waypoint (1) avoiding a change in travel direction and hence resulting in a different route shape (the orange line) as shown in the image below.

Route with passthrough via waypoint
Figure 2. Route with passthrough via waypoint

results matching ""

    No results matching ""