Skip to content

The OSINT investigator's workbench. One case, one folder, every tool. Local-first: your media and your investigations never leave your machine.

JavaScript

Remove the Labels map layer: CARTO's tiles now ask for a key (#89)

OsintMeThat4ab8d95a8e2f
diff --git a/docs/IMAGERY_PROVIDERS.md b/docs/IMAGERY_PROVIDERS.md
index e290bcd..dee1b1c 100644
--- a/docs/IMAGERY_PROVIDERS.md
+++ b/docs/IMAGERY_PROVIDERS.md
@@ -536,8 +536,7 @@ Checked 2026-09-13.
| Layer | Source | Licence / terms | Notes |
|---|---|---|---|
-| OSM labels | CARTO `voyager_only_labels` | © OSM contributors © CARTO | imagery only |
-| Borders | Esri `Reference/World_Boundaries_and_Places` | Esri terms, as World Imagery | |
+| Borders | Esri `Reference/World_Boundaries_and_Places` | Esri terms, as World Imagery | carries the place names |
| Roads | Esri `Reference/World_Transportation` | Esri terms, as World Imagery | imagery only |
| OSM railways | OpenRailwayMap `standard` | © OSM contributors, style © OpenRailwayMap | |
| Power lines | Open Infrastructure Map vector tiles (`/map/power`, `/telecoms`, `/petroleum`) | data ODbL, analysis CC-BY 4.0, credit and link required | no published tile usage policy, so the style is ours, requests only follow the view, and nothing is prefetched |
diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md
index 6cd0cce..8f0b8c7 100644
--- a/docs/RELEASE_NOTES.md
+++ b/docs/RELEASE_NOTES.md
@@ -96,6 +96,8 @@ maps made elsewhere on yours.
## Fixes
+- The Labels map layer is gone: CARTO's tiles now ask for a key and covered the
+ map with a watermark. Borders still names places, and Roads names streets.
- Changing only the case of a name renames it on Windows and macOS, where it
used to delete a collage or be refused.
- Two names differing only by case no longer block a bundle export on Linux.
diff --git a/docs/UI.md b/docs/UI.md
index 388c776..8708402 100644
--- a/docs/UI.md
+++ b/docs/UI.md
@@ -1591,8 +1591,8 @@ which it is (`lib/map/tools.js`) rather than adding a button somewhere.
- **Its settings** open in the rail's one **panel slot**, beside it. One mode is
armed, so one panel is open; a panel cannot cross another or the map's own
controls.
-- **Layers** — what is drawn over the imagery: OSM labels, borders, roads, OSM
- railways, power lines, sea marks, GPS traces, active fires, night lights, the
+- **Layers** — what is drawn over the imagery: borders with their place names,
+ roads, OSM railways, power lines, sea marks, GPS traces, active fires, night lights, the
case's saved work, and the points another tool handed over (a sheet's
coordinate column, a Timeline window). None of them changes what the
pointer does, so none takes a rail seat: they are a list in the panel beside
diff --git a/frontend/e2e/app.fixture.js b/frontend/e2e/app.fixture.js
index a16e4fb..68d3af4 100644
--- a/frontend/e2e/app.fixture.js
+++ b/frontend/e2e/app.fixture.js
@@ -694,7 +694,7 @@ function fixtureTemporalReading(raw) {
*/
export async function installAppFixture(page, options = {}) {
const unexpected = [];
- const labelTiles = [];
+ const railTiles = [];
const referenceTiles = [];
const captures = [];
const placeWrites = [];
@@ -952,12 +952,12 @@ export async function installAppFixture(page, options = {}) {
const url = new URL(request.url());
const path = url.pathname;
- // The labels overlay is the one layer served straight from its provider —
- // the proxy cannot expand a `{s}` template. Answered here, with the same
- // bytes as a proxied tile, so a spec can prove the overlay was asked for
- // without the run touching the network.
- if (url.hostname.endsWith('.basemaps.cartocdn.com')) {
- labelTiles.push(request.url());
+ // The railways are served straight from their provider — the proxy cannot
+ // expand a `{s}` template. Answered here, with the same bytes as a proxied
+ // tile, so a spec can prove the overlay was asked for without the run
+ // touching the network.
+ if (url.hostname.endsWith('.tiles.openrailwaymap.org')) {
+ railTiles.push(request.url());
return route.fulfill({ contentType: 'image/png', body: TILE_PNG });
}
@@ -1979,7 +1979,7 @@ export async function installAppFixture(page, options = {}) {
return {
captures,
placeWrites,
- labelTiles,
+ railTiles,
referenceTiles,
widgetLoads,
gridWrites,
diff --git a/frontend/e2e/satellite-overlays.spec.js b/frontend/e2e/satellite-overlays.spec.js
index 2e3154a..3ff2b56 100644
--- a/frontend/e2e/satellite-overlays.spec.js
+++ b/frontend/e2e/satellite-overlays.spec.js
@@ -234,7 +234,7 @@ test('carries the coordinates on a dragged pin, and drops it on exit', async ({
await expect(pin).toHaveCount(0);
});
-test('lays the OSM labels over the imagery, and lifts them off again', async ({ page }) => {
+test('lays the railways over the imagery, and lifts them off again', async ({ page }) => {
// The toggle sat on the tool while the layer never heard about it: the effect
// that carries it down read the map first, and while the map was still being
// built the switch it was watching was never read at all.
@@ -245,17 +245,17 @@ test('lays the OSM labels over the imagery, and lifts them off again', async ({
});
await page.goto('/#satellite');
await awaitMapReady(page);
- // the labels are a layer, listed with the others in the panel on the right
- const labels = page.getByLabel('OSM labels');
+ // the railways are a layer, listed with the others in the panel on the right
+ const rails = page.getByLabel('OSM railways');
- expect(fixture.labelTiles).toEqual([]);
- await labels.click();
- await expect.poll(() => fixture.labelTiles.length).toBeGreaterThan(0);
+ expect(fixture.railTiles).toEqual([]);
+ await rails.click();
+ await expect.poll(() => fixture.railTiles.length).toBeGreaterThan(0);
// off again, and a pan proves it: the imagery is still being fetched and the
- // labels are not
- await labels.click();
- const laid = fixture.labelTiles.length;
+ // railways are not
+ await rails.click();
+ const laid = fixture.railTiles.length;
const painted = imagery.length;
const box = await page.locator('.map').boundingBox();
await page.mouse.move(box.x + 400, box.y + 300);
@@ -263,7 +263,7 @@ test('lays the OSM labels over the imagery, and lifts them off again', async ({
await page.mouse.move(box.x + 120, box.y + 120, { steps: 8 });
await page.mouse.up();
await expect.poll(() => imagery.length).toBeGreaterThan(painted);
- expect(fixture.labelTiles.length).toBe(laid);
+ expect(fixture.railTiles.length).toBe(laid);
});
test('measures a path clicked on the map, and clears it', async ({ page }) => {
diff --git a/frontend/src/lib/map/basemap.js b/frontend/src/lib/map/basemap.js
index cc9653a..063ee8d 100644
--- a/frontend/src/lib/map/basemap.js
+++ b/frontend/src/lib/map/basemap.js
@@ -117,17 +117,6 @@ const OVERLAYS = [
attribution: 'Esri, HERE, Garmin, © OpenStreetMap contributors, and the GIS user community',
maxZoom: 19,
},
- {
- // Roads and place names readable without hiding the satellite view. Over a
- // street basemap it would only double its own labels, which is why the tool
- // keeps it to imagery.
- id: 'labels',
- layer: 'basemap-labels',
- url: 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_only_labels/{z}/{x}/{y}.png',
- subdomains: ['a', 'b', 'c', 'd'],
- attribution: '© OpenStreetMap contributors © CARTO',
- maxZoom: 20,
- },
{
// Active fire detections, live or from the archive (engine/firms.py). The
// key is NASA's and stays on the backend, so this one address is ours.
diff --git a/frontend/src/lib/map/basemap.test.js b/frontend/src/lib/map/basemap.test.js
index 7f52d4e..dafe843 100644
--- a/frontend/src/lib/map/basemap.test.js
+++ b/frontend/src/lib/map/basemap.test.js
@@ -1,6 +1,6 @@
// @vitest-environment happy-dom
import { describe, expect, it, vi } from 'vitest';
-import { rasterSource, sourceMaxZoom, tileTemplate, tileUrls } from './basemap.js';
+import { OVERLAY_IDS, rasterSource, sourceMaxZoom, tileTemplate, tileUrls } from './basemap.js';
/**
* The provider shapes are the ones `/api/satellite/providers` really answers
@@ -380,12 +380,12 @@ describe('the layers on a map', () => {
it('stops an overlay at its own last level rather than blowing it up', async () => {
await withStubbedGoogle(async ({ createBasemaps }) => {
const map = stubMap();
- createBasemaps(stubEngine(map)).setOverlay('labels', true);
+ createBasemaps(stubEngine(map)).setOverlay('railway', true);
// the deepest tile, and the deepest view, which the engine counts one
// shallower — the same number, two questions
- expect(map.sources.get('basemap-labels').maxzoom).toBe(20);
- expect(map.getLayer('basemap-labels').maxzoom).toBe(20);
- expect(map.sources.get('basemap-labels').tiles).toHaveLength(4);
+ expect(map.sources.get('basemap-railway').maxzoom).toBe(19);
+ expect(map.getLayer('basemap-railway').maxzoom).toBe(19);
+ expect(map.sources.get('basemap-railway').tiles).toHaveLength(3);
});
});
@@ -408,10 +408,10 @@ describe('the layers on a map', () => {
await withStubbedGoogle(async ({ createBasemaps }) => {
const map = stubMap();
const basemaps = createBasemaps(stubEngine(map));
- basemaps.setOverlay('labels', true);
- basemaps.setOverlay('labels', true);
- expect(map.layers.map((l) => l.id)).toEqual(['basemap-labels']);
- basemaps.setOverlay('labels', false);
+ basemaps.setOverlay('boundaries', true);
+ basemaps.setOverlay('boundaries', true);
+ expect(map.layers.map((l) => l.id)).toEqual(['basemap-boundaries']);
+ basemaps.setOverlay('boundaries', false);
expect(map.layers).toEqual([]);
});
});
@@ -463,11 +463,11 @@ describe('the layers on a map', () => {
const map = stubMap();
const basemaps = createBasemaps(stubEngine(map));
basemaps.setOverlay('firms', true, { sensor: 'viirs', window: '24h' });
- basemaps.setOverlay('labels', true);
+ basemaps.setOverlay('boundaries', true);
basemaps.setOverlay('railway', true);
expect(map.layers.map((l) => l.id)).toEqual([
'basemap-railway',
- 'basemap-labels',
+ 'basemap-boundaries',
'basemap-firms',
]);
});
@@ -479,9 +479,9 @@ describe('the layers on a map', () => {
const basemaps = createBasemaps(stubEngine(map));
// the names last, whichever order they arrive in: a station label under
// its own track is a label nobody can read
- basemaps.setOverlay('labels', true);
+ basemaps.setOverlay('boundaries', true);
basemaps.setOverlay('railway', true);
- expect(map.layers.map((l) => l.id)).toEqual(['basemap-railway', 'basemap-labels']);
+ expect(map.layers.map((l) => l.id)).toEqual(['basemap-railway', 'basemap-boundaries']);
});
});
@@ -491,7 +491,7 @@ describe('the layers on a map', () => {
const basemaps = createBasemaps(stubEngine(map));
basemaps.show(ESRI, ESRI.id, 256);
basemaps.setOverlay('railway', true);
- basemaps.setOverlay('labels', true);
+ basemaps.setOverlay('boundaries', true);
// a tool's own layer, appended above all three
map.addLayer({ id: 'sfc-1-fill' });
// and now a different provider, which must not land on top of any of them
@@ -499,7 +499,7 @@ describe('the layers on a map', () => {
expect(map.layers.map((l) => l.id)).toEqual([
'basemap-imagery',
'basemap-railway',
- 'basemap-labels',
+ 'basemap-boundaries',
'sfc-1-fill',
]);
});
@@ -534,13 +534,13 @@ describe('the layers on a map', () => {
await withStubbedGoogle(async ({ createBasemaps }) => {
const map = stubMap();
const basemaps = createBasemaps(stubEngine(map));
- basemaps.setOverlay('labels', true);
+ basemaps.setOverlay('boundaries', true);
basemaps.setOverlay('railway', true);
basemaps.setOverlay('power', true);
const ids = map.layers.map((l) => l.id);
// over the tracks, under the names
expect(ids[0]).toBe('basemap-railway');
- expect(ids.at(-1)).toBe('basemap-labels');
+ expect(ids.at(-1)).toBe('basemap-boundaries');
expect(ids.slice(1, -1).every((id) => id.startsWith('basemap-power-'))).toBe(true);
});
});
@@ -550,7 +550,7 @@ describe('the layers on a map', () => {
const map = stubMap();
const basemaps = createBasemaps(stubEngine(map));
basemaps.show(ESRI, ESRI.id, 256);
- for (const id of ['firms', 'labels', 'boundaries', 'seamarks', 'railway', 'roads', 'gpstraces']) {
+ for (const id of ['firms', 'boundaries', 'seamarks', 'railway', 'roads', 'gpstraces']) {
basemaps.setOverlay(id, true, id === 'firms' ? { sensor: 'viirs', window: '24h' } : undefined);
}
basemaps.setOverlay('nightlights', true, { source: 'noaa20', day: '2026-09-12' });
@@ -562,12 +562,15 @@ describe('the layers on a map', () => {
'basemap-railway',
'basemap-seamarks',
'basemap-boundaries',
- 'basemap-labels',
'basemap-firms',
]);
});
});
+ it('has no CARTO labels layer: its tiles now ask for a key, and the borders name places', () => {
+ expect(OVERLAY_IDS).not.toContain('labels');
+ });
+
it('asks GIBS for the night it was given, and lets its coarse pixels be read zoomed in', async () => {
await withStubbedGoogle(async ({ createBasemaps }) => {
const map = stubMap();
diff --git a/frontend/src/lib/map/compare.js b/frontend/src/lib/map/compare.js
index b31df51..013521a 100644
--- a/frontend/src/lib/map/compare.js
+++ b/frontend/src/lib/map/compare.js
@@ -29,7 +29,6 @@ export const BLINK_SPEEDS = Object.freeze([
/** Reference layers Compare can persist, grouped the way the sheet lists them. */
export const COMPARE_LAYERS = Object.freeze([
- { id: 'labels', label: 'Labels', hint: 'Roads and place names', group: 'reference' },
{ id: 'boundaries', label: 'Borders', hint: 'Country, region and district borders', group: 'reference' },
{ id: 'roads', label: 'Roads', hint: 'Road network', group: 'reference' },
{ id: 'railway', label: 'Railways', hint: 'Tracks, sidings and stations', group: 'reference' },
diff --git a/frontend/src/lib/map/compare.test.js b/frontend/src/lib/map/compare.test.js
index d1adebe..77b6d21 100644
--- a/frontend/src/lib/map/compare.test.js
+++ b/frontend/src/lib/map/compare.test.js
@@ -25,8 +25,8 @@ describe('compare helpers', () => {
});
it('keeps layers ordered, unique and supported', () => {
+ // 'labels' is a layer that was retired: a session saved with it opens without it
expect(comparisonLayers(['saved', 'roads', 'roads', 'buildings', 'labels'])).toEqual([
- 'labels',
'roads',
'saved',
]);
diff --git a/frontend/src/tools/Compare.render.test.js b/frontend/src/tools/Compare.render.test.js
index 01fbaf9..7aee0f7 100644
--- a/frontend/src/tools/Compare.render.test.js
+++ b/frontend/src/tools/Compare.render.test.js
@@ -531,7 +531,7 @@ describe('Compare', () => {
const layers = document.querySelector('[role="dialog"]');
expect(layers.getAttribute('aria-label')).toBe('Layers · A / B');
expect(layers.querySelectorAll('.layer-pane')).toHaveLength(2);
- expect(layers.querySelectorAll('.layer-row')).toHaveLength(20);
+ expect(layers.querySelectorAll('.layer-row')).toHaveLength(18);
expect(layers.textContent).toContain('Active fires');
expect(layers.textContent).toContain('Night lights');
expect(layers.textContent).toContain('Saved work');
diff --git a/frontend/src/tools/Detect.render.test.js b/frontend/src/tools/Detect.render.test.js
index bbaf8d5..239c4f9 100644
--- a/frontend/src/tools/Detect.render.test.js
+++ b/frontend/src/tools/Detect.render.test.js
@@ -129,7 +129,7 @@ const setOverlay = vi.fn();
const setAlternate = vi.fn();
const showAlternate = vi.fn();
vi.mock('../lib/map/basemap.js', () => ({
- OVERLAY_IDS: ['boundaries', 'roads', 'labels'],
+ OVERLAY_IDS: ['boundaries', 'roads'],
createBasemaps: vi.fn(() => ({ show: showBasemap, setOverlay, setAlternate, showAlternate,
setZoomCeiling: vi.fn(), dispose: vi.fn() })),
}));
@@ -272,6 +272,15 @@ describe('Detect', () => {
expect(post).not.toHaveBeenCalled();
});
+ it('drops a retired layer from the saved overlays, so the next save is not refused', async () => {
+ prefs.detectView = { collapsed: false, basemap: 'esri-world-imagery', overlays: ['labels', 'roads'], saved: true };
+ await open();
+ expect(setOverlay).not.toHaveBeenCalledWith('labels', true, expect.anything());
+ target.querySelector('[aria-label="Collapse Detect panel"]').click(); await settle();
+ expect(put).toHaveBeenLastCalledWith('/api/settings/prefs', {
+ detect_view: expect.objectContaining({ overlays: ['roads'] }) });
+ });
+
it('takes the current view as an area to sweep', async () => {
await open();
button('New detection').click(); await settle();
diff --git a/frontend/src/tools/Detect.svelte b/frontend/src/tools/Detect.svelte
index 96a7b2f..84beba8 100644
--- a/frontend/src/tools/Detect.svelte
+++ b/frontend/src/tools/Detect.svelte
@@ -76,9 +76,10 @@
* its Copernicus layer and day, but none is remembered as the basemap: Detect
* opens on free imagery every time. */
const PASSES = [SENTINEL, RADAR_ID];
+ const OVERLAY_ROWS = [['boundaries', 'Borders'], ['roads', 'Roads'], ['railway', 'Railways'],
+ ['power', 'Power lines'], ['seamarks', 'Seamarks'], ['gpstraces', 'GPS traces']];
const layerRows = $derived([
- ...[['boundaries', 'Borders'], ['labels', 'Labels'], ['roads', 'Roads'], ['railway', 'Railways'],
- ['power', 'Power lines'], ['seamarks', 'Seamarks'], ['gpstraces', 'GPS traces']].map(([id, label]) => ({
+ ...OVERLAY_ROWS.map(([id, label]) => ({
id, label, on: overlays.includes(id), toggle: () => {
overlays = overlays.includes(id) ? overlays.filter((value) => value !== id) : [...overlays, id];
},
@@ -194,7 +195,9 @@
collapsed = saved?.collapsed ?? false;
chosenBasemap = saved?.basemap && !PASSES.includes(saved.basemap) ? saved.basemap : 'esri-world-imagery';
providerId = chosenBasemap;
- overlays = [...(saved?.overlays ?? ['boundaries'])];
+ // Only the layers still offered: a retired one (Labels) would be sent back
+ // with the next save and refused.
+ overlays = (saved?.overlays ?? ['boundaries']).filter((id) => OVERLAY_ROWS.some(([row]) => row === id));
savedVisible = saved?.saved ?? true;
prefsLoaded = true;
home = { ...prefs.homeView };
diff --git a/frontend/src/tools/Satellite.svelte b/frontend/src/tools/Satellite.svelte
index 18ac7d7..f1e7c07 100644
--- a/frontend/src/tools/Satellite.svelte
+++ b/frontend/src/tools/Satellite.svelte
@@ -205,11 +205,8 @@
let mapReady = $state(false);
let mapRefused = $state(false);
- // OSM labels overlay: a transparent labels-only layer laid over the imagery so
- // roads / place names are readable without hiding the satellite view (item 1).
- let osmOverlay = $state(false);
- // OpenRailwayMap over the same imagery: which of two parallel strips is a
- // railway, where a siding ends, what a yard is made of. Unlike the labels it
+ // OpenRailwayMap over the imagery: which of two parallel strips is a
+ // railway, where a siding ends, what a yard is made of. Unlike the roads it
// is worth having over a street base map too, which draws tracks as one
// undifferentiated line.
let railOverlay = $state(false);
@@ -359,7 +356,6 @@
/** What the surface is asked to lay over the picture (lib/map/basemap.js). */
const overlays = $derived(
[
- osmOverlay && baseIsImagery && 'labels',
refLayers.boundaries && 'boundaries',
refLayers.roads && baseIsImagery && 'roads',
railOverlay && 'railway',
@@ -631,10 +627,9 @@
if (fullscreen && !document.fullscreenElement) toggleFullscreen();
}
- // force the labels overlay off whenever the base isn't imagery (item 1), and
- // the roads with it: a street map already draws both
+ // force the roads off whenever the base isn't imagery: a street map already
+ // draws them
$effect(() => {
- if (!baseIsImagery && osmOverlay) osmOverlay = false;
if (!baseIsImagery && refLayers.roads) refLayers.roads = false;
});
@@ -1137,17 +1132,6 @@
* different intentions and used to be the same button.
*/
const layerRows = $derived([
- {
- id: 'labels',
- label: 'OSM labels',
- on: osmOverlay,
- disabled: !baseIsImagery,
- detail: baseIsImagery ? '' : 'imagery only',
- title: baseIsImagery
- ? 'Roads and place names over the imagery'
- : 'Only useful over satellite imagery',
- toggle: () => (osmOverlay = !osmOverlay),
- },
{
id: 'railway',
label: 'OSM railways',
diff --git a/frontend/src/tools/Satellite.test.js b/frontend/src/tools/Satellite.test.js
index caf3eb0..3f6ddba 100644
--- a/frontend/src/tools/Satellite.test.js
+++ b/frontend/src/tools/Satellite.test.js
@@ -350,19 +350,23 @@ describe('what is laid over the imagery', () => {
);
});
- it('offers the railways over any basemap and the labels only over imagery', () => {
- // OSM's own street map already draws its labels twice; it draws a railway
- // as one more line, which is the thing OpenRailwayMap is for
- expect(source).toContain("osmOverlay && baseIsImagery && 'labels'");
+ it('offers the railways over any basemap and the roads only over imagery', () => {
+ // OSM's own street map already draws its roads; it draws a railway as one
+ // more line, which is the thing OpenRailwayMap is for
+ expect(source).toContain("refLayers.roads && baseIsImagery && 'roads'");
expect(source).toContain("railOverlay && 'railway'");
const rows = source.slice(source.indexOf('const layerRows = $derived(['));
expect(rows.slice(0, 900)).toContain("label: 'OSM railways'");
expect(rows.slice(0, 900)).toContain('toggle: () => (railOverlay = !railOverlay)');
});
- it('gives neither of them a rail seat', () => {
+ it('gives the railways no rail seat', () => {
expect(rail).not.toContain('railOverlay');
- expect(rail).not.toContain('osmOverlay');
+ });
+
+ it('has no labels layer: its tiles now ask for a key, and Borders names places', () => {
+ expect(source).not.toContain("'labels'");
+ expect(source).not.toContain('OSM labels');
});
it('fetches no railway tile until it is asked for', () => {
@@ -395,7 +399,7 @@ describe('what is laid over the imagery', () => {
it('says a layer is for imagery only when the basemap is not imagery', () => {
const rows = source.slice(source.indexOf('const layerRows = $derived(['));
- expect(rows.match(/detail: baseIsImagery \? '' : 'imagery only'/g)).toHaveLength(2);
+ expect(rows.match(/detail: baseIsImagery \? '' : 'imagery only'/g)).toHaveLength(1);
});
it('asks for no tile until the choice is one the service can answer', () => {
diff --git a/frontend/src/tools/proof/PointMapDialog.render.test.js b/frontend/src/tools/proof/PointMapDialog.render.test.js
index 5a554c0..cadf3d5 100644
--- a/frontend/src/tools/proof/PointMapDialog.render.test.js
+++ b/frontend/src/tools/proof/PointMapDialog.render.test.js
@@ -62,7 +62,7 @@ vi.mock('../../lib/map/engine.js', () => ({
const setOverlay = vi.fn();
vi.mock('../../lib/map/basemap.js', () => ({
- OVERLAY_IDS: ['labels', 'roads', 'boundaries', 'railway', 'power', 'seamarks', 'gpstraces'],
+ OVERLAY_IDS: ['roads', 'boundaries', 'railway', 'power', 'seamarks', 'gpstraces'],
createBasemaps: vi.fn(() => ({
show: vi.fn(),
setOverlay,
@@ -155,10 +155,10 @@ describe('moving a proof point on the map', () => {
expect(onpick).not.toHaveBeenCalled();
});
- it('offers the reference layers, labels first and already on', async () => {
+ it('offers the reference layers, the borders already on for their place names', async () => {
await open();
- expect(setOverlay).toHaveBeenCalledWith('labels', true, null);
+ expect(setOverlay).toHaveBeenCalledWith('boundaries', true, null);
expect(setOverlay).toHaveBeenCalledWith('railway', false, undefined);
button('Layers').click();
@@ -167,7 +167,6 @@ describe('moving a proof point on the map', () => {
entry.textContent.trim()
);
expect(names).toEqual([
- 'Labels',
'Borders',
'Roads',
'Railways',
diff --git a/frontend/src/tools/proof/PointMapDialog.svelte b/frontend/src/tools/proof/PointMapDialog.svelte
index 3fc31f6..80ece0b 100644
--- a/frontend/src/tools/proof/PointMapDialog.svelte
+++ b/frontend/src/tools/proof/PointMapDialog.svelte
@@ -40,8 +40,8 @@
} = $props();
const PIN = 'point';
- /** Only these two read wrongly over a street basemap, which draws its own. */
- const IMAGERY_ONLY = new Set(['labels', 'roads']);
+ /** Only the roads read wrongly over a street basemap, which draws its own. */
+ const IMAGERY_ONLY = new Set(['roads']);
const REFERENCE = COMPARE_LAYERS.filter((layer) => layer.group === 'reference');
const imagery = createImageryState({ api });
@@ -53,7 +53,8 @@
// Where the pin starts: the opening camera, read once. The dialog is opened on
// one row and closed on it, so a later view would be a different question.
let at = $state(untrack(() => ({ lat: view.lat, lon: view.lon })));
- let on = $state(['labels']);
+ // The borders carry the place names, which is what finding a spot needs.
+ let on = $state(['boundaries']);
let layersOpen = $state(false);
let surface = null;
diff --git a/src/azimut/api/compare.py b/src/azimut/api/compare.py
index eae7407..a1ef919 100644
--- a/src/azimut/api/compare.py
+++ b/src/azimut/api/compare.py
@@ -46,6 +46,7 @@ from .. import config, layout
from ..engine import artifacts as artifact_engine
from ..engine import comparisons, exportdir, sentinel, tiles
from ..engine import links as link_engine
+from ..engine.analysis_models import RETIRED_OVERLAYS
from ..engine import media as media_engine
from ..workspace import Case, CaseError
from .cases import delete_by_path, get_case
@@ -55,7 +56,7 @@ from .satellite import locate_on_save, saved_changed
router = APIRouter(prefix="/api", tags=["compare"])
OVERLAYS = frozenset({
- "labels", "boundaries", "roads", "railway", "power", "seamarks", "gpstraces",
+ "boundaries", "roads", "railway", "power", "seamarks", "gpstraces",
"firms", "nightlights", "saved",
})
MAX_FRAME_BYTES = 24_000_000
@@ -125,7 +126,8 @@ class CompareNightlights(BaseModel):
class CompareSide(BaseModel):
present: bool = False
provider: str = Field(default="esri-world-imagery", min_length=1, max_length=500)
- overlays: list[str] = Field(default_factory=list, max_length=len(OVERLAYS))
+ # Room for a retired layer too: it is dropped after, not refused here.
+ overlays: list[str] = Field(default_factory=list, max_length=len(OVERLAYS) + len(RETIRED_OVERLAYS))
sentinel: CompareSentinel = Field(default_factory=CompareSentinel)
wayback_release: int | None = Field(default=None, ge=1)
radar: CompareRadar = Field(default_factory=CompareRadar)
@@ -303,6 +305,8 @@ def _validated_spec(spec: CompareSpec) -> dict[str, Any]:
tiles.get_provider(side["provider"])
except KeyError as exc:
raise HTTPException(status_code=422, detail=str(exc)) from exc
+ # A layer that was retired drops out of a session saved with it.
+ side["overlays"] = [entry for entry in side["overlays"] if entry not in RETIRED_OVERLAYS]
unknown = set(side["overlays"]) - OVERLAYS
if unknown:
raise HTTPException(
diff --git a/src/azimut/engine/analysis_models.py b/src/azimut/engine/analysis_models.py
index f58416b..876fc0c 100644
--- a/src/azimut/engine/analysis_models.py
+++ b/src/azimut/engine/analysis_models.py
@@ -19,6 +19,7 @@ from pydantic import (
Field,
FiniteFloat,
SerializerFunctionWrapHandler,
+ field_validator,
model_serializer,
model_validator,
)
@@ -76,13 +77,26 @@ class Model(BaseModel):
model_config = ConfigDict(extra="forbid", allow_inf_nan=False)
+#: Map layers that no longer exist. A saved preference or a settings backup that
+#: still names one drops it rather than being refused: CARTO's labels went when
+#: their tiles began asking for a key, and the borders already name places.
+RETIRED_OVERLAYS = frozenset({"labels"})
+
+
class DetectPrefs(Model):
collapsed: bool = False
basemap: str = Field(default="esri-world-imagery", max_length=120, pattern=r"^[a-zA-Z0-9_-]+$")
- overlays: list[Literal["boundaries", "labels", "roads", "railway", "power", "seamarks", "gpstraces"]] = Field(
- default=["boundaries"], max_length=7)
+ overlays: list[Literal["boundaries", "roads", "railway", "power", "seamarks", "gpstraces"]] = Field(
+ default=["boundaries"], max_length=6)
saved: bool = True
+ @field_validator("overlays", mode="before")
+ @classmethod
+ def _drop_retired(cls, value: Any) -> Any:
+ if isinstance(value, list):
+ return [entry for entry in value if entry not in RETIRED_OVERLAYS]
+ return value
+
class Parameters(Model):
# Moves each method's threshold inside the range it was calibrated over
diff --git a/src/azimut/engine/tiles.py b/src/azimut/engine/tiles.py
index 361705a..620b56d 100644
--- a/src/azimut/engine/tiles.py
+++ b/src/azimut/engine/tiles.py
@@ -46,7 +46,7 @@ class Provider:
needs_key: bool = False
subdomains: tuple[str, ...] = field(default_factory=tuple) # for {s} templates
# True for satellite/aerial imagery, False for street/base maps. Drives the UI:
- # the OSM labels overlay is only useful over imagery (§ Satellite item 1).
+ # the roads overlay is only useful over imagery, a street map draws its own.
imagery: bool = True
capturable: bool = True # may a saved capture be filed from it?
cacheable: bool = True # may its tiles be written to a disk cache?
diff --git a/tests/test_compare_api.py b/tests/test_compare_api.py
index 24b9078..359b304 100644
--- a/tests/test_compare_api.py
+++ b/tests/test_compare_api.py
@@ -777,3 +777,20 @@ def test_a_colour_list_the_app_never_writes_is_refused(client, keep):
data={"animation": "blink", "filename": "Bad", "keep": keep},
)
assert response.status_code == 422
+
+
+def test_a_session_saved_with_the_retired_labels_layer_saves_without_it(client):
+ # CARTO's labels went when their tiles began asking for a key. A session kept
+ # from before, or a tab left open across the update, still sends the id.
+ cid = _case(client, "Retired labels")
+ spec = _spec()
+ spec["a"]["overlays"] = ["labels", "roads", "labels"]
+ everything = ["labels", "boundaries", "roads", "railway", "power", "seamarks",
+ "gpstraces", "firms", "nightlights", "saved"]
+ spec["b"]["overlays"] = everything
+ res = _save(client, cid, "Before the key", spec=spec)
+ assert res.status_code == 200, res.text
+ loaded = client.get(f"/api/cases/{cid}/compare/sessions/Before%20the%20key").json()
+ assert loaded["spec"]["a"]["overlays"] == ["roads"]
+ assert "labels" not in loaded["spec"]["b"]["overlays"]
+ assert len(loaded["spec"]["b"]["overlays"]) == len(everything) - 1
diff --git a/tests/test_satellite_api.py b/tests/test_satellite_api.py
index 07c2a5d..012e500 100644
--- a/tests/test_satellite_api.py
+++ b/tests/test_satellite_api.py
@@ -20,7 +20,7 @@ def _fake_tile(client, url): # offline: every tile is a solid green square
def test_providers_flag_imagery_vs_street(client):
- # the UI uses `imagery` to disable the OSM labels overlay over street maps
+ # the UI uses `imagery` to disable the roads overlay over street maps
providers = {p["id"]: p for p in client.get("/api/satellite/providers").json()}
assert providers["esri-world-imagery"]["imagery"] is True
assert providers["osm"]["imagery"] is False
diff --git a/tests/test_settings_api.py b/tests/test_settings_api.py
index fd8580d..d00124b 100644
--- a/tests/test_settings_api.py
+++ b/tests/test_settings_api.py
@@ -1108,3 +1108,13 @@ def test_update_then_reset_round_trip(client, monkeypatch):
def test_scrapers_live_in_the_workspace_not_the_install(client):
"""The runtime dir has to be somewhere writable — the binary's own dir isn't."""
assert config.runtime_dir().parent == config.internal_dir()
+
+
+def test_detect_prefs_drop_the_retired_labels_layer(client):
+ # A preference saved while the Labels layer existed is not refused for it.
+ saved = client.put(
+ "/api/settings/prefs",
+ json={"detect_view": {"overlays": ["labels", "boundaries", "roads"]}},
+ )
+ assert saved.status_code == 200, saved.text
+ assert saved.json()["detect_view"]["overlays"] == ["boundaries", "roads"]
diff --git a/tests/test_settings_backup.py b/tests/test_settings_backup.py
index 7d3bd53..e4d4839 100644
--- a/tests/test_settings_backup.py
+++ b/tests/test_settings_backup.py
@@ -366,3 +366,12 @@ def test_a_backup_naming_a_dropped_target_still_restores(client):
# The live route is the other side of that: there the caller is the UI, and a
# target it does not offer is a bug rather than a machine's history.
assert client.put("/api/settings/prefs", json={"post_target": "mastodon"}).status_code == 422
+
+
+def test_a_backup_naming_the_retired_labels_layer_still_imports(client):
+ res = client.post(
+ "/api/settings/import",
+ json={"settings": {"detect_view": {"collapsed": True, "overlays": ["labels", "roads"]}}},
+ )
+ assert res.status_code == 200, res.text
+ assert client.get("/api/settings").json()["detect_view"]["overlays"] == ["roads"]