Using TomTom Location Services to Develop Fleet Logistics Applications
TomTom Developer Portal·Oct 02, 2020

Using TomTom Location Services to Develop Fleet Logistics Applications

TomTom Developer Portal
TomTom Developer Portal
Oct 02, 2020 · 9 min read

TomTom mapping and routing APIs and the TomTom Maps SDK have many useful features for developers building fleet management and logistics applications. In this article, we'll highlight the API and SDK features you can use to build these apps.

Most fleet logistics and mapping applications concentrate on short-range, multi-waypoint routing. This is fine for common scenarios of delivery, ridesharing, or taxi services, but not much help with the challenges specific to long-range fleet routing.

Long-range logistics deals with long routes, sometimes over many days and multiple countries. A static map doesn't reflect changing conditions on routes that can take days to complete. Mistakes can be costly.

TomTom mapping and routing APIs and the TomTom Maps SDK have many useful features for developers building fleet-routing applications. In this article, we'll highlight these APIs and SDK features.

What are the Challenges in Long Range Fleet Logistics?

What do we mean by long-range fleet logistics? Okay, we’re routing trucks… what else? Organizing and running more than a couple of trucks over very long distances introduces quite a few areas of complexity. Let’s look at some of these areas.

Static maps don’t cut it when you need dynamic updates using real-time traffic data to handle unexpected events. You need to allow for very large changes of routes around accidents, road works, road closures, bushfires or weather events – floods, hurricanes, snow, and ice. You need to save drivers time and guesswork with real-time re-routing to avoid expensive stoppages or inefficient routes.

Simple vehicle routing for the shortest distance may not work as you need to consider factors such as vehicle weight (weight limits on some roads or bridges) and size (height, width, and length matter as trucks need to fit under bridges or fit through tunnels) and cargo (hazardous cargo is not allowed on some roads).

Also important is the type of load you’re hauling: some roads, bridges and tunnels may not allow dangerous goods.

Routes can cross counties, states, or multiple countries. Some routes involve various taxes, charges, and not just road tolls. Most countries require drivers to maintain logs of hours and distance driven, as well as to record regular and scheduled rest breaks. For example, this capability could be useful for Federal Motor Carrier Safety Administration (FMCSA) ELD Mandate compliance. Electronic logging devices (ELDs) are used to record driver Record of Duty Status (RODS) to ensure compliance with Hours of Service (HOS) requirements.

In addition to helping maintain mandatory logging and compliance, using real-time location updates can help predict estimated time of arrival (ETA), which can minimize idle time and costs as drivers wait to unload and reload. It also helps determine estimated travel time, which enables optimizing fleets at the planning stage, an important feature for long-haul logistics.

Finally, handling a fleet of trucks introduces the need to consider the driver’s rosters, availability, home locations, swapping trailers or rigs, as well as allowance for maintenance schedules. Good management of your fleet helps keep drivers safe and efficient, and results in improved staff retention, not to mention making your whole operation smoother and more profitable.

image of=

How Can TomTom Services Help?

Let’s see how TomTom services can help you build capability into a long-range fleet logistics application by looking at each of the challenges we’ve discussed.

For efficient routing, let’s start with the TomTom Routing API. Like with most TomTom API features we'd suggest using API Explorer. This is a try-it-yourself feature that lets you try out each API call, test different options, and see the actual API responses, all without needing to knock up a shell app or write a line of code. (Users of Swagger already know how app design benefits from this technique).

Go to the Routing API and Extended Routing API documentation and select Routing > Calculate Route. Under Request data, click API Explorer, then click either GET or POST:

fleetapps1

Click the red "Try it out" button when ready to test the feature. Next, for our fleet routing, perhaps start with departAt or arriveAt, to set either the departure time or the ETA. Set travelMode to truck, and vehicleCommercial to true.

Some other useful options include truck dimensions — these are vehicleWeight, vehicleAxleWeight, vehicleLength, vehicleWidth, and vehicleHeight. You’ll need to do some exploring here, as there are many options, making the API suited to a variety of applications. Again, the API Explorer feature is an ideal place to start as it gives you a leg up when forming ideas for building your own app.

Configure the response format by setting contentType to either JSON or XML, whichever you prefer. When ready to go, click the red "Execute" button to see the results. Here’s a typical generated route shown as JSON:

{
  "formatVersion": "0.0.12",
  "routes": [
    {
      "summary": {
        "lengthInMeters": 1146,
        "travelTimeInSeconds": 169,
        "trafficDelayInSeconds": 0,
        "departureTime": "2020-12-19T16:37:07+01:00",
        "arrivalTime": "2020-12-19T16:39:56+01:00"
      },
      "legs": [
        {
          "summary": {
            "lengthInMeters": 1146,
            "travelTimeInSeconds": 169,
            "trafficDelayInSeconds": 0,
            "departureTime": "2020-12-19T16:37:07+01:00",
            "arrivalTime": "2020-12-19T16:39:56+01:00"
          },
          "points": [
            {
              "latitude": 52.5093,
              "longitude": 13.42937
            },
            {
              "latitude": 52.50904,
              "longitude": 13.42913
            },
            {
              "latitude": 52.50895,
              "longitude": 13.42904
            },
            ...
          ]
        }
      ],
      "sections": [
        {
          "startPointIndex": 0,
          "endPointIndex": 24,
          "sectionType": "TRAVEL_MODE",
          "travelMode": "truck"
        }
      ]
    }
  ]
}

Next, you can take a look at vehicleMaxSpeed, vehicleEngineType, and currentFuelInLiters — these are a great help for calculating fuel cost or planning fuel stops.

TomTom has worked hard on their Combustion Consumption modelling. Just ensure vehicleEngineType is set to combustion.

Once you generate more accurate fuel consumption estimates for your routes, these can help you make more accurate quotes for new work. Put alongside the actual fuel use, both help minimize fuel theft, as well as gauge various drivers’ efficiency.

Time to get visual: let’s get those routes we created earlier and display them on a map using the TomTom Map Display API and TomTom Maps SDK for Web. Again, we’d recommend starting with API Explorer to try the different options for various Raster or Vector maps until you find what map type you’d prefer.

At this point, you need to sign up for a free TomTom Developer Key which lets you try out the example code. Once you got your key, use it in place of <your-tomtom-API-key> in each code example, like this:

<script>
      tt.setProductInfo(
          '<your-product-name>', 
          '<your-product-version>');
      tt.map({
          key: '<your-tomtom-API-key>',
          container: 'map',
          style: 'tomtom://vector/1/basic-main'
      });
    </script>

For instance, this example (output shown below) demonstrates how to display a route on a map:

fleetapps2

You can also customizeTomTom Maps using the new Map Styler from the Map Display API. Apart from day-time or night-time styles, it’s a great way to make your new apps customized to the needs of your drivers and organizational planning.

Next, look at the TomTom Traffic API to hook into a real-time traffic feed. Like all TomTom examples, it focuses on just a couple of key features, which saves it from getting too cluttered with code. This example shows how to generate map layers with traffic incidents, traffic flow, or both:

fleetapps3

Now we’ll see how to use the Point of Interest (POI) search to help identify important points: fueling stations, regulatory stops (weighbridge scales, inspections, borders), rest stops, as well as possible problems along the way, such as bridges and tunnels.

Walk through the following example to see how to search for a particular POI. Just choose POI Search for type. Check out the various language options, too: this is a great demo of multi-language support.

fleetapps4

You can also add custom map layers to display special features, highlight route sections (like tunnels that might have restrictions), or overlay external data (such as weather or comments on local traffic conditions) that might help your drivers. For example, try to change visibility of layers or add a heat map layer.

Asset and vehicle tracking are another set of features commonly used for fleet management. There are three APIs of interest here:

  • The TomTom Geofencing API lets you define enclosed areas, or geofences, within a map. These can be boundaries around a route, a neighborhood, or around key points along the route such as the originating warehouse or the delivery destination.

  • The Location History API allows you to define objects (such as trucks, trailers, or loads) and track these objects or list their location.

  • Finally, the Notifications API allows you to create apps that alert, say, a warehouse when a truck is nearing it, or alert you if a rig goes off course or reaches a scheduled rest stop.

Together these TomTom services can provide real-time, up to the minute estimates of ETA for delivery, or help you coordinate with other shipping, warehouse, and factory schedules. Use these to automate logs and provide audits for your drivers and loads.

Linked to weather, road, and traffic conditions, these services can provide your drivers with real-time alerts of icy weather, hail, thunderstorms, or other events. You’ll keep your drivers, loads, and rigs safe, and you’ll give your customers the up-to-date advice on delivery times.

Next Steps

TomTom services will really help accelerate your development. Start with API Explorer for each feature, try out online examples, download the code – and don’t forget to register for a free developer API key.

Build web apps with TomTom Maps SDK for Web using HTML and JavaScript, Angular, or other frameworks. Alternatively, develop native mobile apps with TomTom Maps SDK for iOS or Maps SDK for Android.

Here are a few blog posts that might help you get started: