- DESIGN.md: full design incl. driving-trip requirements (R1-R4), stays model, focus mode, mobile, provenance rules - SURVEY.md: open-source landscape - mock/: interaction mock (Florence itinerary, focus mode, stays, region stops, mobile layout) - router/: Go module (stdlib-only) with Router interface (Valhalla + OSRM backends), stop_cost, optimize_stops, corridor, routectl CLI, bench (5 real NE-corridor tasks, 26 checks passing), integration tests, and setup-osrm.sh for the self-hosted router - osm/: NH+MA+CT+NY PBFs (gitignored) + setup artifacts
69 lines
2.7 KiB
Bash
69 lines
2.7 KiB
Bash
#!/usr/bin/env bash
|
|
# Self-host the OSRM router over the NH+MA+CT+NY extract.
|
|
# Prereqs: cmake, g++, make, >=12GB RAM for extract, >=10GB disk.
|
|
#
|
|
# The PBFs are pre-downloaded in ../osm/ (us-new-hampshire, us-connecticut,
|
|
# us-massachusetts, us-new-york .osm.pbf, from the geofabrik mirror on
|
|
# HuggingFace: NoeFlandre/osm-geofabrik-raw-pbf-extracts).
|
|
#
|
|
# Artifacts go to ../osm/build/. Router ends up on http://localhost:5000.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
OSM_DIR="$(pwd)/osm"
|
|
BUILD_DIR="$OSM_DIR/build"
|
|
DATA_DIR="$BUILD_DIR/data"
|
|
OSRM_BIN="$BUILD_DIR/osrm-backend-26.4.1/build"
|
|
mkdir -p "$DATA_DIR"
|
|
|
|
step() { echo; echo "=== $1"; }
|
|
|
|
step "1/5 OSRM binaries"
|
|
if [ ! -x "$OSRM_BIN/osrm-extract" ]; then
|
|
if [ ! -d "$BUILD_DIR/osrm-backend-26.4.1" ]; then
|
|
curl -sL -o "$BUILD_DIR/osrm.tar.gz" https://github.com/Project-OSRM/osrm-backend/archive/refs/tags/v26.4.1.tar.gz
|
|
tar -C "$BUILD_DIR" -xzf "$BUILD_DIR/osrm.tar.gz"
|
|
fi
|
|
# Boost is header-usage only for OSRM; point BOOST_ROOT at a source tree.
|
|
if [ ! -d "$BUILD_DIR/boost_1_84_0" ]; then
|
|
curl -sL -o "$BUILD_DIR/boost.tgz" https://archives.boost.io/release/1.84.0/source/boost_1_84_0.tar.gz
|
|
tar -C "$BUILD_DIR" -xzf "$BUILD_DIR/boost.tgz"
|
|
fi
|
|
cmake -S "$BUILD_DIR/osrm-backend-26.4.1" -B "$OSRM_BIN" \
|
|
-DCMAKE_BUILD_TYPE=Release -DWITH_TESTS=OFF -DWITH_EXAMPLES=OFF \
|
|
-DBOOST_ROOT="$BUILD_DIR/boost_1_84_0"
|
|
cmake --build "$OSRM_BIN" -j"$(nproc)"
|
|
fi
|
|
ls -la "$OSRM_BIN"/osrm-extract "$OSRM_BIN"/osrm-routed
|
|
|
|
step "2/5 OSM PBFs"
|
|
for f in us-new-hampshire us-connecticut us-massachusetts us-new-york; do
|
|
if [ ! -s "$OSM_DIR/$f.osm.pbf" ]; then
|
|
curl -sL -o "$OSM_DIR/$f.osm.pbf" \
|
|
"https://huggingface.co/datasets/NoeFlandre/osm-geofabrik-raw-pbf-extracts/resolve/main/$f-latest.osm.pbf"
|
|
fi
|
|
done
|
|
ls -la "$OSM_DIR"/us-*.osm.pbf
|
|
|
|
step "3/5 extract (needs ~12GB RAM; this is the slow part)"
|
|
touch "$DATA_DIR/timestamp"
|
|
if [ ! -s "$DATA_DIR/northeast.osrm" ] || [ ! -s "$DATA_DIR/northeast.osrm.tile" ]; then
|
|
"$OSRM_BIN/osrm-extract" \
|
|
"$OSM_DIR/us-new-hampshire.osm.pbf" \
|
|
"$OSM_DIR/us-connecticut.osm.pbf" \
|
|
"$OSM_DIR/us-massachusetts.osm.pbf" \
|
|
"$OSM_DIR/us-new-york.osm.pbf" \
|
|
--profile-file "$OSRM_BIN/../profiles/driving.lua" \
|
|
--timestamp-file "$DATA_DIR/timestamp" \
|
|
--output-location "$DATA_DIR/northeast" \
|
|
--ignore-waterway --ignore-tunnels 2>&1 | tail -5
|
|
fi
|
|
|
|
step "4/5 partition + customize"
|
|
"$OSRM_BIN/osrm-partition" --input-location "$DATA_DIR/northeast"
|
|
"$OSRM_BIN/osrm-customize" --input-location "$DATA_DIR/northeast" --profile-file "$OSRM_BIN/../profiles/driving.lua"
|
|
|
|
step "5/5 serve"
|
|
echo "Starting osrm-routed on :5000 (Ctrl-C to stop)"
|
|
exec "$OSRM_BIN/osrm-routed" --algorithm mld --port 5000 "$DATA_DIR/northeast.osrm"
|