Delivery & Distance Matrix Routing with OSRM Table API
Compute driving travel times and distances across hundreds of Canadian coordinate pairs in a single HTTP request. Built for dispatch engines, last-mile delivery, and vehicle routing problems (VRP).
Why Use the OSRM Table Service?
When dispatching deliveries or calculating travel times between multiple warehouses and delivery stops, sending individual point-to-point route requests creates extreme network overhead and bill shock. For $N$ sources and $M$ destinations, point-to-point routing requires $N \times M$ round trips.
The OSRM Table API computes the complete $N \times M$ matrix of travel durations (in seconds) and distances (in meters) in a single sub-100ms API call using pre-calculated OpenStreetMap contraction hierarchies.
Example: Windsor–Québec Commercial Corridor
The Windsor–Quebec City corridor represents over 60% of Canadian commercial freight. Here is an example query calculating the driving time matrix between Toronto, Kingston, Ottawa, and Montréal in one request:
GET https://geo.jerielbenavides.com/table/v1/driving/-79.3832,43.6532;-76.4860,44.2312;-75.6972,45.4215;-73.5673,45.5017?annotations=duration,distance
Matrix Response Schema
The OSRM Table endpoint returns symmetric 2D arrays for durations (in seconds) and distances (in meters):
{
"code": "Ok",
"durations": [
[0.0, 9340.2, 16120.5, 19800.8],
[9280.1, 0.0, 7200.4, 10540.2],
[16050.8, 7150.2, 0.0, 7300.6],
[19720.4, 10480.1, 7250.3, 0.0]
],
"distances": [
[0.0, 262400.0, 451200.0, 542100.0],
[261900.0, 0.0, 196800.0, 287500.0],
[450800.0, 196200.0, 0.0, 198400.0],
[541500.0, 286900.0, 197900.0, 0.0]
],
"sources": [
{"hint": "...", "location": [-79.3832, 43.6532], "name": "Bay Street"},
{"hint": "...", "location": [-76.4860, 44.2312], "name": "Princess Street"},
{"hint": "...", "location": [-75.6972, 45.4215], "name": "Wellington Street"},
{"hint": "...", "location": [-73.5673, 45.5017], "name": "Boulevard René-Lévesque"}
],
"destinations": [ ... ]
}
Python Dispatch Matrix Snippet
import requests
BASE_URL = "https://geo.jerielbenavides.com"
API_KEY = "your_server_key_here"
# List of pickup / delivery points (lon, lat)
locations = [
(-79.3832, 43.6532), # Toronto
(-76.4860, 44.2312), # Kingston
(-75.6972, 45.4215), # Ottawa
(-73.5673, 45.5017), # Montreal
]
coord_str = ";".join(f"{lon},{lat}" for lon, lat in locations)
url = f"{BASE_URL}/table/v1/driving/{coord_str}"
res = requests.get(
url,
headers={"Authorization": f"Bearer {API_KEY}"},
params={"annotations": "duration,distance"},
timeout=5
)
res.raise_for_status()
data = res.json()
# Durations matrix in minutes
durations_min = [[round(sec / 60.0, 1) for sec in row] for row in data["durations"]]
print("Duration Matrix (minutes):")
for row in durations_min:
print(row)
Driver Waypoints Never Logged or Stored
Dispatch routes and delivery sequences expose sensitive corporate trade secrets: customer locations, delivery volumes, and driver schedules. When using Geo Service, our server operates with zero coordinate logging on bare-metal Canadian hardware in Beauharnois, Quebec. Your fleet telemetry remains 100% confidential.