#!/usr/bin/env bash # The backcountry-osm catalog row and its geo.dataset_imports record (docs/backcountry/PLAN.md B2.2a), in the geotools # image: tools/geodata/run backcountry-osm/register. On the PC after backcountry-osm/build or build-all. Writes # data/export/backcountry-osm-apply.sql (the same SQL) for the targeted ship: the VM's Postgres container runs that file # with psql (docs/10 ยง4c); never run this script on the VM. HG_SQL_ONLY=1 writes the file without touching a database. set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=../lib/common.sh source "$HERE/../lib/common.sh" TILES=/data/tiles/backcountry-osm.pmtiles [[ -f "$TILES" ]] || die "no $TILES; run tools/geodata/backcountry-osm/build" VERSION="$(python3 -I -c 'import sys; sys.path.insert(0, sys.argv[2]); import pmtiles_meta m = pmtiles_meta.read_metadata(sys.argv[1]) if m.get("dataset") != "backcountry-osm" or not m.get("source_version"): sys.exit("not a stamped backcountry-osm archive") print(m["source_version"])' "$TILES" "$HERE/../lib")" # Backcountry's register (B0.2): refuses a blocked or unregistered source, and gives the tier written with the import. python3 -I "$HERE/../republishing/republishing.py" backcountry-require dataset:backcountry-osm TIER="$(python3 -I "$HERE/../republishing/republishing.py" backcountry-tier dataset:backcountry-osm)" SCOPE="${HG_BACKCOUNTRY_SCOPE:-US+CA}" mkdir -p /data/export python3 -I "$HERE/apply_sql.py" "$HERE/backcountry-osm.layer.json" "$VERSION" "$TIER" \ "$(sha256sum "$TILES" | cut -d' ' -f1)" "$SCOPE" >/data/export/backcountry-osm-apply.sql if [[ -z "${HG_SQL_ONLY:-}" ]]; then psql_run -f /data/export/backcountry-osm-apply.sql log "backcountry-osm catalog row and import record loaded ($VERSION, tier $TIER)" fi log "Ship file: data/export/backcountry-osm-apply.sql (with data/tiles/backcountry-osm.pmtiles)"