# Optimizing waypoints

The HERE Waypoints Sequence API v8 resource findsequence allows you to optimize for distance covered in a journey or for travel time. Use the parameter improvefor (available values: distance and time). By default, HERE Waypoints Sequence optimizes waypoints for travel time.

HERE Waypoints Sequence API v8 does not include route details in its responses. To request a route, use the HERE Routing API.

Requests to the Routing API must include the route travel mode and two consecutive waypoint coordinates from the response from HERE Waypoints Sequence API v8. If the route includes traffic information, departure time is also required. The response from HERE Waypoints Sequence API v8 provides this information in the element estimatedDeparture.

Time window constraints define opening hours or deadlines for product delivery points or appointments specific to each waypoint. Successful responses contain an optimized waypoint sequence that observes all the time constraints specified in the request in the parameter destinationN. Where this is not possible, the service generates a response without a way point sequence, but hints at conflicting or problematic constraints or waypoints. You must then resubmit the request with relaxed or modified constraints or waypoints. For an example, see Time Constraints Waypoint Sequence.

Sequence constraints between pairs of waypoints define a partial order which is strictly obeyed. Add ;before:destination13 to the waypoints in the request parameters to define sequence constraints. Several 'before's are allowed per way point.

Service time is specific to each waypoint and defines the amount of time to be spent at the waypoint. In other words, it indicates the length of time between arrival at the waypoint and departure from it, for example, to complete the delivery of goods. Service times are taken into account in the optimized waypoint sequence. For an example with rest times at waypoints, see Traffic Info and Rest Time Constraints Waypoint Sequence.

HERE Waypoints Sequence API v8 may take several minutes to calculate a response depending on the parameters specified. Specifically, this calculation time depends on the following:

• whether traffic mode (mode=...;traffic:enabled) is enabled
• the number of waypoints
• the distances between the individual waypoints
• whether car or truck mode is used (mode=car;… or mode=truck;...)

The timeout after which the network connection is closed is set to 300 seconds on the HERE Waypoints Sequence API v8 systems.

## Grouping nearby waypoints

Internally the HERE Waypoints Sequence API v8 puts nearby way points into groups. Sequences keeping groups intact are algorithmically preferred, but not required.

The conditions for waypoints being grouped are:

• Only destinations are grouped, start and end waypoints are not grouped.
• Destinations are put into groups, if each two of them are 50m or less apart:
start-- 16m--x1-- 30m --x2-- 2m --x3-- 10m --x4-- 80m --x5-- 10m --end In this example x1, x2, x3 and x4 will form a group. x5 stays as a separate destination.
• This distance is checked in both directions, for that

• Destinations in one-way streets are likely not to be grouped
• Destinations cannot be chained in chunks > 50m, e.g.

x12--- 48m ---x13--- 47m ----x14

will not form a group.

The distance is the routing distance, not the air-distance, this means the matching to the road network defines the important location:

Destinations on a rear building still can be grouped together with destinations on the front building, if matched to the same road.
Destinations matched on opposite sides of multi-digitized roads are likely not to be grouped.


### Impact of constraints on Grouping

Constraints may break groups. For that reason waypoints with certain constraints attached cannot be part of a group:

• Destinations with access/opening hours (acc:) are grouped, if the the access hours are literally the same. They can also be grouped with destinations without access hours.
• Service times (st:) have no impact on grouping.
• Destinations with partial order (before:) or appointments (at:) are not grouped.