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).
64 lines
2.1 KiB
Bash
Executable File
64 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Pre-cache OSM tiles for the trip's map extent through the local proxy
|
|
# (which stores them in mock/.tilecache). Usage:
|
|
# pre-cache-tiles.sh # all trips
|
|
# pre-cache-tiles.sh colombia z16 # one trip, one zoom
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
BASE="${BASE:-http://localhost:8077}"
|
|
TRIPS=("$@")
|
|
[ ${#TRIPS[@]} -eq 0 ] && TRIPS=(colombia boston florence)
|
|
|
|
# tile range for a lon/lat box
|
|
range() { # z minlon minlat maxlon maxlat -> "x0 x1 y0 y1"
|
|
python3 -c "
|
|
import math
|
|
z, minlo, minla, maxlo, maxla = float('$1'), float('$2'), float('$3'), float('$4'), float('$5')
|
|
def tx(lon): return int((lon + 180) / 360 * 2**z)
|
|
def ty(lat):
|
|
r = math.radians(lat)
|
|
return int((1 - math.log(math.tan(r) + 1 / math.cos(r)) / math.pi) / 2 * 2**z)
|
|
print(tx(minlo), tx(maxlo), ty(maxla), ty(minla))"
|
|
}
|
|
|
|
fetch() { # trip z
|
|
local trip="$1" z="$2"
|
|
case "$trip" in
|
|
colombia)
|
|
# Cartagena + Santa Marta boxes
|
|
for box in "-75.62 10.36 -75.42 10.48" "-74.27 11.08 -74.13 11.28"; do
|
|
set -- $box
|
|
read -r x0 x1 y0 y1 <<< "$(range "$z" "$1" "$2" "$3" "$4")"
|
|
echo " $trip z$z box($1,$2,$3,$4): x $x0-$x1 y $y0-$y1" >&2
|
|
for ((x=x0; x<=x1; x++)); do for ((y=y0; y<=y1; y++)); do
|
|
echo "$BASE/tiles/$z/$x/$y.png"
|
|
done; done
|
|
done
|
|
;;
|
|
boston)
|
|
set -- -71.16 42.29 -71.00 42.41
|
|
read -r x0 x1 y0 y1 <<< "$(range "$z" "$1" "$2" "$3" "$4")"
|
|
for ((x=x0; x<=x1; x++)); do for ((y=y0; y<=y1; y++)); do
|
|
echo "$BASE/tiles/$z/$x/$y.png"
|
|
done; done
|
|
;;
|
|
florence)
|
|
set -- 11.19 43.72 11.32 43.80
|
|
read -r x0 x1 y0 y1 <<< "$(range "$z" "$1" "$2" "$3" "$4")"
|
|
for ((x=x0; x<=x1; x++)); do for ((y=y0; y<=y1; y++)); do
|
|
echo "$BASE/tiles/$z/$x/$y.png"
|
|
done; done
|
|
;;
|
|
esac
|
|
}
|
|
|
|
for trip in "${TRIPS[@]}"; do
|
|
for z in 14 15 16; do
|
|
echo "== $trip z$z"
|
|
# one URL per curl: -o applies to the first URL only, otherwise the rest
|
|
# print to stdout
|
|
fetch "$trip" "$z" | xargs -P 8 -n 1 curl -s -o /dev/null -m 20 --retry 2 > /dev/null
|
|
done
|
|
done
|
|
echo "done. cache size: $(du -sh .tilecache | cut -f1)"
|