#!/usr/bin/env bash # The join step of offroad-osm/build-launch (docs/offroad/PLAN.md R4.1b), in the geotools image (no database): the # regions' offroad-osm archives → one /data/tiles/offroad-osm.pmtiles with tile-join, every layer and zoom kept (-pk: # no tile size limit), stamped with the ODbL notice, the 4.6 offer and the oldest extract date. Only offroad-osm # archives go in: the result stays one ODbL tileset (RJ-14). # # tools/geodata/run offroad-osm/join /data/build/offroad-osm-launch/michigan.pmtiles /data/build/offroad-osm-launch/utah.pmtiles set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" log() { printf '\033[1;32m==>\033[0m %s\n' "$*"; } die() { printf '\033[1;31merror:\033[0m %s\n' "$*" >&2; exit 1; } [[ $# -ge 1 ]] || die "usage: offroad-osm/join …" oldest="" for f in "$@"; do [[ -f "$f" ]] || die "no archive at $f" meta="$(python3 -I "$HERE/../lib/pmtiles_meta.py" show "$f")" python3 -I -c 'import json, sys; m = json.load(sys.stdin) sys.exit(0 if m.get("dataset") == "offroad-osm" else "%s is not an offroad-osm archive" % sys.argv[1])' "$f" <<<"$meta" v="$(python3 -I -c 'import json, sys; print(json.load(sys.stdin).get("source_version", ""))' <<<"$meta")" [[ -z "$oldest" || "$v" < "$oldest" ]] && oldest="$v" done BUILD_DIR="${HG_BUILD_DIR:-/tmp/hg-build}/offroad-osm-join" rm -rf "$BUILD_DIR" && mkdir -p "$BUILD_DIR" tile-join -o "$BUILD_DIR/offroad-osm.pmtiles" -f -q -pk -n "HuntGrid Offroad OSM" \ -A '© OpenStreetMap contributors' "$@" python3 "$HERE/../lib/pmtiles_meta.py" odbl "$BUILD_DIR/offroad-osm.pmtiles" offroad-osm "$oldest" mkdir -p /data/tiles cp "$BUILD_DIR/offroad-osm.pmtiles" /data/tiles/.offroad-osm.pmtiles.part mv -f /data/tiles/.offroad-osm.pmtiles.part /data/tiles/offroad-osm.pmtiles rm -rf "$BUILD_DIR" log "Joined $# regions into /data/tiles/offroad-osm.pmtiles ($oldest)"