Calculate a Truck Route
Problem: I need a route a 53-foot trailer can physically and legally drive.Prerequisites
- A HERE API key with Routing entitlement
- Confirm truck routing entitlement specifically — free-tier product coverage varies and should not be assumed
export HERE_API_KEY="..."
The code
vehicle supersedes truck. The truck object is marked deprecated in the current v8 specification. weightLimit is deprecated in favour of grossWeight. If you are reading a 2021 tutorial, you are reading deprecated parameters.Units
Verify the constraints are actually applied
Route a 410 cm vehicle through these. Any path returned is a failure.Common mistakes
SettingtransportMode=truck and stopping there. The engine is selected. The vehicle is not described.
Passing metres instead of centimetres.
Counting only the tractor’s axles. axleCount includes trailers.
Using deprecated truck[...] or weightLimit.
Hardcoding dimensions at the call site. They belong on the vehicle record.
Treating NoRouteError as a failure to retry with relaxed constraints. That produces an illegal route.
Falling back to car routing. Worse than failing.
Constraints on the server, absent on the device. The driver deviates, the phone reroutes, and the constraint set never left your backend. Push the profile to the device.
Assuming category=lightTruck waives dimension limits. It waives certain legal restrictions. Bridges do not care about your category.
Production considerations
Vehicle profiles are model data. Store them once. Validate at write time — a vehicle record with a null height should fail before it reaches a routing call. Truck routing is slower than car routing. More constraints, larger search space. Size your timeouts. Confirm entitlement before scoping a pilot. Truck routing inclusion in the free tier should be verified against your specific account. For many-to-many truck travel times, Matrix Routing accepts truck parameters. Do not loop. See Distance Matrix. For hazmat, addshippedHazardousGoods (an array of cargo types) and tunnelCategory (B|C|D|E). These are different parameters governing different things. See Hazmat Routing.
Related
Truck Routing
The full constraint set and why omitting one is silent.
Fleet Routing
Where the profile lives, and how it reaches the device.
Hazmat Routing
Cargo types, tunnel categories, and refusing to route.
Routing System Architecture
Constraints belong on records, never at call sites.
HERE documentation
- Routing API v8 reference — full
vehicleparameter table - Transport modes
Placematic
Need production HERE API keys or implementation support? Placematic is an official HERE Technologies reseller and implementation partner. We have deployed HERE truck routing into production ELD systems. Talk to us.