HERE iOS SDK Developer's Guide

Toll Cost Extension

Toll Cost Extension provides you the possibility to easily access Toll Cost Extension API from the HERE SDK. The HERE Toll Cost Extension (TCE) allows you to determine the toll costs for a specified route for a defined vehicle profile.

TCE Classes

Class Description
NMATollCostOptions All the parameters for the toll cost calculation including route, vehicle profile, currency and departure date. It implements the [NSObject description] method.
NMATollCostRequest Creates the TCE request for the toll cost data.
NMATollCostResult After a TCE data request run, the result is returned with this class.
NMATollCostVehicleProfile All the parameters of the vehicle to be used. It implements [NSObject description] method.

Requesting the Toll Cost Data

To use Toll Cost Extension, you need to first have a route calculated in online mode, as the Toll Cost Extension requires permanent directed link IDs. After having a route from the core router, you can then retrieve the toll cost of the route.

// Create the core router
NMACoreRouter *coreRouter = [[NMACoreRouter alloc] init];

// We need link IDs, NMARoute.permanentDirectedLinkIds, so we force online routing
coreRouter.connectivity = NMACoreRouterConnectivityOnline;

You can provide options for the toll cost request through an instance of NMATollCostOptions. If the vehicle needs non-default settings, such as if this toll request is for a specific type of vehicle, create an NMATollCostVehicleProfile object.

Note: It is your responsibility to provide a compatible route and toll cost options. When setting the toll cost options, make sure that they match the route options. For example, if the toll cost option vehicle type is set as truck, but the route is created for a car, they are incompatible. In this case, the toll cost result may not be valid.

Next, create a NMATollCostRequest request object. If the request object is valid and the route contains permanent directed linkids, then you can execute the toll cost request via a block or listener. When the result is received, first it is checked for any error. If there is no error, its toll cost contents are retrieved.

Figure 1. A Toll Cost Example
// Step 1: Get the input

// Mandatory. Assume it is calculated via the above core router for a truck.
NMARoute route;
// Optional. Set it to the date and time for the trip
NSDate departureTime;
NMATollCostVehicleProfile *vehicleProfile = [[NMATollCostVehicleProfile alloc] init];

vehicleProfile.tollVehicleType = NMATollCostVehicleTypeTruck;
vehicleProfile.trailerType = NMATollCostTrailerTypeNone;
vehicleProfile.trailersCount = NMATollCostTrailersCountNone;
vehicleProfile.vehicleNumberAxles = 2;
vehicleProfile.emissionType = NMATollCostEmissionTypeEuroVI;
vehicleProfile.hybridType = NMATollCostHybridTypeNone;
vehicleProfile.height = 3.8f;
vehicleProfile.vehicleWeight = 11.0f;
vehicleProfile.limitedWeight = 11.0f;
vehicleProfile.passengersCount = 1;
vehicleProfile.tiresCount = 4;
vehicleProfile.commercial = true;
vehicleProfile.shippedHazardousGoods = NMATollCostShippedHazardousGoodsNone;
vehicleProfile.heightAbove1stAxle = 1.0f;

// Step 2: Wrap all the input
NMATollCostOptions *options = [NMATollCostOptions alloc] initWithVehicleProfile:route];
parameter.departure = departureTime; // Optional
parameter.currency = @"USD"; // Optional

// Step 3: Create the TCE request
NMATollCostRequest request = [[NMATollCostRequest alloc] initWithRoute:route andOptions:options];

// Step 4: Execute the TCE request with a block
// Is the request valid?
if (request) {
  [request startWithBlock:^(NMATollCostRequest *request, NMATollCostResult *result, NSError *error) {
    if (error) {
      // Something has gone wrong
      NSLog(@"Error occurred!\n"
          "Code: %ld\n"
          "Description: %@\n",
          (long)error.code,
          error.localizedDescription];
    } else {
      // Retrieved the result successfully

      // What is the total toll cost?
      NSString *tollCost = [NSString stringWithFormat:@"%.2f", result.tollCost.doubleValue];
      NSLog(@"Total Toll Cost: %@ %@\n", tollCost, options.currency];

      // What is the toll cost per country along the route?
      NSDictionary<NSString*, NSString*> *countryTollMap = result.tollCostByCountry;
      for (NSString *country in countryTollMap) {
        NSlog(@"Country: %@ -> Toll Cost: %@\n", country, countryTollMap[country]);
      }

      // What is the toll cost per toll system along the route?
      NSDictionary<NSString*, NSString*> *tollSystemMap = result.tollSystemMap;
      for (NSString *system in tollSystemMap) {
        NSlog(@"Toll System: %@ -> Toll Cost: %@\n", system, tollSystemMap[system]);
      }
    }
  }];
} else {
  NSLog(@"Invalid request!");
}

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.