Mastering Taxi Dispatch: The API Revolution

06/01/2021

Rating: 4.1 (12356 votes)

In the bustling landscape of modern urban transport, the ability to swiftly connect a passenger with the nearest available taxi is paramount. Gone are the days of aimless hailing; today’s commuters expect efficiency, transparency, and immediate service. But what's the secret sauce behind these seamless operations? It's largely down to sophisticated application programming interfaces (APIs), particularly those capable of calculating distances and travel times with remarkable precision and speed. This article delves into the technological backbone that powers efficient taxi dispatch systems, with a particular focus on the Google Distance Matrix API and its pivotal role in getting you the nearest ride.

How does the Gett API work?
The Gett platform is dynamic and works with multiple suppliers with different capabilities and restrictions to get the best of Gett API and for smooth order requests you will have to request orders based on "Company settings" and "Gett products". HTTPS - All requests should be made using the HTTPS protocol.

Imagine a world where finding a taxi is as simple as a tap on your smartphone. This convenience is not magic; it’s the result of complex algorithms working in harmony with powerful mapping services. At the heart of many leading ride-sharing and taxi apps lies a fundamental challenge: determining which driver is closest to a passenger, not just as the crow flies, but in terms of actual travel time, accounting for real-time traffic conditions. This is where the Google Distance Matrix API, specifically its updated Compute Route Matrix endpoint within the broader Routes API, steps in as an indispensable tool.

Table

The Google Distance Matrix (Compute Route Matrix) API: An Overview

A distance matrix API is a web service that returns travel times and distances for multiple locations, efficiently checking the reachability of coordinates from each other. It's designed to filter points by travel time and underpin complex optimisation problems. Typically, it provides a matrix where each row represents an origin, each column a destination, and the values within the matrix detail the travel time and/or distance between them. Google's offering, known as Compute Route Matrix, is a cornerstone of the Routes API, a suite of tools that aid in navigation, Estimated Time of Arrival (ETA) calculation, and route finding.

The terms 'Distance Matrix API' and 'Compute Route Matrix' are often used interchangeably, primarily because the latter is the updated and more efficient successor to the original Google Distance Matrix API, which is slated for deprecation on March 1, 2025. This evolution ensures that developers have access to the most accurate and performant tools for their applications.

How the Distance Matrix Works: A Simplified Example

Consider a scenario where a taxi company has three drivers (A, B, C) and needs to determine their distances to three potential passenger pickup locations (X, Y, Z). The Compute Route Matrix API can process this 'matrix' of origins and destinations. For instance, if you have three origins and three destinations, the API will effectively make nine parallel route calculations (A to X, A to Y, A to Z, B to X, and so on) and present the results in a structured table. This table, or distance matrix, allows for quick lookups, revealing the travel time and distance for the fastest route between each origin-destination pair, crucially factoring in real-time traffic.

One of the most compelling features of the Compute Route Matrix endpoint is its remarkable efficiency. It can provide results for numerous routes in roughly the same time it takes the Compute Routes endpoint to return data for a single route. This parallel processing capability is a game-changer for applications requiring rapid decision-making, such as taxi dispatch. However, it's important to note that while it provides travel times and distances, it doesn't offer route geometries (the actual lines on a map). If you need to draw a route polyline, a separate call to the Compute Routes endpoint would be necessary.

Google Distance Matrix API Use Cases in Transport

While the Google Distance Matrix API has broad applications, its utility in the transport sector, particularly for taxi and ride-sharing services, is profound. Its primary uses include:

  • Nearest Available Vehicle: This is the bread and butter of ride-sharing platforms like Uber and Lyft. By calculating the travel time from each available driver to a user's location, these platforms can display a sorted list of vehicles, allowing passengers to choose based on their preferences (e.g., quickest arrival, cheapest fare).
  • Lookup Table for Route Optimisation: For more complex fleet management and dispatch systems, distance matrices serve as crucial data inputs for route optimisation algorithms. Solvers like Google OR Tools use this data to determine the most efficient routes for a fleet of vehicles, ensuring timely pickups and drop-offs.

These applications underscore the API's role in facilitating rapid matching and efficient routing, which are critical for delivering a superior customer experience in the competitive taxi market.

An Example: Finding Your Nearest Taxi

Let's walk through a simplified example of how a taxi app might use the Compute Route Matrix endpoint. Suppose a passenger at the "Residence Inn" in downtown Vancouver wants a taxi. Three taxis are available in "West End", "Kitsilano", and "Mount Pleasant". The app needs to find the quickest pickup.

The request to the API would specify the passenger's location as the single origin and the three taxi locations as destinations. Key parameters would include travelMode: "DRIVE" and routingPreference: "TRAFFIC_AWARE" to ensure real-time traffic is considered. A departureTime can also be specified to account for predicted traffic conditions at a future time.

