Get Started
Create Direction Service Instance
Direction service depends on system service, setting service and mapContent service.
System service: manage map data paths, vehicle types, cloud URLs, and more.
Setting service: supply a serials of key-value settings that can be used for all kinds of services. All keys for direction services please refer to tn::direction::SettingConstants.
MapContent: a service to manage map data that is used by other services.
Here is an example of creating a direction instance.
| tn::foundation::System::Builder builder;
builder.setCloudURL("https://api.telenav.com");
auto system = tn::foundation::System::Builder.build();
auto setting = tn::foundation::Settings::Builder.build();
auto mapContent = tn::mapcontent::Factory::create(system,setting);
auto directionService =
tn::direction::DirectionService::CreateInstance(system, setting, mapContent);
|
Set vehichle type when intialization
Routing supports different vehicle types; it will consider road restrictions related to vehicle types.
How to set the vehicle type, as shown in the example below.
| auto system = tn::foundation::System::Builder::build();
// set vehicle type
system->vehicleInfoProvider()->setVehicleCategory(tn::foundation::VehicleCategory::Auto);
// set the drivetrain type of the vehicle
system->vehicleInfoProvider()->setDrivetrainType(tn::foundation::DrivetrainType::FourWheelDrive);
auto setting = tn::foundation::Settings::Builder.build();
auto mapContent = tn::mapcontent::Factory::create(system,setting);
auto directionService =
tn::direction::DirectionService::CreateInstance(system, setting, mapContent);
|
If vehicle type is truck, you should set the truck related information.
| auto system = tn::foundation::System::Builder::build();
auto provider = system->vehicleInfoProvider();
tn::foundation::VehicleCategory category = tn::foundation::VehicleCategory::Truck;
tn::foundation::VehicleDimensions dimensions;
dimensions.length = 500;
dimensions.width = 300;
dimensions.height = 270;
dimensions.weight = 2950;
dimensions.gross_vehicle_mass = 4250;
provider->setDimensions(dimensions);
provider->setVehicleCategory(category);
auto setting = tn::foundation::Settings::Builder.build();
auto mapContent = tn::mapcontent::Factory::create(system,setting);
auto directionService =
tn::direction::DirectionService::CreateInstance(system, setting, mapContent);
|
If you use an EV-related feature, you should set the vehicle's electric information.
| auto system = tn::foundation::System::Builder::build();
tn::foundation::EnergyProfile profile;
profile.energyType = tn::foundation::EnergyType::Electric;
profile.evBatteryCapacity = 100; // kwh
profile.evEnergyConsumption = 160; // wh/km
profile.evConnectorTypes.push_back(tn::foundation::EvConnectorType::J1772);
system->vehicleInfoProvider()->setEnergyProfile(profile);
auto setting = tn::foundation::Settings::Builder.build();
auto mapContent = tn::mapcontent::Factory::create(system,setting);
auto directionService =
tn::direction::DirectionService::CreateInstance(system, setting, mapContent);
|
Set cloud URL when intialization
| tn::foundation::System::Builder systemBuild;
systemBuild.setCloudURL("https://apina.telenav.com");
systemBuild.setUserID("navigaton_user");
systemBuild.setApplicationKeyAndSecret("key","secret");
auto system = systemBuild.build();
auto setting = tn::foundation::Settings::Builder.build();
auto mapContent = tn::mapcontent::Factory::create(system,setting);
auto direction_Service =
tn::direction::DirectionService::CreateInstance(system, setting, mapContent);
|