The latest update to the Mapbox Directions API brings fast and accurate rerouting.
Naive rerouting approaches often trigger too late or too early. You may have missed an exit and now you’re waiting for a new route or there’s simply a misread on your location and your navigation system proposes a new route for a wrong starting location.
To increase reaction time and confidence for rerouting, we now use bearings in addition to location to determine whether a driver is on their recommended route or not. For example, if we expect a driver to travel at a bearing of 110 degrees, but measure 130 degrees instead, we have a strong indication that the vehicle has departed from the recommended route and we can request a new route.
Angles between road edges in simplified map data often differ from the real world. To compute real world bearings from map data, we apply different strategies in different scenarios. Here are a couple of examples.
In the example below a simple approach would detect two independent merging roads with steep turn angles when in fact this is a simple continuation of the same highway separating into dual carriage ways:
Here is a similar case where a highway exit is represented as a sharp turn:
These examples are taken from OpenStreetMap and they are mapped correctly. They simply don’t represent real world turn angles accurately. To address these inconsistencies, we identify various scenarios. In the examples, we estimate bearings by skipping over the first few meters of the turn and looking at the angle of the road segment just after.
Turns on curves
Another scenario are curves and we apply a different strategy. Here, the angle following the immediate intersection represents the accurate turn bearing: