Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/active-owner-build-run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"workflow": "Build All Offline Owner Candidates",
"allowedRunId": "30518531875"
}
9 changes: 9 additions & 0 deletions planetiler/build-region.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ docker run --rm \
"$IMAGE" \
"${COMMON_ARGS[@]}"

# Planetiler runs as root inside the container and may leave root-owned temporary
# databases behind. Remove the temporary directory through the same container
# image so host-side cleanup cannot fail after a successful archive build.
docker run --rm \
--entrypoint /bin/sh \
-v "$DATA_DIR:/data" \
"$IMAGE" \
-c 'rm -rf /data/tmp'

test -s "$OUTPUT"
(
cd "$OUTPUT_DIR"
Expand Down
68 changes: 68 additions & 0 deletions scripts/aggregate-offline-owner-manifests.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env node

import fs from 'node:fs/promises';
import path from 'node:path';

const [inputDir, outputPath, expectedText = '51'] = process.argv.slice(2);
if (!inputDir || !outputPath) {
throw new Error('Usage: node scripts/aggregate-offline-owner-manifests.mjs INPUT_DIR OUTPUT.json [EXPECTED_FAMILIES]');
}
const expectedFamilies = Number(expectedText);
const files = [];
async function walk(directory) {
for (const entry of await fs.readdir(directory, { withFileTypes: true })) {
const absolute = path.join(directory, entry.name);
if (entry.isDirectory()) await walk(absolute);
else if (/occumed-owner-.*\.manifest\.json$/.test(entry.name)) files.push(absolute);
}
}
await walk(inputDir);

const families = [];
const cellOwners = new Map();
for (const filename of files.sort()) {
const manifest = JSON.parse(await fs.readFile(filename, 'utf8'));
families.push(manifest);
for (const partition of manifest.partitions || []) {
for (const cell of partition.cells || []) {
const key = `${cell.z}/${cell.x}/${cell.y}`;
const list = cellOwners.get(key) || [];
list.push({ family: manifest.family, asset: partition.asset || partition.pmtiles || partition.mbtiles });
cellOwners.set(key, list);
}
}
}

const conflicts = [...cellOwners.entries()]
.filter(([, owners]) => owners.length > 1)
.map(([cell, owners]) => ({ cell, owners }))
.sort((a, b) => a.cell.localeCompare(b.cell));
const familyIds = new Set(families.map((manifest) => manifest.family));
const duplicateFamilies = families
.map((manifest) => manifest.family)
.filter((family, index, all) => all.indexOf(family) !== index);

const aggregate = {
generatedAt: new Date().toISOString(),
version: 1,
architecture: 'immutable-offline-owner-partitions',
foundation: {
overviewAsset: 'occumed-world-overview.pmtiles',
surfaceAsset: 'occumed-world-surface.pmtiles',
minZoom: 0,
maxZoom: 10
},
regionalRoutingZoom: 11,
expectedFamilyCount: expectedFamilies,
completedFamilyCount: familyIds.size,
duplicateFamilies: [...new Set(duplicateFamilies)].sort(),
conflictCellCount: conflicts.length,
conflicts,
activationAllowed: familyIds.size === expectedFamilies && !duplicateFamilies.length && !conflicts.length,
families: families.sort((a, b) => a.family.localeCompare(b.family))
};

await fs.mkdir(path.dirname(outputPath), { recursive: true });
await fs.writeFile(outputPath, `${JSON.stringify(aggregate, null, 2)}\n`);
console.log(`Aggregated ${familyIds.size}/${expectedFamilies} families with ${conflicts.length} conflicting owner cells.`);
if (!aggregate.activationAllowed) process.exitCode = 1;
36 changes: 36 additions & 0 deletions scripts/build-regional-land-owner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail

geometry="${1:?Usage: build-regional-land-owner.sh REGION.geojson OUTPUT.pmtiles}"
output="${2:?Usage: build-regional-land-owner.sh REGION.geojson OUTPUT.pmtiles}"
workdir="$(mktemp -d /tmp/occumed-owner-land-XXXXXX)"
trap 'rm -rf "$workdir"' EXIT

curl --fail --location --retry 5 --retry-all-errors \
--output "$workdir/ne_10m_land.geojson" \
https://raw.githubusercontent.com/nvkelso/natural-earth-vector/v5.1.2/geojson/ne_10m_land.geojson

ogr2ogr -f GeoJSON \
"$workdir/land-clipped.geojson" \
"$workdir/ne_10m_land.geojson" \
-clipsrc "$geometry" \
-nln land

test -s "$workdir/land-clipped.geojson"
mkdir -p "$(dirname "$output")"

tippecanoe \
--force \
--minimum-zoom=11 \
--maximum-zoom=16 \
--preserve-input-order \
--no-feature-limit \
--no-tile-size-limit \
--no-simplification-of-shared-nodes \
--detect-shared-borders \
-L "land:$workdir/land-clipped.geojson" \
--output="$output"

test -s "$output"
test "$(head -c 7 "$output")" = PMTiles
echo "Built exact-region authoritative land owner surface: $output"
Loading