compareToForkingRoute

@RestrictToExtendedFlavor(value = [ExternalScope.LIBRARY_GROUP])
fun Route.compareToForkingRoute(forkingRoute: Route): Result<RouteDifferences, RouteComparisonFailure>

Compares this route to a forking route and returns the differences between the two.

A forking route is defined as one that branches off from this route at a designated fork point, with both routes following the same trajectory up to that point and sharing the same destination.

For instance, this method can be applied on the alternative route against the one currently being navigated:

val result = currentRoute.compareToForkingRoute(betterAlternativeRoute)
result.ifSuccess { differences ->
// Analyze the differences
}
}

The returned RouteDifferences object can provide insights into the advantages and disadvantages of the alternative route.

Receiver

The route to compare with the forking route.

Return

A Result containing RouteDifferences, or a RouteComparisonFailure if the comparison fails:

Parameters

forkingRoute

The route to compare with the receiver route.