OSRM is an open source equivalent of Google maps and its distance API. Effectively, if you provide OSRM a street network (usually from OpenStreetMap, OSM) and a destination and origin pair, it will determine the fastest route and report the distance and time taken.
This can be done with either walking, biking, or driving and modifying the assumptions for different transport profiles is possible.
This instructions are similar to those provided here.
Create a directory structure, e.g. C:\osrm-data
I will refer to this directory location as XXX
1. Install docker, for linux this will be different
2. Open a terminal and run the following code
docker build -t "cartography/osrm-backend-docker" https://github.com/cartography/osrm-backend-docker
This may require sudo as a prefix
This will build OSRM on your computer
Download my GitHub repo using the download zip option from my github. Unzip this and just copy the osrm folder (within code) into the directory of you created.
For this example we'll use a coordinate pair within the state of Delaware (because it is one of the smallest download files).
Profiles refer to the transport mode and inform OSRM the speed someone travels over surfaces etc. and penalties for intersections.
You can download the general profiles from the OSRM github page and edit them as you like.
You do not need to download the profiles if you are using the Windows setup
Run the following code (you may need to preface with sudo)
docker run -p 5000:5000 --name osrm-api -v XXX/:/osrm-data/ -v XXX/foot.lua:/osrm-build/profile.lua cartography/osrm-backend-docker:latest osrm delaware-latest
The network will take a while to build, but the result should say "running and waiting for requests"
The following code needs to be pasted into the Windows terminal
XXX/osrm/osrm-extract.exe XXX/delaware-latest.osm.pbf -p XXX/osrm/profiles/foot.luab
XXX/osrm/osrm-contract.exe XXX/delaware-latest.osrm
XXX/osrm//osrm-routed.exe XXX/delaware-latest.osrm --port 5000
The network will take a while to build, but the result should say "running and waiting for requests"
Effectively you're done. You've set up OSRM on your computer and now it is waiting for queries.
To test, try pasting the following into your browser url
http://localhost:5000/route/v1/walking/-75.556521,39.746364;-75.545551,39.747228?overview=false
Note that this is the url of the server, the mode, the lon & lat of the origin ; then the lon & lat of the destination
To run this with a large number of queries you need to generate wrapper code and a set of origin-destination points to run. Examples of such code can be found here: