Calculating driving distance between two addresses
Overview
This template computes the driving distance (in meters) between two addresses.
How the template works
Workflow JSON input
{
"fromAddress": "<string, required>",
"destinationAddress": "<string, required>"
}
Workflow example JSON input
{
"fromAddress": "500 Oracle Parkway, Redwood City, CA",
"destinationAddress": "1 Apple Park Way, Cupertino, CA"
}
What it does
-
Geocoding
-
Sends the
fromAddressanddestinationAddressto Nominatim to obtain latitude and longitude for each. -
Example Nominatim request (HTTP GET):
https://nominatim.openstreetmap.org/search?q=<URL-encoded address>&format=jsonv2&limit=1 -
The first result's
latandlonare used.
-
-
Routing
-
Sends the coordinates to Open Source Routing Machine (OSRM) to get a driving route and distance (in meters).
-
Example OSRM request (HTTP GET):
https://router.project-osrm.org/route/v1/driving/<lon_from>,<lat_from>;<lon_to>,<lat_to>?overview=false&alternatives=false&steps=false
-
-
Response
-
Parses OSRM's response and returns the distance in meters (from the first route's distance field).
-
Workflow JSON output:
{ "from": "<string>", "distance": <number>, "destination": "<string>" }
-
How to use the template
-
Click Use this template button on the top right of this page.
-
Click Save button.
-
Toggle the Enable checkbox to enable the workflow definition.