A FastAPI app to dynamically deliver ZIPped Valhalla graphs from a variety of data sources.
The default road dataset is the OSM planet PBF. If available, it also supports road datasets of commercial vendors, such as TomTom and HERE, assuming they are provided in the OSM PBF format.
POST
and DELETE
endpointsARQ
workerThe following will download
First you need to clone the project:
git clone https://github.com/gis-ops/routing-graph-packager.git
Since the graph generation takes place in docker containers, you'll also need to pull the relevant image: docker pull ghcr.io/gis-ops/docker-valhalla/valhalla:latest
.
The easiest way to quickly start the project is to use docker-compose
:
docker-compose up -d
With the project defaults, you can now make a POST
request which will generate a graph package in DATA_DIR
(default ./data
) from Andorra:
curl --location -XPOST 'http://localhost:5000/api/v1/jobs' \
--header 'Authorization: Basic YWRtaW5AZXhhbXBsZS5vcmc6YWRtaW4=' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "test", # name needs to be unique for a specific router & provider
"description": "test descr",
"bbox": "1.531906,42.559908,1.6325,42.577608", # the bbox as minx,miny,maxx,maxy
"provider": "osm", # the dataset provider, needs to be registered in ENABLED_PROVIDERS
"update": "true" # whether this package should be updated on every planet build
}'
After a minute you should have the graph package available in ./data/output/osm_test/
. If not, check the logs of the worker process or the Flask app.
The routing-packager-app
container running the HTTP API has a supervisor
process running in a loop, which:
By default, also a fake SMTP server is started, and you can see incoming messages on http://localhost:1080
.
Under the hood we're running a supervisor
instance to control the graph builds.
Two instances of the Valhalla docker image take turns building a new graph from an updated OSM file. Those two graphs are physically separated from each other in subdirectories $TMP_DATA_DIR/osm/8002
& $TMP_DATA_DIR/osm/8003
.
After each graph build finished, the OSM file is updated for the next graph build.
This service tries to be flexible in terms of data sources and routing engines. Consequently, we support proprietary dataset such as from TomTom or HERE.
However, all data sources must be in the OSM PBF format and follow the OSM tagging model. There is commercial support in case of interest.
POST
new jobThe app is listening on /api/v1/jobs
for new POST
requests to generate some graph according to the passed arguments. The lifecycle is as follows:
ARQ
in a Redis database to dispatch to a worker.status
database field along the processing to indicate the current stage$DATA_DIR/output/<JOB_NAME>
, along with a metadata JSON