The route to explain.
The route to explain it against, such as the selected alternative or the route typical traffic would take.
The section types to weigh.
The stretches each route drives alone, and getSectionsWithin on each side.
sections.distinct, which were found against every route of their response.calculateRoute calls compare where they carry the same coordinates along a
road they share. Where they don't, that road counts as distinct on both sides.costModel: { traffic: 'historical' } still carries the live traffic
sections along it. Compare the live route with it to tell which jams and closures it avoids.distinct empty on both sides means the two routes drive the same roads.const [live, usual] = await Promise.all([
calculateRoute({ locations }),
calculateRoute({ locations, costModel: { traffic: 'historical' } }),
]);
const { avoids } = compareRoutes(live.features[0], usual.features[0], { types: ['traffic'] });
avoids.traffic?.sections.forEach((incident) => console.log(`avoids ${incident.categories.join(', ')}`));
Compares a route with a reference route: what it takes on that the reference doesn't, such as a toll or a ferry, and what it stays clear of, such as a jam or a closed road.