Skip to content

Customize Drive Session

Customize navigation service

This tutorial will walk you through the process of creating a navigation service with customized options to get advanced features.

Get started

A navigation service can be created with optional components enabled to provide advanced navigation features: * audio guidance prompts * rich information for user location * traffic information * highway information * traffic signs * cameras * turn and access restriction * administrative information * speed limits * turn-by-turn guidance * better route detection

Before creating a navigation service, a foundation system and map content instance must be created.

Enable map matching log output for debugging

Enable map matching log output at the creation of a navigation service to get detailed information for debugging.

1
2
3
4
5
6
7
8
// turn on map matching log output and set log path
const auto settings = tn::foundation::Settings::Builder()
    .setString(tn::drive::api::SettingConstants::SETTING_POSITION_LOG_ENABLED, "true")
    .setString(tn::drive::api::SettingConstants::SETTING_POSITION_LOG_PATH, "/path/to/log")
    .build();

const auto navigationService = tn::drive::api::NavigationServiceFactory::createNavigationService(
    options, system, settings, mapContent, directionService);

Turn off data collection for analytics

Analytics data is collected by default to improve the TA SDK. Once you implemented tn::foundation::Analytics interface and set the instance via tn::foundation::System::Builder::setAnalytics(), navigation service will collect and send analytics data to the service specified by analytics instance. You can turn it off at the creation of a navigation service.

1
2
3
4
5
6
const auto settings = tn::foundation::Settings::Builder()
    .setString(tn::drive::api::SettingConstants::SETTING_DRIVE_ANALYTICS_COLLECTION, "false")
    .build();

const auto navigationService = tn::drive::api::NavigationServiceFactory::createNavigationService(
    options, system, settings, mapContent, directionService);

Customize road graph detection distance

In navigation service, there's a road graph built at run time to detect road condition changes around vehicle. The detection distances are shared for detection of highway information, traffic incidents, traffic signs, cameras, turn and access restrictions, administrative information changes and speed limits. They can be customized to adjust the performance.

const std::string roadGraphSettings = R"json(
{
    // Following configuration shows the default values for detection distances
    "RoadGraph": 
    {
        //  Maximum forward road detection distance in virtual road graph when vehicle is on highway, unit: meter.
        //  If road detection function is invoked, road graph builder will detect road with maximum length of this value.
        "MaxAheadRouteDistance": 100000,

        //  Minimum forward road detection distance in virtual road graph when vehicle is on highway, unit: meter.
        //  If stored ahead route distance is less than this value, forward road detection will be invoked.
        "MinAheadRouteDistance": 81000,

        //  Maximum forward road detection distance in virtual road graph when vehicle is on local road, unit: meter.
        //  If road detection function is invoked, road graph builder will detect road with maximum length of this value.
        "MaxAheadRouteDistanceOnLocal": 7000,

        //  Minimum forward road detection distance in virtual road graph when vehicle is on local road, unit: meter.
        //  If stored ahead route distance is less than this value, forward road detection will be invoked.
        "MinAheadRouteDistanceOnLocal": 5000,

        //  Backward road detection distance in virtual route graph, unit: meter.
        //  If previous route behind vehicle is less than this value, backward road detection will be invoked.
        "PreviousRouteDistance": 5000
    }
}
)json";

const auto settings = tn::foundation::Settings::Builder()
    .setString(tn::drive::api::SettingConstants::SETTING_ALERT_JSON_CONTENT, roadGraphSettings)
    .build();

// enable alert component at the creation of a navigation service to make customized road graph settings effective
tn::drive::NavigationServiceOptions options;
options.enable_alert = true;

const auto navigationService = tn::drive::api::NavigationServiceFactory::createNavigationService(
    options, system, settings, mapContent, directionService);