#!/usr/bin/env bash # Second half of tools/geodata/outdoor/build (runs in the geotools image): the "outdoor-osm" catalog row and a # geo.dataset_imports record for data/tiles/outdoor.pmtiles. set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$HERE/../lib/common.sh" EXTRACT="${HG_OSM_EXTRACT:-north-america/us/alabama}" TILES=/data/tiles/outdoor.pmtiles [[ -f "$TILES" ]] || die "no $TILES; run tools/geodata/outdoor/build" VERSION="OpenStreetMap $(date -u -r "$TILES" +%Y-%m-%d)" SOURCE_URL="$([[ "$EXTRACT" == planet ]] && echo "https://planet.openstreetmap.org" || echo "https://download.geofabrik.de/$EXTRACT-latest.osm.pbf")" # Offroad's republishing register (docs/offroad/PLAN.md R0.2a-b): refuses a blocked or taken-down source, and gives the # tier written to geo.dataset_imports.tier. python3 -I "$HERE/../republishing/republishing.py" require dataset:osm-outdoor TIER="$(python3 -I "$HERE/../republishing/republishing.py" tier dataset:osm-outdoor)" log "Catalog layer outdoor-osm" upsert_layer "$HERE/outdoor.layer.json" psql_run -v version="$VERSION" -v tier="$TIER" -v source_url="$SOURCE_URL" -v scope="$EXTRACT" -v checksum="$(md5sum "$TILES" | cut -d' ' -f1)" <<'SQL' insert into geo.dataset_imports (id, dataset_key, version, source_url, license, attribution, feature_count, checksum, scope, tier, imported_at) values ( encode(set_bit(set_bit(overlay(uuid_send(gen_random_uuid()) placing substring(int8send(floor(extract(epoch from clock_timestamp()) * 1000)::bigint) from 3) from 1 for 6), 52, 1), 53, 1), 'hex')::uuid, 'osm-outdoor', :'version', :'source_url', 'ODbL 1.0', '© OpenStreetMap contributors', null, :'checksum', :'scope', :'tier', now()); update geo.layers set source_version = :'version', updated_at = now() where key = 'outdoor-osm'; SQL # The ODbL notice, licence URI and 4.6 offer in the file's own metadata (F20.15); replaced atomically. stamp_odbl "$TILES" outdoor-osm osm-outdoor