run osrm import on the host

This commit is contained in:
Shautvast 2026-03-30 12:57:06 +02:00
parent 2deb8731a4
commit e99114b7b7
3 changed files with 57 additions and 8 deletions

View file

@ -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):

View file

@ -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."

View file

@ -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