fix(touch): give each tap to the layer that acts on it

On a coarse pointer the dispatcher can name a contact near the tap instead
of the exact pick. Only flights, military, vessels, radio and Street Level
act on such a contact, so they now register as expanded pick owners, and a
quake card or label yields only to them. A FIRMS fire or CCTV camera reached
only as a nearby contact no longer swallows a quake card, a quake label or
a vessel's own card tap, and FIRMS and CCTV cards yield to a contact whose
layer does act on it.

Radio and Street Level also pick through their own windows. A station or
Street Level item found only there, not as the touch contact, yields to
another layer's card painted over it, and Street Level takes its own touch
contact beyond its narrower window.

Fire, CCTV and vessel cards now act over a passive owner's pick (a flight
trail, the directions route), as the quake card does. The Context panel
leaves a passive route, or a fire or camera reached only as a nearby
contact, to the card painted over it.
This commit is contained in:
manjunath22466 committed 2026-11-17 13:18:32 +05:30
1 parent 4804097ca1
commit 830c980ca6
26 files changed
+1095 -69

No files matched your search

+71 -2
View File
@@ -1012,7 +1012,7 @@ function makeCesiumEvent() {
};
}
function installWireHarness(picked, stateOverrides = {}) {
function installWireHarness(picked, stateOverrides = {}, sceneExtras = {}) {
const hadWindow = Object.hasOwn(globalThis, 'window');
const hadDocument = Object.hasOwn(globalThis, 'document');
const priorWindow = globalThis.window;
@@ -1038,7 +1038,7 @@ function installWireHarness(picked, stateOverrides = {}) {
},
};
const viewer = {
scene: { pick: () => picked },
scene: { pick: () => picked, ...sceneExtras },
};
const input = fakeInput(viewer);
// The camera port other layers follow through, with no pose to read; its
@@ -1993,6 +1993,75 @@ test('vessel interaction wire: a sibling-owned pick wins without selection mutat
}
});
// A trail acts for nobody: the vessel's card painted over it still selects,
// and a bare trail pick stays a no-op that keeps the selection.
test('vessel interaction wire: a card over a trail selects; a bare trail is a no-op', () => {
for (const carded of [true, false]) {
const harness = installWireHarness(
{ id: 'gev-trail:fl-a1b2c3:head' },
{ selectedRecord: null },
);
const requests = [];
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
requests.push(event.detail),
);
_setVesselOverlayHostForTest(
hostWithCardHit(carded ? `vessel:${harness.record.mmsi}` : null),
);
try {
harness.handler.click({ position: { x: 10, y: 20 } });
assert.equal(requests.length, carded ? 1 : 0, `card: ${carded}`);
assert.equal(
aisLiveVesselsLayer.getSelectedInfo()?.mmsi ?? null,
carded ? harness.record.mmsi : null,
);
} finally {
_setVesselOverlayHostForTest(null);
harness.cleanup();
}
}
});
// A coarse tap on the vessel's card finds a fire nearby through the shared
// touch contact. The fire layer acts only on exact hits, so the card keeps the
// tap; an exact fire pick under the card still belongs to the fire.
test('vessel interaction wire: a coarse near miss of an exact-only item keeps the card tap', (t) => {
const previous = globalThis.matchMedia;
globalThis.matchMedia = () => ({ matches: true });
t.after(() => {
if (previous) globalThis.matchMedia = previous;
else delete globalThis.matchMedia;
});
const fire = 'fire:near-miss';
registerPickOwner('test-exact-fires', (pickedId) => pickedId === fire);
t.after(() => unregisterPickOwner('test-exact-fires'));
for (const exact of [false, true]) {
const harness = installWireHarness(
exact ? { id: fire } : null,
{ selectedRecord: null },
{ drillPick: () => [{ id: fire }] },
);
const requests = [];
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
requests.push(event.detail),
);
_setVesselOverlayHostForTest(
hostWithCardHit(`vessel:${harness.record.mmsi}`),
);
try {
harness.handler.click({ position: { x: 10, y: 20 } });
assert.equal(requests.length, exact ? 0 : 1, `exact fire: ${exact}`);
assert.equal(
aisLiveVesselsLayer.getSelectedInfo()?.mmsi ?? null,
exact ? null : harness.record.mmsi,
);
} finally {
_setVesselOverlayHostForTest(null);
harness.cleanup();
}
}
});
for (const card of ['live', 'stale', 'absent', 'covered']) {
test(`vessel interaction wire: ${card} foreground card over registered cyclone`, () => {
const id = 'cyclone:fixture:cone:0';