Skip to content

A spy satellite simulator in your browser, except the data is real. Live open source spatial intelligence on a photorealistic 3D globe.

fix(imagery): require explicit Data-Present proof before decoding thumbnails

Rudy Celekli3962ac52f719
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a770fbd35..6f5ee5c10 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -33,6 +33,8 @@
- Director timeline seeks cross the dateline along the short longitude arc.
+- Recent Imagery thumbnails require explicit presence evidence before reporting available pixels.
+
- Treat explicitly current, complete empty vessel coverage as a successful update,
clearing obsolete contacts while retaining stale or incomplete snapshots.
diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md
index 1f794a5b5..93e5214a5 100644
--- a/docs/CURRENT-STATE.md
+++ b/docs/CURRENT-STATE.md
@@ -4449,6 +4449,8 @@ are omitted rather than framing the wrong part of the globe.
### Recent Imagery (September 2026)
+Thumbnail decoding requires explicit `Data-Present: true` evidence; false remains empty, while absent or malformed evidence reports an error. Injected `getThumbnail` sources must return an OK Response with readable `Data-Present: true` to admit image bytes, or `false` for confirmed empty coverage. Cross-origin sources must expose that header to browser JavaScript.
+
- The layer sits in the Data Layers panel's Cameras group beside Cameras (CCTV); Mapped ALPR Cameras moved to the Infrastructure group to make room.
- DATA ▸ **Recent Imagery** (`recent-imagery`, `src/layers/recentImagery/`) lists the last 30 UTC days of imagery for a selected box and drapes the days you pick: HLS S30 (Sentinel-2) and L30 (Landsat 8/9) at 30 m, and the VIIRS NOAA-21 daily overview at 250 m. Keyless and browser-direct: NASA CMR for which days have HLS granules in the box (`catalog.js`, both collections concurrently, paged with `CMR-Search-After` up to 2,000 records each, `truncated` against CMR `hits`), GIBS WMTS for tiles, Worldview Snapshots for thumbnails and exports. Worldview's `Data-Present` header is the only availability signal: GIBS answers an empty tile with HTTP 200, and the JPEG overview would drape black, so a day confirmed empty never drapes.
- **Box.** SELECT BOX (`src/ui/imageryBoxTool.js`) claims the pointer like Draw, borrows the stock click actions and freezes the camera only mid-drag; USE VIEW takes the camera rectangle; `boxFromPinAt` grows a 10 km box. Boxes must be ≤ 1,000 km a side, on one side of the dateline and inside the Web-Mercator limit (`validateBox`). A refusal (`boxError`, including the tool's own via `reportBoxRefusal`) stays at the top of the panel until a box succeeds; a view over the cap is refused with its size, never shrunk. An oversized box or view (`Box is … km wide · limit 1,000 km`, `View is … wide · …`) sets the hint to `Zoom in or draw a smaller box` and enables ZOOM IN: `zoomToFit()` flies top-down (1.2 s) to the refused box's centre, or the ground under the canvas centre for a view, at the height whose view is about 400 km wide for the canvas aspect and the camera's vertical FOV (`fitViewHeightM`, clamped 5–400 km), and returns that height.
diff --git a/src/layers/recentImagery/source.js b/src/layers/recentImagery/source.js
index 258e8e2e1..9e6749cb7 100644
--- a/src/layers/recentImagery/source.js
+++ b/src/layers/recentImagery/source.js
@@ -1,7 +1,11 @@
import { searchHls } from './catalog.js';
import { gibsTemplate, wvsSnapshotUrl } from './model.js';
-/** NASA-compatible imagery acquisition; transport and URL builders are replaceable. */
+/**
+ * NASA-compatible imagery acquisition; transport and URL builders are replaceable.
+ * Thumbnail responses must expose Data-Present: true for image admission, or
+ * false for confirmed empty coverage, including injected getThumbnail sources.
+ */
export function createRecentImagerySource({
fetchImpl = (...args) => globalThis.fetch(...args),
search = searchHls,
diff --git a/src/layers/recentImagery/thumbnail-presence-proof.test.mjs b/src/layers/recentImagery/thumbnail-presence-proof.test.mjs
new file mode 100644
index 000000000..4605079b1
--- /dev/null
+++ b/src/layers/recentImagery/thumbnail-presence-proof.test.mjs
@@ -0,0 +1,30 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { createThumbnailLoader } from './thumbnails.js';
+test('missing or malformed presence evidence cannot prove thumbnail pixels', async () => {
+ for (const header of [null, 'unknown', '', 'true', 'false']) {
+ let decodes = 0;
+ const loader = createThumbnailLoader({
+ requestThumbnail: async () => ({
+ ok: true,
+ headers: { get: (key) => (key === 'Data-Present' ? header : null) },
+ blob: async () => {
+ decodes++;
+ return new Blob(['fixture']);
+ },
+ }),
+ createObjectUrl: () => 'blob:fixture',
+ });
+ loader.request(
+ { key: 'fixture', product: 'S30', day: '2026-09-18' },
+ { west: 0, east: 1, south: 0, north: 1 },
+ );
+ await new Promise((resolve) => setImmediate(resolve));
+ assert.equal(
+ loader.get('fixture').status,
+ header === 'true' ? 'present' : header === 'false' ? 'empty' : 'error',
+ );
+ assert.equal(decodes, header === 'true' ? 1 : 0);
+ loader.destroy();
+ }
+});
diff --git a/src/layers/recentImagery/thumbnails.js b/src/layers/recentImagery/thumbnails.js
index 23fe4dd49..4aaec294b 100644
--- a/src/layers/recentImagery/thumbnails.js
+++ b/src/layers/recentImagery/thumbnails.js
@@ -100,12 +100,12 @@ export function createThumbnailLoader({
cancelled = true;
} else if (response?.ok) {
const present = String(
- response.headers?.get?.('Data-Present') ?? 'true',
+ response.headers?.get?.('Data-Present') ?? '',
).toLowerCase();
acquisitionTime = response.headers?.get?.('Acquisition-Time') || null;
if (present === 'false') {
status = 'empty';
- } else {
+ } else if (present === 'true') {
const blob = await response.blob();
if (controller.signal.aborted) cancelled = true;
else {