Update Route Handle

The route handle endpoint also accepts an origin parameter. It can be used to update the origin of the route, essentially removing the initial part of the original route up until the location passed as new origin.

Note that for this behavior the origin needs to be on the route. A location not on the route for origin will result in an error.

If a route goes through the same point multiple times, origin is matched to the first occurrence on the route.

Example request to obtain an route handle:

curl -X GET \
    'https://router.hereapi.com/v8/routes?origin=52.531029,13.384831&destination=52.539451,13.410595&return=summary,routeHandle&transportMode=car'
{
  "routes": [
    {
      "id": "d5d4eda5-ca9e-4722-ba23-33d8878a0c9a",
      "sections": [
        {
          "id": "41d20dd7-35ee-4da0-a5d8-60f7dea495db",
          "type": "vehicle",
          "departure": {
            "time": "2021-06-29T13:37:29+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.53105,
                "lng": 13.38481
              },
              "originalLocation": {
                "lat": 52.5310289,
                "lng": 13.3848309
              }
            }
          },
          "arrival": {
            "time": "2021-06-29T13:44:19+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.5394429,
                "lng": 13.4106148
              },
              "originalLocation": {
                "lat": 52.539451,
                "lng": 13.410595
              }
            }
          },
          "summary": {
            "duration": 410,
            "length": 2624,
            "baseDuration": 289
          },
          "transport": {
            "mode": "car"
          }
        }
      ],
      "routeHandle": "{originalRouteHandle}"
    }
  ]
}

Using the originalRouteHandle with origin to get an updated shorter route and a new route handle describing it:

curl -X GET \
    'https://router.hereapi.com/v8/routes/{originalRouteHandle}&origin=52.536431,13.391695&return=summary,routeHandle&transportMode=car'
{
  "routes": [
    {
      "id": "b4507a14-5c64-4a7a-a16f-c6c2390777b5",
      "sections": [
        {
          "id": "2edf3530-b525-4d75-9d75-39af8072d79e",
          "type": "vehicle",
          "departure": {
            "time": "2021-06-29T13:43:01+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.53645,
                "lng": 13.39169
              },
              "originalLocation": {
                "lat": 52.536431,
                "lng": 13.3916949
              }
            }
          },
          "arrival": {
            "time": "2021-06-29T13:47:37+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.5394429,
                "lng": 13.4106148
              },
              "originalLocation": {
                "lat": 52.539451,
                "lng": 13.410595
              }
            }
          },
          "summary": {
            "duration": 276,
            "length": 1728,
            "baseDuration": 183
          },
          "transport": {
            "mode": "car"
          }
        }
      ],
      "routeHandle": "{newRouteHandle}"
    }
  ]
}

Notice that the newRouteHandle is different from originalRouteHandle and a new request using it, but origin provides the same summary as above:

curl -X GET \
    'https://router.hereapi.com/v8/routes/{newRouteHandle}?&return=summary&transportMode=car'
{
  "routes": [
    {
      "id": "3cea7ab5-a8b9-4d30-85c6-96fe725b3985",
      "sections": [
        {
          "id": "ee82ab74-8b21-4134-8d09-59c092365d31",
          "type": "vehicle",
          "departure": {
            "time": "2021-06-29T14:55:51+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.53645,
                "lng": 13.39169
              },
              "originalLocation": {
                "lat": 52.536431,
                "lng": 13.3916949
              }
            }
          },
          "arrival": {
            "time": "2021-06-29T15:00:57+02:00",
            "place": {
              "type": "place",
              "location": {
                "lat": 52.5394429,
                "lng": 13.4106148
              },
              "originalLocation": {
                "lat": 52.539451,
                "lng": 13.410595
              }
            }
          },
          "summary": {
            "duration": 276,
            "length": 1728,
            "baseDuration": 183
          },
          "transport": {
            "mode": "car"
          }
        }
      ]
    }
  ]
}

If origin is not on the route the following error is returned:

curl -X GET \
    'https://router.hereapi.com/v8/routes/{originalRouteHandle}?&origin=52.532914,13.399983&return=summary,routeHandle&transportMode=car'
{
  "notices": [
    {
      "title": "Route calculation failed: Couldn't match origin.",
      "code": "couldNotMatchOrigin",
      "severity": "critical"
    }
  ],
  "routes": []
}

results matching ""

    No results matching ""