From 160b3c5a253dffd23cf99e680f279d1e67d540e5 Mon Sep 17 00:00:00 2001 From: Shadowbroker <43977454+BigBodyCobain@users.noreply.github.com> Date: Sun, 18 Oct 2026 04:31:50 -0600 Subject: [PATCH] fix(map): pin text-font on label layers so CCTV and correlation overlays render Seven overlay label layers had a text-field but no text-font, so MapLibre fell back to "Open Sans Regular,Arial Unicode MS Regular". The keyless OpenFreeMap glyph endpoint returns 404 for that fontstack, which errors every tile of the layer's source. For CCTV that meant the whole source (clusters and dots) rendered nothing even though 23k cameras were loaded. Affected layers: cctv-cluster-count, gps-jamming-label, corr-rf-label, corr-mil-label, corr-infra-label, corr-contra-label, corr-analysis-label. All now use Noto Sans Bold, matching the other overlay labels. Adds a regression test that fails if any MaplibreViewer layout renders text without pinning a text-font. Co-Authored-By: Claude Opus 5.5 --- .../src/__tests__/map/mapLabelFonts.test.ts | 44 +++++++++++++++++++ frontend/src/components/MaplibreViewer.tsx | 7 +++ 2 files changed, 51 insertions(+) create mode 100644 frontend/src/__tests__/map/mapLabelFonts.test.ts diff --git a/frontend/src/__tests__/map/mapLabelFonts.test.ts b/frontend/src/__tests__/map/mapLabelFonts.test.ts new file mode 100644 index 00000000..2b4081b5 --- /dev/null +++ b/frontend/src/__tests__/map/mapLabelFonts.test.ts @@ -0,0 +1,44 @@ +/** + * Regression: every overlay label layer must pin an explicit `text-font`. + * + * Without one, MapLibre falls back to "Open Sans Regular,Arial Unicode MS Regular", + * which the keyless OpenFreeMap glyph endpoint does not serve (HTTP 404). The failed + * glyph request errors every tile of the layer's source, so the whole source stops + * rendering — e.g. the CCTV cluster count took the CCTV circles down with it. + */ +import { describe, expect, it } from 'vitest'; +import * as fs from 'fs'; +import * as path from 'path'; + +const VIEWER = path.resolve(__dirname, '../../components/MaplibreViewer.tsx'); + +function layoutBlocks(source: string): { line: number; body: string }[] { + const blocks: { line: number; body: string }[] = []; + const marker = 'layout={{'; + let start = source.indexOf(marker); + while (start !== -1) { + let depth = 2; + let i = start + marker.length; + while (depth > 0 && i < source.length) { + if (source[i] === '{') depth += 1; + else if (source[i] === '}') depth -= 1; + i += 1; + } + blocks.push({ + line: source.slice(0, start).split('\n').length, + body: source.slice(start + marker.length, i), + }); + start = source.indexOf(marker, i); + } + return blocks; +} + +describe('MaplibreViewer label layers', () => { + it('pin a text-font on every layout that renders text', () => { + const source = fs.readFileSync(VIEWER, 'utf-8'); + const missing = layoutBlocks(source) + .filter((b) => b.body.includes("'text-field'") && !b.body.includes("'text-font'")) + .map((b) => `MaplibreViewer.tsx:${b.line}`); + expect(missing).toEqual([]); + }); +}); diff --git a/frontend/src/components/MaplibreViewer.tsx b/frontend/src/components/MaplibreViewer.tsx index e525676d..caddebec 100644 --- a/frontend/src/components/MaplibreViewer.tsx +++ b/frontend/src/components/MaplibreViewer.tsx @@ -2289,6 +2289,7 @@ const MaplibreViewer = ({ id="gps-jamming-label" type="symbol" layout={{ + 'text-font': ['Noto Sans Bold'], 'text-field': [ 'concat', 'GPS JAM ', @@ -2386,6 +2387,7 @@ const MaplibreViewer = ({ filter={['==', ['get', 'corr_type'], 'rf_anomaly']} minzoom={3} layout={{ + 'text-font': ['Noto Sans Bold'], 'text-field': ['concat', 'RF ANOMALY\n', ['get', 'drivers']], 'text-size': ['interpolate', ['linear'], ['zoom'], 3, 7, 5, 9, 8, 11], 'text-allow-overlap': false, @@ -2426,6 +2428,7 @@ const MaplibreViewer = ({ filter={['==', ['get', 'corr_type'], 'military_buildup']} minzoom={3} layout={{ + 'text-font': ['Noto Sans Bold'], 'text-field': ['concat', 'MIL BUILDUP\n', ['get', 'drivers']], 'text-size': ['interpolate', ['linear'], ['zoom'], 3, 7, 5, 9, 8, 11], 'text-allow-overlap': false, @@ -2465,6 +2468,7 @@ const MaplibreViewer = ({ filter={['==', ['get', 'corr_type'], 'infra_cascade']} minzoom={3} layout={{ + 'text-font': ['Noto Sans Bold'], 'text-field': ['concat', 'INFRA CASCADE\n', ['get', 'drivers']], 'text-size': ['interpolate', ['linear'], ['zoom'], 3, 7, 5, 9, 8, 11], 'text-allow-overlap': false, @@ -2505,6 +2509,7 @@ const MaplibreViewer = ({ filter={['==', ['get', 'corr_type'], 'contradiction']} minzoom={2} layout={{ + 'text-font': ['Noto Sans Bold'], 'text-field': ['concat', '? CONTRADICTION\n', ['get', 'context'], ' · ', ['get', 'drivers']], 'text-size': ['interpolate', ['linear'], ['zoom'], 2, 7, 5, 9, 8, 11], 'text-allow-overlap': false, @@ -2557,6 +2562,7 @@ const MaplibreViewer = ({ filter={['==', ['get', 'corr_type'], 'analysis_zone']} minzoom={2} layout={{ + 'text-font': ['Noto Sans Bold'], 'text-field': ['concat', ['get', 'zone_title'], '\n', ['get', 'drivers']], 'text-size': ['interpolate', ['linear'], ['zoom'], 2, 7, 5, 9, 8, 11], 'text-allow-overlap': false, @@ -2599,6 +2605,7 @@ const MaplibreViewer = ({ type="symbol" filter={['has', 'point_count']} layout={{ + 'text-font': ['Noto Sans Bold'], 'text-field': '{point_count_abbreviated}', 'text-size': 12, 'text-allow-overlap': true,