From 4c62435910a191403dc7368ed9d31b5cbafd759e Mon Sep 17 00:00:00 2001 From: German Khokhlov Date: Fri, 6 Nov 2026 22:01:39 +0400 Subject: [PATCH] Drop the duplicate callout test and the card id cache --- src/data/aisLiveVessels.test.mjs | 1 - src/data/detection.js | 1 - src/data/detectionHost.test.mjs | 65 +++----------------------------- src/layers/vessels/cards.js | 8 ---- src/layers/vessels/records.js | 2 - 5 files changed, 5 insertions(+), 72 deletions(-) diff --git a/src/data/aisLiveVessels.test.mjs b/src/data/aisLiveVessels.test.mjs index e1c2fcc5a..edb3505f2 100644 --- a/src/data/aisLiveVessels.test.mjs +++ b/src/data/aisLiveVessels.test.mjs @@ -1821,7 +1821,6 @@ test('detection objects name the vessel card their callout gives way to', () => 'vessel:unkeyed:NO MMSI:37.80000:-122.40000', 'the same identity the vessel card is published under', ); - assert.equal(keyed.overlayEntryId, 'vessel:200', 'cached on the record for later frames'); } finally { _setVesselStateForTest({ enabled: false }); } diff --git a/src/data/detection.js b/src/data/detection.js index b4dc29522..0ec9e9ba2 100644 --- a/src/data/detection.js +++ b/src/data/detection.js @@ -1114,7 +1114,6 @@ function _stashCallout(entry, acquireFade, keyhole) { row.alpha = alpha; row.cardSourceId = candidate.cardSourceId; row.cardEntryId = candidate.cardEntryId; - row.paintAlpha = alpha; _calloutCount++; } diff --git a/src/data/detectionHost.test.mjs b/src/data/detectionHost.test.mjs index f479869f9..db01ed18a 100644 --- a/src/data/detectionHost.test.mjs +++ b/src/data/detectionHost.test.mjs @@ -19,12 +19,10 @@ import { suspendDetection, } from './detection.js'; import { - clearOverlaySource, destroyWorldOverlay, getOverlayPaintRect, initWorldOverlay, setOverlayEntries, - setOverlaySourceVisible, } from '../overlays/worldOverlay.js'; import { applyVesselOverlayPolicy } from './vesselLabels.js'; import { @@ -588,64 +586,6 @@ test('every style paints its OWN plate token through the production callout path } }); -test('a callout gives way to its contact\'s own card only while that card paints', () => { - // The callout shows through its card's plate. The host paints only some - // published cards (budget, collisions, UI chrome); an unpainted one keeps it. - const env = installEnvironment({ width: 900, height: 600, dpr: 1 }); - try { - const ships = [ - { x: -0.3, sourceId: 'carded', id: 'SHIP-CARDED', card: 'vessel:carded' }, - { x: 0.3, sourceId: 'dropped', id: 'SHIP-DROPPED', card: 'vessel:dropped' }, - ].map(({ x, sourceId, id, card }) => ({ - position: new Cesium.Cartesian3(x, 0, 6_356_752), - sourceId, - id, - metric: '6 kn', - type: 'SEA', - cardSourceId: card === 'vessel:carded' ? 'vessel-cards' : 'dropped-cards', - cardEntryId: card, - })); - initWorldOverlay(env.viewer); - initDetection(env.viewer, [{ id: 'ais-live-vessels', getDetectableObjects: () => ships }], () => {}); - const card = (id, title, x) => ({ - id, - position: new Cesium.Cartesian3(x, 0, 6_356_752), - variant: 'label', - title, - selected: true, - protected: true, - horizonCull: false, - edgeFade: 'none', - }); - setOverlayEntries('vessel-cards', [card('vessel:carded', 'CARD-CARDED', -0.3)]); - // Published, but the host does not paint it this frame. - setOverlayEntries('dropped-cards', [card('vessel:dropped', 'CARD-DROPPED', 0.3)]); - setOverlaySourceVisible('dropped-cards', false); - setMode('DENSE'); - settleFrame(env); - env.ctx.calls.length = 0; - settleFrame(env); - - const painted = (text) => env.ctx.calls.some(([name, value]) => name === 'fillText' && value === text); - assert.ok(painted('CARD-CARDED'), 'the fixture card reached the frame'); - assert.ok(!painted('CARD-DROPPED'), 'the hidden source paints no card'); - assert.ok(!painted('SHIP-CARDED'), 'no callout under the painted card'); - assert.ok(painted('SHIP-DROPPED'), 'the contact whose card did not paint keeps its callout'); - assert.equal(getDetectionDiagnostics().calloutRects.length, 1, - 'only the callout that painted is reported'); - - // The card leaves the host: the callout comes back on the next frame. - clearOverlaySource('vessel-cards'); - env.ctx.calls.length = 0; - settleFrame(env); - assert.ok(painted('SHIP-CARDED'), 'the callout returns once its card stops painting'); - } finally { - destroyDetection(); - destroyWorldOverlay(); - env.cleanup(); - } -}); - /** A vessel detection contact that names its ambient card, like the AIS layer does. */ function shipWithCard(mmsi, position) { return { @@ -776,6 +716,11 @@ test('a vessel whose ambient card loses the collision keeps its callout', () => carded ? `${ship.id} draws no callout under its card` : `${ship.id} keeps its callout`, ); } + assert.equal( + getDetectionDiagnostics().calloutRects.length, + ships.length - winners.length, + 'only the callouts that painted are reported', + ); } finally { destroyDetection(); destroyWorldOverlay(); diff --git a/src/layers/vessels/cards.js b/src/layers/vessels/cards.js index 2563bf420..bcf3459f1 100644 --- a/src/layers/vessels/cards.js +++ b/src/layers/vessels/cards.js @@ -117,14 +117,6 @@ export function createCards({ /** Stable overlay identity for MMSI-keyed and source-retained unkeyed rows. */ function vesselOverlayEntryId(record) { - // Cached on the record: detection asks for it every frame for every vessel. - if (record?.overlayEntryId) return record.overlayEntryId; - const id = composeVesselOverlayEntryId(record); - if (record) record.overlayEntryId = id; - return id; - } - - function composeVesselOverlayEntryId(record) { const mmsi = String(record?.mmsi || '').trim(); if (mmsi) return `vessel:${mmsi}`; const name = String(record?.name || 'VESSEL').trim() || 'VESSEL'; diff --git a/src/layers/vessels/records.js b/src/layers/vessels/records.js index f6f581784..ad6d85cbd 100644 --- a/src/layers/vessels/records.js +++ b/src/layers/vessels/records.js @@ -23,8 +23,6 @@ export function normalizeVessel(row) { lastPositionUtc: String(row.last_position_UTC || ''), lastPositionEpoch: finiteNumber(row.last_position_epoch), missedRefreshes: 0, - // Cached by `vesselOverlayEntryId`; the fields it reads never change. - overlayEntryId: null, }; }