The API's response would return an array of elements, each detailing the distance and duration from the origin (passenger) to one of the destinations (taxis). For instance, an element might look like this:

{
"originIndex": 0,
"destinationIndex": 1,
"status": {},
"distanceMeters": 1861,
"duration": "379s"
}

Here, originIndex refers to the passenger's location, and destinationIndex refers to one of the taxis. distanceMeters provides the distance in metres, and duration gives the travel time in seconds. By analysing these results, the taxi company can instantly identify the nearest taxi based on driving time, allowing them to dispatch the most suitable vehicle.

Building a Basic Taxi Dispatch System (Conceptual Approach)

The principles behind building a taxi dispatch system using the Google Distance Matrix API are elegant in their simplicity, yet powerful in their execution. A typical implementation would involve:

  1. Capturing User Location: The user's current location is obtained, often via a map interface or address autocomplete.
  2. Identifying Available Taxis: A list of currently available taxis, along with their GPS coordinates, is maintained.
  3. Calling the Compute Route Matrix: The user's location becomes the origin, and all available taxis become destinations. The API is queried to get travel times and distances for all origin-destination pairs.
  4. Sorting and Matching: The API's response, which might be unsorted, is then processed. Taxis are sorted by their duration (travel time) from the user's location, allowing the system to identify the absolute nearest taxi.
  5. Displaying Route and Details: Once the nearest taxi is identified, a separate call to the Compute Routes API can be made to get the actual route polyline, which is then displayed on the map, showing the passenger the taxi's path and estimated arrival time.

This workflow ensures that passengers are matched with the most efficient pickup option, enhancing the user experience and optimising fleet utilisation for the taxi operator. Key components in such a system would include map integration, location search (e.g., Google Places Autocomplete), and robust logic to process and display the API responses.

Navigating the Limitations and Pricing of Google Distance Matrix API

While incredibly powerful, the Compute Route Matrix endpoint does come with certain limitations and a pricing structure that warrants careful consideration for large-scale operations.

API Limits

The API has specific caps to prevent abuse and manage computational load:

  • Origins & Destinations: A maximum of 25 origins or 25 destinations per request.
  • Rate Limit: Up to 3,000 elements per minute (EPM), where elements = number of origins × number of destinations.
  • Place ID or Address: Maximum of 50 origins and destinations combined when using Place IDs or addresses.
  • Traffic-Aware Routing: When routingPreference: "TRAFFIC_AWARE_OPTIMAL", requests are limited to 100 elements.
  • Transit Mode: When travelMode: "TRANSIT", requests are limited to 100 elements.
  • General Limit: For all other cases, requests can include up to 625 elements (e.g., 25 origins x 25 destinations).

These limits can pose challenges for dispatch systems needing to process thousands of drivers and passengers simultaneously. To circumvent this, strategies like splitting large matrices into smaller 25x25 chunks or pre-filtering destinations using K-nearest neighbour (k-NN) search to narrow down the closest locations before calling the API are often employed.

Pricing Tiers

Billing for the Compute Route Matrix endpoint is element-based, not request-based. A single request with one origin and three destinations, for example, is billed for three elements. There are three pricing tiers:

TierDescriptionTypical Cost (CPM)
BasicSupports up to 25 origins and 25 destinations. No real-time traffic.$5.00
AdvancedEnabled with TRAFFIC_AWARE or TRAFFIC_AWARE_OPTIMAL routing, and side-of-road/heading/vehicle stopover modifiers.$10.00
PreferredAny request using two-wheeled vehicle routing, toll calculation, or route modifiers (e.g., 'avoid tolls').$15.00

As evident, costs can escalate rapidly. A maximum 25x25 matrix at the Basic tier, for instance, would cost $5 CPM x 625 elements = $3.125 per request. For high-volume services, this makes cost-effective API usage a significant consideration, reinforcing the need for smart search space pruning.

How do I get the nearest taxi to a user's location?
We can get the nearest taxi to the the user's location by accessing the first element of the newList array with newList. Compute Routes API Call Once we get the nearest taxi, the fetchRoute() method uses the Compute Routes endpoint of the Routes API to display the driver's driving route to the user's pickup location.

Alternatives to Google Distance Matrix API

Given the cost and size limitations of Google's offering, many businesses explore alternative distance matrix API providers. These alternatives often present different trade-offs in terms of features, pricing, and scalability.

OSRM Table API (Open Source Routing Machine)

OSRM is a free and open-source alternative that leverages OpenStreetMap (OSM) data. Its main advantages are its zero cost (if self-hosted) and the ability to handle larger matrices by allocating more memory and compute. However, its significant drawback is the lack of real-time traffic updates, a crucial feature for dynamic taxi dispatch where congestion can heavily impact travel times.

Commercial Alternatives with Real-Time Traffic

