How to link SERVICE tour events to waypoints in xRoute response
Posted: Thu Sep 25, 2025 1:18 pm
I have a question about how to correctly determine the time and distance between waypoints in the xRoute response.
In our product, we initially used calculateRoute without breaks, relying on the RouteResponse/waypoints property to obtain the required data (time and distance between waypoints).
Since we’ve started including driver breaks from xRoute, we also use the RouteResponse/events property to get the break events.
In our product, breaks are treated as waypoints, so the BREAK tour events we convert them in waypoints.
Each event in RouteResponse/events have distanceFromStart and travelTimeFromStart. To correctly calculate the actual time and distance between waypoints (waypoints + break events), I need to determine which SERVICE tour event belongs to which waypoint.
From analyzing the response, the pattern appears to be (check attached image):
P.S.
1. I also enabled the nodes property and considered linking them through nodeIndex, but found out that that`s not the proper property to use.
2. In our product, each waypoint always has exactly one SERVICE event, which makes the mapping simpler.
Regards,
Marko Arsovski
CAPcargo
In our product, we initially used calculateRoute without breaks, relying on the RouteResponse/waypoints property to obtain the required data (time and distance between waypoints).
Since we’ve started including driver breaks from xRoute, we also use the RouteResponse/events property to get the break events.
In our product, breaks are treated as waypoints, so the BREAK tour events we convert them in waypoints.
Each event in RouteResponse/events have distanceFromStart and travelTimeFromStart. To correctly calculate the actual time and distance between waypoints (waypoints + break events), I need to determine which SERVICE tour event belongs to which waypoint.
From analyzing the response, the pattern appears to be (check attached image):
- All events following a waypoint belong to it.
- Except for the last waypoint, where SERVICE events are listed before the waypoint.
P.S.
1. I also enabled the nodes property and considered linking them through nodeIndex, but found out that that`s not the proper property to use.
2. In our product, each waypoint always has exactly one SERVICE event, which makes the mapping simpler.
Regards,
Marko Arsovski
CAPcargo