Skip to content

Commute Route

Commute Route

Prerequisites: This feature works based on collecting user tracks. When drivers often drive the same route to their usual destination. The commute route will return the driver's usual route. If there is no usual route, it will return the fastest route.

Note: this feature only support offboard mode.

Create a request

The request is the same as a route request. If there is no usual route, commute route will return the normal route with the user's request.

1
2
3
4
auto request = direction_Service->createRouteRequestBuilder()
                ->setOrigin(tn::direction::models::v2::GeoLocation(37.386300,-122.005090))
                .setDestination(tn::direction::models::v2::GeoLocation(37.398760,-121.977360))
                .build();

Calculate a commute route

1
2
3
4
5
6
7
8
tn::shared_ptr<tn::direction::api::RouteResponse> route_response;
tn::foundation::ErrorCode error_code;

auto request = direction_Service->createCommuteRouteTask(request, tn::direction::api::CalculationMode::Offboard)
    ->runSync([&](tn::foundation::ErrorCode c, tn::shared_ptr<tn::direction::api::RouteResponse> r) {
        route_response = r;
        error_code = c;
    });
The response is the same as the route response; the commute route is one of the styles of route, and the style is tn::direction::models::v2::RouteStyle::Usual.