trips/router/scripts/setup-osrm-colombia.sh
Greg Pomerantz 33ed5d9fe6 multi-trip mock + Colombia trip with a real walking router
The mock can now work several trips at once: a trip picker in the
topbar, per-trip state in localStorage (edits + version history survive
switching), and a per-trip router key so each trip routes on its own
OSRM extract.

Colombia (Cartagena -> Santa Marta, 8 days) becomes the default working
trip, inside a new walking-profile OSRM instance:
- scripts/crop_pbf.py: streaming 3-pass PBF cropper (no PBF library;
  the country file is too big for osmium extract -s complete_ways on
  this box). Framing validated against osmium test fixtures and
  osrm-extract. Drops relations (foot profile ignores restrictions).
- scripts/setup-osrm-colombia.sh: download -> crop (~4.6 MB) ->
  extract/partition/customize with the official foot.lua -> serve
  :5003. Verified: Getsemaní -> Castillo San Felipe 7.98 km / 96 min.
- server.js: ROUTERS map, ?router=colombia|northeast on /route,
  /table, /router-status (per-router probe points).
- app.js: legs touching a transit stop are fixed (flight/taxi/bus via
  M.multimodal), never re-routed; distance-0 router answers (both
  points on one node) read as adjacent stops, not out-of-coverage.
- multi-hotel fix: day-scope map fit uses the stays covering THAT day,
  so a two-city trip no longer fits the whole country per day.

Also: pre-cache-tiles.sh (Cartagena+Santa Marta z14-16, 2560 tiles),
tile cache write fix (Node rejects flags:'x'; buffer-then-write),
favicon, renderHotelMks load-order guard, tests updated for the new
default trip (all four puppeteer suites green, zero console errors).
2026-09-09 09:44:29 -04:00

56 lines
2.1 KiB
Bash

#!/usr/bin/env bash
# Build + serve the COLOMBIA walking router (Cartagena + Santa Marta boxes) on :5003.
#
# The full-country PBF (329 MB) is too big for `osmium extract -s complete_ways`
# on this box (~2 GB free RAM), so crop_pbf.py streams it in 3 passes and keeps
# only the two city boxes (~4.6 MB). The dataset is built with the official
# foot.lua profile (real walking speeds, ~5 km/h).
#
# Prereq: scripts/setup-osrm.sh has run once (OSRM binaries + osmium exist in
# $HOME/osm-build). The Colombia PBF is downloaded from geofabrik if missing.
#
# Usage: scripts/setup-osrm-colombia.sh # build + serve :5003
# scripts/setup-osrm-colombia.sh --no-serve # build only
set -euo pipefail
cd "$(dirname "$0")"
W="${W:-$HOME/osm-build}"
OSM_DIR="$(cd ../.. && pwd)/osm"
DATA_DIR="$W/data/colombia"
OSRM_BIN="$W/build"
OSRM_SRC="$W/osrm-backend-26.4.1"
SERVE=1
[ "${1:-}" = "--no-serve" ] && SERVE=0
export LD_LIBRARY_PATH="$W/prefix/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
mkdir -p "$DATA_DIR"
PBF="$OSM_DIR/colombia.osm.pbf"
echo "=== PBF"
if [ ! -s "$PBF" ]; then
echo "downloading colombia-latest.osm.pbf from geofabrik (~330 MB)..."
curl -sL -o "$PBF" https://download.geofabrik.de/south-america/colombia-latest.osm.pbf
fi
ls -la "$PBF"
echo "=== crop to Cartagena + Santa Marta boxes (3 streaming passes, ~3 min)"
# boxes: MINLON MINLAT MAXLON MAXLAT (Cartagena city+beaches, Santa Marta+Tayrona)
CARTAGENA="-75.66,10.26,-75.36,10.56"
SAMARTA="-74.36,10.84,-74.02,11.22"
python3 crop_pbf.py "$PBF" /tmp/colombia-trip.pbf "$CARTAGENA" "$SAMARTA"
echo "=== extract (foot.lua) + partition + customize"
rm -f "$DATA_DIR"/colombia-trip.osrm.*
"$OSRM_BIN/osrm-extract" /tmp/colombia-trip.pbf \
-p "$OSRM_SRC/profiles/foot.lua" -o "$DATA_DIR/colombia-trip"
"$OSRM_BIN/osrm-partition" "$DATA_DIR/colombia-trip"
"$OSRM_BIN/osrm-customize" "$DATA_DIR/colombia-trip"
if [ "$SERVE" = 0 ]; then
echo "done (not serving; start with: $OSRM_BIN/osrm-routed --algorithm mld --port 5003 $DATA_DIR/colombia-trip.osrm)"
exit 0
fi
echo "=== serve on :5003 (Ctrl-C to stop)"
exec "$OSRM_BIN/osrm-routed" --algorithm mld --port 5003 "$DATA_DIR/colombia-trip.osrm"