feat: add prepare-pbf.sh to stage OSM extract
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
# Prepare a local .osm.pbf for Nominatim import (compose first boot).
|
||||
#
|
||||
# Usage:
|
||||
# ./scripts/prepare-pbf.sh /path/to/region.osm.pbf
|
||||
# ./scripts/prepare-pbf.sh /path/to/OSRM/data/us-latest.osm.pbf --symlink
|
||||
#
|
||||
# After this, set NOMINATIM_PBF_FILE in .env (default region.osm.pbf) and:
|
||||
# docker compose up -d
|
||||
#
|
||||
# Shares the PBF with OSRM only — never copy/use .osrm* graph files here.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SYMLINK=0
|
||||
ARGS=()
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--symlink|-s) SYMLINK=1 ;;
|
||||
-h|--help)
|
||||
echo "usage: $0 [--symlink] <path-to-osm.pbf>" >&2
|
||||
exit 0
|
||||
;;
|
||||
*) ARGS+=("$arg") ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ${#ARGS[@]} -lt 1 ]]; then
|
||||
echo "usage: $0 [--symlink] <path-to-osm.pbf>" >&2
|
||||
exit 64
|
||||
fi
|
||||
|
||||
SRC="${ARGS[0]}"
|
||||
if [[ ! -f "$SRC" ]]; then
|
||||
echo "pbf file not found: $SRC" >&2
|
||||
exit 66
|
||||
fi
|
||||
|
||||
# Resolve absolute path.
|
||||
SRC="$(cd "$(dirname "$SRC")" && pwd)/$(basename "$SRC")"
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
DATASET="${NOMINATIM_PBF_FILE:-region.osm.pbf}"
|
||||
DEST="${ROOT}/data/${DATASET}"
|
||||
|
||||
mkdir -p "${ROOT}/data"
|
||||
|
||||
if [[ "$SYMLINK" -eq 1 ]]; then
|
||||
ln -sfn "$SRC" "$DEST"
|
||||
echo "symlinked $DEST -> $SRC"
|
||||
else
|
||||
cp -f "$SRC" "$DEST"
|
||||
echo "copied $SRC -> $DEST"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "next: cp .env.example .env # set NOMINATIM_PASSWORD"
|
||||
echo " docker compose up -d # first boot imports (slow)"
|
||||
echo "smoke: curl -sG 'http://localhost:8089/search' --data-urlencode 'q=Akron, OH' -d 'format=json' -d 'limit=1'"
|
||||
Reference in New Issue
Block a user