#!/usr/bin/env bash # HuntGrid Offroad's OpenStreetMap tileset for the launch regions (docs/offroad/PLAN.md R4.1b): offroad-osm/build for # each Geofabrik extract below, then one file joined with tile-join → data/tiles/offroad-osm.pmtiles, re-stamped with # the ODbL notice and the oldest extract date, and data/build/offroad-osm-launch/sizes.json (bytes per region and the # total) for Appendix H.2. PC only (owner step; hours, several GB of downloads): the VM never builds tiles. # # tools/geodata/offroad-osm/build-launch # every launch region # HG_OFFROAD_REGIONS="north-america/us/michigan north-america/us/utah" tools/geodata/offroad-osm/build-launch # # Neighbouring extracts overlap a little at their borders, so a way crossing one can be in two inputs; tile-join keeps # both copies (drawn on top of each other: harmless for a display tileset). No data limit (RJ-15): nothing is dropped # to save space; check the VM's free disk before shipping and add disk if it won't fit. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" US=north-america/us CA=north-america/canada DEFAULT_REGIONS="$US/washington $US/oregon $US/california $US/idaho $US/nevada $US/utah $US/arizona $US/montana $US/wyoming $US/colorado $US/new-mexico $US/michigan $US/minnesota $US/wisconsin $CA/quebec $CA/ontario $CA/nova-scotia $CA/new-brunswick $CA/newfoundland-and-labrador $CA/prince-edward-island" REGIONS="${HG_OFFROAD_REGIONS:-$DEFAULT_REGIONS}" OUT="$ROOT/data/build/offroad-osm-launch" log() { printf '\033[1;32m==>\033[0m %s\n' "$*"; } mkdir -p "$OUT" sizes="{" for extract in $REGIONS; do name="${extract##*/}" if [[ -f "$OUT/$name.pmtiles" && -z "${HG_REBUILD:-}" ]]; then log "$name: reusing $OUT/$name.pmtiles (HG_REBUILD=1 to rebuild)" else HG_OSM_EXTRACT="$extract" "$ROOT/tools/geodata/offroad-osm/build" mv -f "$ROOT/data/tiles/offroad-osm.pmtiles" "$OUT/$name.pmtiles" fi sizes+="\"$name\": $(wc -c <"$OUT/$name.pmtiles")," done log "Joining $(wc -w <<<"$REGIONS") regions" inputs=() for extract in $REGIONS; do inputs+=("/data/build/offroad-osm-launch/${extract##*/}.pmtiles"); done HG_DB_URL="${HG_DB_URL:-unused}" "$ROOT/tools/geodata/run" offroad-osm/join "${inputs[@]}" total="$(wc -c <"$ROOT/data/tiles/offroad-osm.pmtiles")" printf '%s "total": %s}\n' "$sizes" "$total" >"$OUT/sizes.json" log "Done: data/tiles/offroad-osm.pmtiles ($(du -h "$ROOT/data/tiles/offroad-osm.pmtiles" | cut -f1)); sizes in $OUT/sizes.json"