For services requiring real-time traffic data, other commercial APIs are available:

  • HERE Matrix Routing Service: Supports up to 10,000 origins and destinations, making it suitable for very large-scale operations. It is priced at approximately $4.60 CPM per element.
  • TomTom Matrix Routing Service: More affordable at around $2.60 CPM per element, but comes with a stricter limit of 2,500 elements.

Each of these alternatives presents a different balance of scale, features, and cost, allowing businesses to choose the best fit for their specific operational needs and budget.

Integrating with the Gett API: A Business-Centric Approach

While Google's Distance Matrix API provides the foundational data for calculating distances and times, platforms like Gett offer a more comprehensive, business-to-business API for direct taxi and delivery service integration. The Gett Business API is designed to embed Gett's solutions directly into a company's operational processes, handling the entire lifecycle of a ride or delivery.

Unlike the Google API, which focuses solely on geographical data, the Gett API provides endpoints for a wide array of functionalities essential for a taxi company:

  • Request Ride/Delivery: On-demand or pre-booked, including multi-passenger, multi-stop rides, and multi-drop-offs for deliveries.
  • Update Order: Modify existing ride or delivery requests.
  • Get Order Details: Retrieve comprehensive information about ongoing or completed orders.
  • Get Supplier Details and Location: Access information about the assigned driver and their current location.
  • Get a Price Estimation: Obtain fare estimates before booking.
  • Get an Order Receipt: Access post-ride calculations and receipts.
  • Cancel Order: Cancel a booked ride or delivery.

The Gett API operates over HTTPS, requires scope-based authorisation with Bearer ACCESS_TOKEN in headers, and expects JSON format for requests and responses. It also implements rate limits (defaulting to 16 requests per second per account) to ensure system stability. A key piece of advice from Gett is to avoid hardcoding Product IDs and their settings, as these can change dynamically based on suppliers and locations. This highlights Gett's role as a dynamic platform connecting various suppliers, offering a complete solution beyond just distance calculations.

In essence, if Google Distance Matrix is the engine that tells you how far and how long, Gett's API is the entire vehicle, handling booking, dispatch, tracking, and billing, making it a powerful tool for businesses looking to integrate a full-fledged taxi service into their operations.

Conclusion

The efficiency of modern taxi dispatch systems hinges on the intelligent application of powerful APIs. The Google Distance Matrix API, particularly its Compute Route Matrix endpoint, stands out as a critical component for determining the nearest available taxi with high accuracy, taking real-time traffic into account. Its ability to process multiple origin-destination pairs simultaneously provides the speed required for instant matching in a fast-paced environment.

However, understanding its limitations and pricing models is crucial for sustainable, large-scale deployment. For businesses looking beyond geographical calculations, platforms like the Gett API offer a comprehensive suite of functionalities to manage the entire ride lifecycle, from booking to completion. Whether building a system from the ground up with foundational mapping APIs or integrating a ready-made service, the intelligent use of these technological marvels is what truly drives the modern taxi industry forward, ensuring passengers always get their nearest ride with unparalleled efficiency.

Frequently Asked Questions (FAQs)

Q: What is the primary purpose of the Google Distance Matrix API in taxi dispatch?

A: The primary purpose is to efficiently calculate the travel time and distance between a passenger's location and multiple available taxis, considering real-time traffic, to identify the nearest and most suitable vehicle for dispatch.

Q: How does real-time traffic data impact taxi dispatch using these APIs?

A: Real-time traffic data is crucial as it allows dispatch systems to calculate more accurate Estimated Times of Arrival (ETAs) and choose routes that avoid congestion, leading to faster pickups, more reliable service, and better customer satisfaction. The TRAFFIC_AWARE routing preference in Google's API enables this.

Q: Are there cost-effective alternatives to Google's API for taxi services, especially for large volumes?

A: Yes, alternatives exist. Open-source options like OSRM are free to use if self-hosted but lack real-time traffic. Commercial alternatives like HERE Matrix Routing Service and TomTom Matrix Routing Service offer real-time traffic data, often with different pricing models and higher element limits, which can be more cost-effective for very large volumes after careful analysis.

Q: How does the Gett API differ from Google's Distance Matrix API?

A: Google's Distance Matrix API provides foundational geographical data (distances and travel times). In contrast, the Gett API is a comprehensive business-to-business platform that handles the entire ride or delivery lifecycle, including booking, order updates, driver tracking, price estimation, and cancellations. It's designed for direct integration of Gett's ride-hailing services into a company's operations, rather than just providing mapping data.

Q: What are the main challenges when implementing a taxi dispatch system with these APIs?

A: Key challenges include managing API call limits and associated costs, especially for high-volume operations. Efficiently pruning the search space (e.g., using k-NN search to pre-filter closest drivers) before making API calls is vital to optimise usage and minimise expenditure. Ensuring real-time data accuracy and robust error handling are also critical.

If you want to read more articles similar to Mastering Taxi Dispatch: The API Revolution, you can visit the Transport category.

Go up