The Truck Routing feature in the HERE SDK allows users to calculate routes that can be specifically traveled 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 RouteOptions Class
RouteOptionsclass contains a number of truck-specific methods and enums that you should use before performing a route calculation. To perform a truck route calculation, use the
TransportMode.TRUCKenum with the
setTransportMode(TransportMode)method to specify the route transportation type. You can also set the following truck-specific route options before performing the route calculation:
- The number of truck trailers
- The truck height
- The truck length
- The truck width
- The maximum allowed truck weight
- Hazardous goods that are transported by the truck
- The category of tunnels that the truck can travel on
- The truck's weight per axle
- Difficult turns
RouteOptions.Type.FASTESTrouting type. Other routing types are not supported.
A Route Calculation Example
- As with the previous routing example, retrieve the
CoreRouter, create a
RoutePlanand set its waypoints.
- Create a new
TransportModeshould be set to
// Create the RouteOptions and set its transport mode & routing type RouteOptions routeOptions = new RouteOptions(); routeOptions.setTransportMode(RouteOptions.TransportMode.TRUCK); routeOptions.setRouteType(RouteOptions.Type.FASTEST);
- Set other truck routing options.
routeOptions.setTruckTunnelCategory(TunnelCategory.E) .setTruckLength(25.25f) .setTruckHeight(2.6f) .setTruckTrailersCount(1);
- Set the
- Create a
CoreRouter.Listenerand then calculate the route by calling