HERE iOS SDK Developer's Guide

Truck Routing

The Truck Routing feature in the HERE SDK allows users to calculate routes that can be specifically travelled by trucks and commercial vehicles. Commercial vehicles typically have different regulations for their transportation routes. For example, a government may have laws that restrict trucks carrying flammable materials from traveling in a residential area. By using the Truck Routing feature, you can launch a route calculation that specifically adheres to these restrictions.

Truck Routing and the NMARoutingMode class

The NMARoutingMode class contains truck-specific properties that you should set to perform a route calculation. You need to set the the route transportation mode to NMATransportModeTruck, and then optionally set the following route properties before launching the calculation:
  • The number of truck trailers
  • The truck height
  • The truck length
  • The truck width
  • The maximum allowed truck weight
  • The category of tunnels that the truck cannot travel on
  • The truck's weight per axle
  • Hazardous goods that are transported by the truck
Note: Truck routing only supports NMARoutingTypeFastest. Other routing types are not supported.

A Route Calculation Example

  1. As with the previous routing example, create the NMACoreRouter, then create an NSArray and set its waypoints.
  2. Initialize NMARoutingMode and set the transport mode to NMATransportModeTruck.
    NMARoutingMode* routingMode = [[NMARoutingMode alloc] initWithRoutingType:NMARoutingTypeFastest transportMode:NMATransportModeTruck routingOptions:0];
    
  3. Set other truck routing properties.
    routingMode.vehicleLength = 25.25f;
    routingMode.vehicleHeight = 2.6f;
    routingMode.trailersCount = 1;
    
  4. Calculate the route by calling calculateRouteWithStops:routingMode:completionBlock:.
    [coreRouter calculateRouteWithStops:stops routingMode:routingMode
        completionBlock:^(NMARouteResult *routeResult, NMARoutingError error) {
          // If the route was calculated successfully
          if (!error && routeResult && routeResult.routes.count > 0)
          {
            NMARoute* route = [routes objectAtIndex:0];
            // Render the route on the map
            mapRoute = [NMAMapRoute mapRouteWithRoute:route];
            [mapView addMapObject:mapRoute];
          }
          else if(error)
          {
            // Display a message indicating route calculation failure
          }
        }];