From e99114b7b784391bb676af319c874c345f2a8ba0 Mon Sep 17 00:00:00 2001 From: Shautvast Date: Mon, 30 Mar 2026 12:57:06 +0200 Subject: [PATCH] run osrm import on the host --- README.md | 17 +++++---- backend/scripts/05_import_routing_host.sh | 43 +++++++++++++++++++++++ backend/scripts/update_all.sh | 5 +-- 3 files changed, 57 insertions(+), 8 deletions(-) create mode 100755 backend/scripts/05_import_routing_host.sh diff --git a/README.md b/README.md index d108805..065aae4 100644 --- a/README.md +++ b/README.md @@ -56,19 +56,20 @@ podman compose run --rm importer /app/scripts/02_import_tiles.sh # Step 3: Import POI data into PostGIS podman compose run --rm importer /app/scripts/03_import_pois.sh -# Step 4: Download Photon geocoding index (~500 MB for Netherlands) +# Step 4: Download Photon geocoding index (~2.3 GB for Netherlands) podman compose run --rm importer /app/scripts/04_import_geocoding.sh -# Step 5: Preprocess OSRM routing graphs (runs osrm containers internally) -podman compose run --rm importer /app/scripts/05_import_routing.sh +# Step 5: Preprocess OSRM routing graphs — run on the HOST, not in the container +# (OSRM tools only exist inside the osrm/osrm-backend image) +bash backend/scripts/05_import_routing_host.sh ~/dev/maps/data # Step 6: Register offline regions in the database podman compose run --rm importer /app/scripts/06_build_offline_packages.sh ``` -To change the country, set `PHOTON_COUNTRY_CODE` before step 4: +To change the country for step 4, use the full country name: ```bash -PHOTON_COUNTRY_CODE=de podman compose run --rm importer /app/scripts/04_import_geocoding.sh +PHOTON_COUNTRY=germany podman compose run --rm importer /app/scripts/04_import_geocoding.sh ``` ### 3. Start all services @@ -86,10 +87,14 @@ podman compose restart osrm-driving osrm-walking osrm-cycling ### 4. Weekly data refresh -Use `update_all.sh` for scheduled updates. It re-downloads the PBF only if the file has changed on the server (`wget -N`), then reimports everything. +Use `update_all.sh` for scheduled updates. It re-downloads the PBF only if the file has changed on the server (`wget -N`), then reimports everything. Note: OSRM preprocessing is not included — run it separately on the host if routing data has changed. ```bash podman compose run --rm importer /app/scripts/update_all.sh + +# If routing data changed, also run on the host: +bash backend/scripts/05_import_routing_host.sh ~/dev/maps/data +podman compose restart osrm-driving osrm-walking osrm-cycling ``` To refresh only specific data (e.g. tiles changed but routing didn't): diff --git a/backend/scripts/05_import_routing_host.sh b/backend/scripts/05_import_routing_host.sh new file mode 100755 index 0000000..a1e0dcb --- /dev/null +++ b/backend/scripts/05_import_routing_host.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# scripts/05_import_routing_host.sh +# Run this directly on the Pi host (not inside the importer container). +# OSRM tools only exist inside the osrm/osrm-backend image. + +set -euo pipefail + +DATA_DIR="${1:-$HOME/dev/maps/data}" +OSRM_DIR="${DATA_DIR}/osrm" +PBF_FILE="${DATA_DIR}/osm/region.osm.pbf" + +if [ ! -f "$PBF_FILE" ]; then + echo "ERROR: PBF file not found at $PBF_FILE" + echo "Run 01_download.sh first." + exit 1 +fi + +for PROFILE in car foot bicycle; do + PROFILE_DIR="${OSRM_DIR}/${PROFILE}" + mkdir -p "$PROFILE_DIR" + cp "$PBF_FILE" "${PROFILE_DIR}/region.osm.pbf" + + echo "=== Processing OSRM profile: $PROFILE ===" + + podman run --rm \ + -v "${PROFILE_DIR}:/data" \ + docker.io/osrm/osrm-backend:latest \ + osrm-extract -p "/opt/${PROFILE}.lua" /data/region.osm.pbf + + podman run --rm \ + -v "${PROFILE_DIR}:/data" \ + docker.io/osrm/osrm-backend:latest \ + osrm-partition /data/region.osrm + + podman run --rm \ + -v "${PROFILE_DIR}:/data" \ + docker.io/osrm/osrm-backend:latest \ + osrm-customize /data/region.osrm + + echo "OSRM $PROFILE profile ready." +done + +echo "All OSRM profiles processed." diff --git a/backend/scripts/update_all.sh b/backend/scripts/update_all.sh index 023b059..0cc6d18 100755 --- a/backend/scripts/update_all.sh +++ b/backend/scripts/update_all.sh @@ -18,8 +18,9 @@ echo "=== Maps data import started at $(date -u) ===" # Step 4: Download Photon geocoding index /app/scripts/04_import_geocoding.sh -# Step 5: Preprocess OSRM routing graphs (runs osrm containers internally) -/app/scripts/05_import_routing.sh +# Step 5: OSRM routing graphs — must be run on the HOST, not in this container +echo "NOTE: Run OSRM preprocessing on the Pi host:" +echo " bash backend/scripts/05_import_routing_host.sh ~/dev/maps/data" # Step 6: Register offline regions in the database /app/scripts/06_build_offline_packages.sh