Offline routing phase 1: valhalla container building from the offline map's extracts, status in the Offline data panel
CI / check (push) Successful in 55s
CI / deploy (push) Successful in 2m48s

This commit is contained in:
randy committed 2026-11-13 21:24:19 +01:00
1 parent 6f5f11cb4d
commit bf912b96e5
13 files changed
+455 -36

No files matched your search

+29 -1
View File
@@ -48,6 +48,13 @@ function formatOfflineMeta(meta) {
return ` · ${meta.sources.map((s) => s.code).join(", ")}`;
}
// Routing tiles live in the valhalla container's hands (see
// lib/maptool/routing.rb); "serving" says whether it actually answers.
function formatRoutingMeta(meta) {
if (!meta) return "";
return `${formatOfflineMeta(meta)} · ${meta.serving ? "routing ready" : "routing service not running"}`;
}
function formatTerrainMeta(meta) {
if (!meta) return "";
const count = meta.sources.length;
@@ -204,6 +211,18 @@ class DataFileRow {
this._deleteButton.addEventListener("click", () => this._delete());
container.appendChild(row);
this._refreshStatus();
this._resumePolling();
}
// A build started earlier (a routing build runs for hours) keeps showing
// its progress after a page reload.
async _resumePolling() {
try {
const status = await (await fetch(this._buildStatusUrl)).json();
if (status.state === "running") this._poll();
} catch {
// status stays whatever _refreshStatus shows
}
}
// Single place that writes to _statusEl, so the error styling (pre-wrap,
@@ -231,7 +250,7 @@ class DataFileRow {
const updated = new Date(data.mtime).toLocaleString([], { dateStyle: "short", timeStyle: "short" });
this._setStatus(`${formatBytes(data.size)} · updated ${updated}${this._formatMeta(data.meta)}`);
this._deleteButton.hidden = !isLoggedIn();
this._deleteButton.hidden = !isLoggedIn() || !this._deleteUrl;
this._checkUpdate();
}
@@ -368,6 +387,15 @@ export class OfflineDataControl {
checkUpdateUrl: "/api/terrain-tiles/check-update",
formatMeta: formatTerrainMeta,
}),
// No delete: the tiles are in use by the routing container.
new DataFileRow({
label: "Offline routing",
statusUrl: "/api/routing-tiles",
buildUrl: "/api/routing-tiles/build",
buildStatusUrl: "/api/routing-tiles/build-status",
checkUpdateUrl: "/api/routing-tiles/check-update",
formatMeta: formatRoutingMeta,
}),
];
this._regionPicker = new RegionPicker(() => this._rows.forEach((row) => row.triggerBuild()));
}