56 lines
1.6 KiB
Bash
Executable file
56 lines
1.6 KiB
Bash
Executable file
#!/bin/bash
|
|
# scripts/05_import_routing_host.sh
|
|
# Run this directly on the Pi host (not inside the importer container).
|
|
# Builds a local ARM64 OSRM image if it doesn't exist, then preprocesses
|
|
# routing graphs for car, foot, and bicycle profiles.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
BACKEND_DIR="$(dirname "$SCRIPT_DIR")"
|
|
DATA_DIR="${1:-$HOME/dev/maps/data}"
|
|
OSRM_DIR="${DATA_DIR}/osrm"
|
|
PBF_FILE="${DATA_DIR}/osm/region.osm.pbf"
|
|
OSRM_IMAGE="maps-osrm-arm64:latest"
|
|
|
|
if [ ! -f "$PBF_FILE" ]; then
|
|
echo "ERROR: PBF file not found at $PBF_FILE"
|
|
echo "Run 01_download.sh first."
|
|
exit 1
|
|
fi
|
|
|
|
# Build the ARM64 OSRM image if not already present
|
|
if ! podman image exists "$OSRM_IMAGE"; then
|
|
echo "=== Building ARM64 OSRM image (one-time, ~30-60 min on Pi) ==="
|
|
podman build \
|
|
-f "${BACKEND_DIR}/osrm-arm64.Dockerfile" \
|
|
-t "$OSRM_IMAGE" \
|
|
"$BACKEND_DIR"
|
|
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" \
|
|
"$OSRM_IMAGE" \
|
|
osrm-extract -p "/opt/${PROFILE}.lua" /data/region.osm.pbf
|
|
|
|
podman run --rm \
|
|
-v "${PROFILE_DIR}:/data" \
|
|
"$OSRM_IMAGE" \
|
|
osrm-partition /data/region.osrm
|
|
|
|
podman run --rm \
|
|
-v "${PROFILE_DIR}:/data" \
|
|
"$OSRM_IMAGE" \
|
|
osrm-customize /data/region.osrm
|
|
|
|
echo "OSRM $PROFILE profile ready."
|
|
done
|
|
|
|
echo "All OSRM profiles processed."
|