Currently we only apply the route when the route is faster (that is what the logic is used for), so the same route with a slower ETA is not applied.
In this PR I've modified the rerouting logic, so we can display more accurate ETA's within the client app. This is especially important when the user drives towards/within a traffic jam.
Rerouting logic:
Every 2 minutes we ask for a new route.
When do we apply a new route?
Before:
Check if new route is 10% or more faster than the current route.
If so -> Apply the new route
After:
Check if the new route is 10% or more faster than the current route.
If so -> Apply the new route
If slower -> Check if the route is 90% or more similar to current route (by geometry)
If so -> Check if new ETA is more than 30s different than current route
If so -> Apply the new route
Regarding geometry check:
We assume the geometry from the routing endpoint is stable. It uses simple coordinate comparison checks (optimising for performance).
Summary of changes
Added method to compare route geometries that gives a percentage of the match
Added a 'best match' method for rerouting that finds the most similar route that is >90% similar
Made test targets run again after FM changes & migrating to Maplibre by updating dependencies (Quick & Nimble) and fixing compiler errors in those targets
Significantly refactored RouteController's rerouting logic, now returning a 'reroute reason' when didRerouteAlong delegate gets called, so that API is changed in signature
Moved & renamed RouteControllerProactiveReroutingInterval to be an instance property of RouteController so the user can easily set this per route controller
Added unit tests for new matching & rerouting methods
Added shouldCheckForRerouteInLastMinutes property to RouteController to skip check if we have 10+ mins left in the route, to also fetch routes for an ETA update in the last 10 mins of the route
How to test
Run the new tests for yourself and check if they are valid
Description
Currently we only apply the route when the route is faster (that is what the logic is used for), so the same route with a slower ETA is not applied.
In this PR I've modified the rerouting logic, so we can display more accurate ETA's within the client app. This is especially important when the user drives towards/within a traffic jam.
Rerouting logic:
Every 2 minutes we ask for a new route.
When do we apply a new route?
Before:
After:
Regarding geometry check: We assume the geometry from the routing endpoint is stable. It uses simple coordinate comparison checks (optimising for performance).
Summary of changes
RouteController
's rerouting logic, now returning a 'reroute reason' whendidRerouteAlong
delegate gets called, so that API is changed in signatureRouteControllerProactiveReroutingInterval
to be an instance property ofRouteController
so the user can easily set this per route controllershouldCheckForRerouteInLastMinutes
property toRouteController
to skip check if we have 10+ mins left in the route, to also fetch routes for an ETA update in the last 10 mins of the routeHow to test
Run the new tests for yourself and check if they are valid