toNavigationRoute

fun DirectionsRoute.toNavigationRoute(): NavigationRoute
fun DirectionsRoute.toNavigationRoute(routerOrigin: RouterOrigin): NavigationRoute

Maps DirectionsRoute to NavigationRoute.

This mapping tries to fulfill some of the required NavigationRoute data points from the nested features of the DirectionsRoute, or supplies them with fake supplements to the best of its ability.

This is a lossy mapping since the DirectionsRoute cannot carry the same amount of information as NavigationRoute.

This compatibility extension is blocking and can now take a significant amount of time to return (in order of hundreds of milliseconds for long routes). To avoid potential slowdowns, try not using the compatibility layer and work with NavigationRoute and NavigationRouterCallback were possible (look for deprecation warnings and refactor). There's a cache layer baked in that avoids the blocking operations if the route was generated by the Navigation SDK itself which could avoid majority of blocking operations, but it's not guaranteed.

Avoid using this mapper and instead try using APIs that accept NavigationRoute type where possible.

Throws

when DirectionsRoute and RouteOptions don't contain enough data to create a new instance of NavigationRoute. For instance, EV routing adds additional waypoints and metadata, to handle a route it requires original DirectionsResponse.