This document will guide you through creating routable graphs which will be stored on S3 and used by this application(s).
We want to take an OSM file, e.g. europe-latest.osm.pbf remove all the
contents which are outside of our operating areas and apply local changes as well.
This will shrink the OSM file size tremendeously, creates a smaller routing graph and OSRM can load the smaller graph much faster. (Also it requires less memory and cpu, which leads to cost-friendly EC2 instances.)
You will need to get the data (if needed) and then trigger the building/updating of the graph. The current process to create a driving and walking graph from scratch takes approximately 4.5 hours (processing), so it's recommended to trigger it on AWS, but you can also do it manually. Both described below.
(the explanation here is relevant if you need to create graphs for a new region that has not been processed before)
These are the steps to create a small OSRM graph.
First a OSM dataset is required, which covers all the regions we are operating in (including the fake operating area in London) or want to run simulations.
We will need all OSM files which cover our regions. You could download a large area or multiple smaller ones.
The short example above uses daily snapshots of different areas provided by Geofabrik. The whole planet is provided by different soures, an overview can be found here.
This is achieved by a bash-script inside of the container.
Note: It is recommendent to use the .pbf files as they are much smaller.
If there are new regions to be added, please look at this file and add the URL.
The second step defines the .geojson file, to include only the features which are
within the described MultiPolygons.
We need to provide the GeoJSON files for all areas we operate in or want to run simulations. For each region a separate file is present here
After making a change to these files or adding a new area, see the section below on how to update
the final routing area merged.geojson.
If you don't need to update these files, you can skip this step.
Enter the helper-scripts directory and install geojson-clipping:
yarn install
Merge all region speficic areas into one routing area for the whole planet:
geojson-clipping union ../graph-builder/data/geojson > ../graph-builder/data/geojson/merged.geojson
Now you should have one big MultiPolygon in merged.geojson that will be used to clip our OSM
dataset to only include the features of our desired routing area.
Be sure to commit your changes to this file.
geojson files:You could also create a bounding box around your region on geojson.io.
Some OSM nodes, ways and/or relations may require local changes for a better routing experience. For example the vehicle depot could be in an area with restricted access (Example) and we want to be able to route on that specific street.
It is necessary to modify the OSM data and generate a new dataset before proceeding. For those use-cases we can create OSM-Change
files (.osc).
An example can be found here - we change the access=private key-value to access=yes
and keep all other elements in place.
Note: If you ever need to create a new changeset, follow these steps:
.osc file based on the example: cp ./data/changesets/example.osc /data/changesets/what-you-change.oscbuild_graph_YYYY_MM_DD (the date part will be used for the graph filename). Tip: also commit the changes to osrm-routing-core (last step) in the same push if you want to use it once merged to master.Note: Every push to this branch format will trigger a new build in all stages.
(Given your data is already present and you only need to update the graph)
In order to run the script, you require Docker 1.12+, awscli and eventually
a text editor.
Install the missing parts via brew:
brew cask install docker
brew install awscli
After this build the docker container (cd into this folder first):
docker build -t osrm-data -f Dockerfile .
Or pull the build from the built image on Docker Hub (synced with master):
docker pull tor2tor/d2d-directions:preprocessor && docker tag tor2tor/d2d-directions:preprocessor osrm-data
Run the docker container to automatically:
This can be achieved via:
docker run -v $(pwd)/graph-builder/data:/data -it osrm-data
Note: You need to execute this command inside this folder.
If you only want to do specific things run:
docker run -v $(pwd)/graph-builder/data:/data -it osrm-data bash ./bootstrap.sh -h
It will print the usage of the script.
Afterwards, you need to zip the graphs and upload them to AWS S3 to their respective buckets (driving/walking):
# compress the files first before uploading
find graph-builder/data/osrm/driving -name "*.osrm*" -execdir tar -zcvf data/driving_graph.tgz -C data/osrm/driving {} +
find graph-builder/data/osrm/walking -name "*.osrm*" -execdir tar -zcvf data/walking_graph.tgz -C data/osrm/walking {} +
# upload archive to buckets per environment
aws --profile d2d-drt-devel s3 cp graph-builder/data/driving_graph.tgz s3://d2d-directions-driving-dev/v5.21.0/graph_$(date +"%Y_%m_%d").tgz
aws --profile d2d-drt-devel s3 cp graph-builder/data/walking_graph.tgz s3://d2d-directions-walking-dev/v5.21.0/graph_$(date +"%Y_%m_%d").tgz
aws --profile d2d-drt-sandbox s3 cp graph-builder/data/driving_graph.tgz s3://d2d-directions-driving-sandbox/v5.21.0/graph_$(date +"%Y_%m_%d").tgz
aws --profile d2d-drt-sandbox s3 cp graph-builder/data/walking_graph.tgz s3://d2d-directions-walking-sandbox/v5.21.0/graph_$(date +"%Y_%m_%d").tgz
aws --profile d2d-drt-staging s3 cp graph-builder/data/driving_graph.tgz s3://d2d-directions-driving-staging/v5.21.0/graph_$(date +"%Y_%m_%d").tgz
aws --profile d2d-drt-staging s3 cp graph-builder/data/walking_graph.tgz s3://d2d-directions-walking-staging/v5.21.0/graph_$(date +"%Y_%m_%d").tgz
aws --profile d2d-drt-prod s3 cp graph-builder/data/driving_graph.tgz s3://d2d-directions-driving-production/v5.21.0/graph_$(date +"%Y_%m_%d").tgz
aws --profile d2d-drt-prod s3 cp graph-builder/data/walking_graph.tgz s3://d2d-directions-walking-production/v5.21.0/graph_$(date +"%Y_%m_%d").tgz
Phew, done. :)
Once all *.osm.pbf and *.poly files are downloaded/created, we will merge all osm files into one, clip the areas based on the poly files and then alter some nodes/ways/relations by applying
a .osc-file to the whole dataset.
This is achieved by a bash-script inside of the container.
As the last step, we generate a routable graph with OSRM and the clipped file for each profile.
This is achieved by a bash-script inside of the container.
Note: This process will generate a graph based on Contraction Hierachies (CH) which best fits use-cases where query performance is key, especially for large distance matrices.
The other option is Multi-Level Dijkstra (MLD) which best fits use-cases where query performance still needs to be very good and live-updates to the data need to be made e.g. for regular Traffic updates.
As we don't use regular data updates yet, we'll stick with CH for now.
You can have a look at the offical Wiki
You can use these graphs in osrm-routing-core locally. Both profiles (walking and driving) will be deployed after changing the dataset and their graphs are stored in S3.
If you uploaded a new dataset, please ensure that the version number and timestamp is configured in osrm-routing-core/.ebextensions
Content type
Image
Digest
Size
91.8 MB
Last updated
about 5 years ago
docker pull tor2tor/d2d-directions