How to Calculate Tolls for any route — Map Independent Toll API

Last updated on Jul 30, 2021 · 5 minutes

TollGuru Toll API now allows individuals and businesses to calculate toll costs for routes from any mapping provider

TollGuru released Map Independent Toll API that allows trucking fleets, logistic companies, ride-shares, car rentals, and everyone else to calculate tolls for routes from a mapping provider of their choice. The companies can upload a route polyline from mapping providers such as Google, Bing, MapBox, Apple Map, HERE, TomTom, Waze, ESRI, MapQuest, JawgMaps, Trimble, PTV, MapmyIndia, Yandex, Michelin, Baidu, Gaode and receive toll information specific to the time of travel, payment type, vehicle type and vehicle characteristics such as axle count, height and weight.

The companies can also upload a route polyline from their custom mapping solutions such as those created using Open Source Routing Machine or GraphHopper Direction Map API. They can also receive tolls for their custom routing solution created using R tree, network graph, A* or any shortest path algorithm, map data from OSM or any other datasources such as ArcGIS.

Why is it hard to calculate tolls for a route polyline from any mapping service

TollGuru developed a data abstraction model that works with each specific implementation of routing by different mapping providers. This allowed us to implement map independent or map-agnostic toll calculation algorithms.

To elucidate how different mapping platforms create polyline for the same road in a slightly different manner, let’s consider New Rochelle Toll Plaza on the New York Thruway. As shown in the image below, the toll plaza (now rebuilt and moved further north) had 14 lanes to collect tolls in northbound direction:

New Rochelle toll barrier — Historical Imagery from Google Earth (The plaza has since been rebuilt)

One way to represent all toll locations would be to create 14 links (node pairs) corresponding to the 14 northbound lanes to represent the fact that vehicles need to pay a toll at each plaza based on their vehicle type and time of travel. As shown in the image below, OSM volunteers chose to create 14 links (way) at this location. A route polyline in northbound direction would include a link from the 14 links. The northbound lanes are shown under the elongated brown oval in the image below.

Image for post
OSM representation of New Rochelle toll barrier. 14 toll gantries are shown as 14 ways

Other mapping service providers such as Google, HERE, Bing, TomTom represent the northbound road in a different manner. These mapping services chose to code one or two links instead of 14 links. The northbound lanes are shown under the brown oval shape in following images:

Image for post
Google Map (left) and HERE map (right) representation of the northbound lanes. Unlike OpenStreetMap, Google and HERE used one link (polyline) to represent 14 toll toll plazas and lanes
Image for post
TomTom (left) and MapQuest (right) representation of the northbound lanes. Unlike OSM, TomTom and MapQuest use two links (polyline) to represent 14 toll toll plazas
Image for post
Bing (left) and Waze (right) representation of the northbound lanes. Unlike TomTom, MapQuest and Bing that use two links, Waze, Google, HERE use one link (polyline) to represent 14 toll toll plazas
Image for post
Apple Maps(left), Yandex (middle), wikimapia (right) representation of the northbound lanes. Like Waze, Google, HERE maps, Apple maps, Yandex and wikimapia use 1 link (polyline) to represent 14 toll toll plazas

Each of the mapping services have a different conceptual data models of the physical world. For example, in OpenStreetMap each feature is one or more geometries with attached attribute data. Since each mapping service uses its own conceptual model to create online maps, it differs from other maps.

As shown in image below, Google, HERE and OSM routing API provide different polyline for the same road. The polyline from HERE map is shown in purple color and is east of polylines from Google (shown in blue color) and OSM (shown in green color).

Image for post
Polylines from HERE map Route API, Google Map Direction API and OSM. TollGuru Toll API calculates toll information for each of the mapping platforms

TollGuru Toll API Solution

TollGuru REST API has developed a conceptual model for its proprietary algorithms to work with each of the mapping platforms described earlier. The Toll API endpoint to receive polyline from any mapping service is:

https://dev.tollguru.com/v1/calc/route

The tolls are returned for payment types such as transponders (e.g. E-ZPass, TxTag, etc.), cash, license plate toll (Pay by Mail, Pay by Plate etc.), Prepaid card (e.g. Nexpress, Nexus Card, etc.) and credit card in the specific currency. For example, tolls in United States are returned in dollars, Mexico in Mexican Peso, etc by default. The toll response includes the following

{
  "summary": { ...
    },
    "departure_time": 1551541566
  },
  "route": {
    "hasTolls": true,
    "costs": {
      "fuel": 4.31,
      "otherCost": 10,
      "tag": 2.46,
      "cash": false,
      "licensePlate": 3.69,
      "creditCard": false,
      "prepaidCard": 2.46
    },
    "tolls": [
      {
        "id": 131030,
        "lat": 33.00225,
        "lng": -96.77585,
        "name": "Coit Main Lane Gantry (MLP7)",
        "road": "President George Bush Tpke",
        "state": "Texas",
        "type": "barrier",
        "tagCost": 1.34,
        "tagPriCost": 1.34,
        "tagSecCost": false,
        "cashCost": false,
        "licensePlateCost": 2.01,
        "prepaidCardCost": 1.34,
        "creditCardCost": false,
        "currency": "USD",
        "tagPrimary": [
          "TxTAG",
          "TollTag",
          "EZ TAG",
          "K-Tag"
        ],
        "tagSecondary": [],
        "licensePlatePrimary": "ZipCash",
        "licensePlateSecondary": false,
        "discountCarDetails": false,
        "discountCarType": false,
        "discountTruckDetails": false,
        "discountTrucks": false,
        "height": "No"
      }
    ]
  }
}

The tolls are specific to vehicle specified. If the vehicle travels on a toll road (such as Pennsylvania turnpike) where the tolls depend on axles and vehicle weight, tolls are returned for the specific weight. The following image shows some of the attributes about toll information.

Image for post

Please get in touch with us at api@tollguru.com if you’d like to schedule a demo or to integrate TollGuru Map Independent Toll API in your product.

About TollGuru

TollGuru, a product of MapUp Inc., calculates tolls for all toll roads, bridges, and tunnels in the United States, Canada, Mexico and India for all vehicle types. TollGuru provides smart toll exchange and navigation platform.

TollGuru mapping service is designed for real America — where both costs and times figure in route decisions. TollGuru shows the cheaper routes not shown by any other mapping applications such as Google maps, Apple maps, Waze, HERE maps, MapQuest, Scout GPS, Garmin, etc. Unlike other mapping applications, our routes consider two vectors — travel time and travel cost (fuel and tolls) to provide a real-time decision platform.