#!/usr/bin/env bash # Outdoor features (tracks with grade, paths, gates, hunting stands, springs, shelters, parking) from OSM → # data/tiles/outdoor.pmtiles + the "outdoor-osm" overlay (docs/07 §12, roadmap 3.3). Runs Planetiler (Apache-2.0) # in its own container, then registers the layer through the geotools image. # # tools/geodata/outdoor/build # Alabama (dev default, ~1 min) # HG_OSM_EXTRACT=europe/slovenia tools/geodata/outdoor/build # any Geofabrik extract # HG_OSM_EXTRACT=planet tools/geodata/outdoor/build # production: a big machine (Planetiler docs) # # Extracts are shared with public-land/osm in data/downloads/osm (reused for a day). Runs on Linux, macOS and Git Bash # on Windows. Needs: bash, curl, docker. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" EXTRACT="${HG_OSM_EXTRACT:-north-america/us/alabama}" PLANETILER_IMAGE="${HG_PLANETILER_IMAGE:-ghcr.io/onthegomap/planetiler:0.9.2}" JAVA_MEMORY="${HG_PLANETILER_MEMORY:-3g}" log() { printf '\033[1;32m==>\033[0m %s\n' "$*"; } [[ "$EXTRACT" =~ ^[a-z0-9/-]+$ ]] || { echo "bad extract: $EXTRACT" >&2; exit 1; } host_path() { if command -v cygpath >/dev/null 2>&1; then cygpath -w "$1"; else printf '%s' "$1"; fi; } mkdir -p "$ROOT/data/build" "$ROOT/data/tiles" "$ROOT/data/downloads/osm" if [[ "$EXTRACT" == planet ]]; then source_args=(--osm_url=aws:latest --download --download_dir=/data/downloads/osm) else pbf="${EXTRACT//\//-}-latest.osm.pbf" if [[ -z "$(find "$ROOT/data/downloads/osm/$pbf" -mtime -1 2>/dev/null)" ]]; then log "Downloading https://download.geofabrik.de/$EXTRACT-latest.osm.pbf" curl -fsSL --retry 3 -A "HuntGrid geodata pipeline" -o "$ROOT/data/downloads/osm/$pbf.part" \ "https://download.geofabrik.de/$EXTRACT-latest.osm.pbf" mv -f "$ROOT/data/downloads/osm/$pbf.part" "$ROOT/data/downloads/osm/$pbf" fi source_args=(--osm_path="/data/downloads/osm/$pbf") fi log "Planetiler: outdoor features for $EXTRACT" # MSYS_NO_PATHCONV: Git Bash must pass the container paths through unchanged. MSYS_NO_PATHCONV=1 docker run --rm -e JAVA_TOOL_OPTIONS="-Xmx$JAVA_MEMORY" \ -v "$(host_path "$ROOT/data"):/data" -v "$(host_path "$ROOT/tools/geodata/outdoor"):/schema:ro" \ "$PLANETILER_IMAGE" generate-custom --schema=/schema/outdoor.yml "${source_args[@]}" \ --tmpdir=/data/build/planetiler-tmp --output=/data/build/outdoor.pmtiles --force mv -f "$ROOT/data/build/outdoor.pmtiles" "$ROOT/data/tiles/outdoor.pmtiles" rm -rf "$ROOT/data/build/planetiler-tmp" HG_OSM_EXTRACT="$EXTRACT" "$ROOT/tools/geodata/run" outdoor/register log "Done: data/tiles/outdoor.pmtiles ($(du -h "$ROOT/data/tiles/outdoor.pmtiles" | cut -f1)); restart Martin to serve a new file"