fix(picking): arbitrate card clicks over passive and background shapes

Flight trails register their ids so every layer reads a trail click as a
no-op, and the directions route claims its line and markers though it acts
only on its maneuver steps. The quake card and magnitude labels yielded to
any registered owner, so over a trail or a route they did nothing. Pick
owners can now name the picks they never act on (registerPickOwner(...,
{ passive })); isActedOnByOtherLayer leaves those out while
isOwnedByOtherLayer is unchanged, so they are still not empty space.

Submarine cables and rocket launches acted on any scene pick, so a card or
label over a cable or a launch marker made both layers act. Both now stand
aside when a world-overlay entry is under the click, as drone airspace and
fire perimeters do through the top-entry check. Each of these layers, and
the quake discs, registers its shapes with registerCardBackground. CCTV
asks isCardBackground instead of matching other layers' set and id formats,
so a live top CCTV card acts once over any of them, while unknown
identified objects and registered owners still block it.
This commit is contained in:
manjunath22466 committed 2026-11-17 01:33:06 +05:30
1 parent 836daf82b3
commit 133d022b29
23 files changed
+825 -78

No files matched your search

+11 -10
View File
@@ -215,14 +215,23 @@ export function createFirePerimetersLayer({
// so claiming these large ground polygons would make FIRMS/vessel/CCTV
// cards inert anywhere over a perimeter. Unowned, our picks read as
// "empty space" to siblings — the pre-existing behavior for the globe.
// Our shapes stand aside for a card painted over them (below), so that
// card's layer may act on the click; without a hit-test they cannot.
if (overlayHost?.hitTest)
picking?.registerCardBackground?.(
layer.id,
(hit) => pickedIncidentId(hit) !== null,
);
_clickSubscription = inputFor(_viewer).onClick((event) => {
// A click on the incident card itself opens its InciWeb page (when the
// incident has one) and never disturbs the selection.
const cardHit = overlayHost.hitTest?.(
event.screenPosition?.x,
event.screenPosition?.y,
{ sourceId: PERIMETER_OVERLAY_SOURCE_ID },
);
// Only the top painted card owns the click; this area's shapes are
// background when another layer has painted a card or label over them.
if (cardHit && cardHit.sourceId !== PERIMETER_OVERLAY_SOURCE_ID) return;
if (cardHit && cardHit.entryId === _selectedCardId) {
if (_selectedLink && openExternal) openExternal(_selectedLink);
return;
@@ -230,15 +239,6 @@ export function createFirePerimetersLayer({
const picked = event.topHit;
const incidentId = picked ? pickedIncidentId(event.drawHit) : null;
if (incidentId) {
// Another layer's card or label painted over the perimeter (a
// quake's card or magnitude label, a fire card) is that layer's
// click: under it the perimeter is background, so it stays as is.
const top = overlayHost.hitTest?.(
event.screenPosition?.x,
event.screenPosition?.y,
{},
);
if (top && top.sourceId !== PERIMETER_OVERLAY_SOURCE_ID) return;
abortLinkVerification();
_selectedId = incidentId;
publishSelectedCard();
@@ -261,6 +261,7 @@ export function createFirePerimetersLayer({
function removeClickHandler() {
_clickSubscription?.();
_clickSubscription = null;
picking?.unregisterCardBackground?.(layer.id);
}
function clearSelection() {
+37 -4
View File
@@ -27,6 +27,7 @@ function harness(
) {
const overlay = { entries: new Map(), visible: null };
const owners = new Map();
const backgrounds = new Map();
const opened = [];
const viewer = { scene: { pick } };
const { draw } = bindFakeDraw(viewer);
@@ -58,6 +59,9 @@ function harness(
String(pickedId).startsWith('other-layer:'),
registerPickOwner: (layerId, predicate) => owners.set(layerId, predicate),
unregisterPickOwner: (layerId) => owners.delete(layerId),
registerCardBackground: (layerId, predicate) =>
backgrounds.set(layerId, predicate),
unregisterCardBackground: (layerId) => backgrounds.delete(layerId),
},
inciwebSource: inciwebIndex
? { getIndex: async () => inciwebIndex }
@@ -77,6 +81,7 @@ function harness(
overlay,
clicks,
owners,
backgrounds,
opened,
};
}
@@ -316,12 +321,16 @@ test('a matched incident card carries the InciWeb line and click-through', async
},
];
let cardHitResult = null;
let foreignOnTop = false;
const h = harness(
{ getSnapshot: async () => [{ ...row, name: 'Fixture' }] },
{
pick: () => null,
inciwebIndex,
cardHit: () => cardHitResult,
cardHit: (_x, _y, options) =>
foreignOnTop && !options?.sourceId
? { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' }
: cardHitResult,
},
);
await h.layer.update(h.viewer);
@@ -336,9 +345,15 @@ test('a matched incident card carries the InciWeb line and click-through', async
const entries = h.overlay.entries.get('fire-perimeters');
assert.equal(entries[0].details.at(-1), 'InciWeb ↗ · click card to open');
// Clicking the card itself opens the InciWeb page.
cardHitResult = { entryId: entries[0].id };
// A selected card covered by a quake card cannot open its hidden link.
cardHitResult = { sourceId: 'fire-perimeters', entryId: entries[0].id };
h.viewer.scene.pick = () => null;
foreignOnTop = true;
h.clicks.handler({ position: { x: 12, y: 12 } });
assert.deepEqual(h.opened, []);
assert.equal(h.overlay.entries.get('fire-perimeters')[0].id, entries[0].id);
// Removing the foreground card makes the incident card actionable again.
foreignOnTop = false;
h.clicks.handler({ position: { x: 12, y: 12 } });
assert.deepEqual(h.opened, ['https://inciweb.wildfire.gov/node/329300']);
assert.equal(
@@ -365,7 +380,7 @@ test('an unmatched incident renders no InciWeb line and card clicks stay inert',
entries[0].details.some((line) => line.includes('InciWeb')),
false,
);
cardHitResult = { entryId: entries[0].id };
cardHitResult = { sourceId: 'fire-perimeters', entryId: entries[0].id };
h.viewer.scene.pick = () => null;
h.clicks.handler({ position: { x: 12, y: 12 } });
assert.deepEqual(h.opened, []);
@@ -679,3 +694,21 @@ test('a failed refresh after a stale snapshot reads as the failure, not stale',
assert.equal(h.layer.getStats().stale, false);
assert.equal(h.layer.getStats().error, 'WFIGS HTTP 502');
});
// A card painted over the area may act there (a live CCTV card): the layer
// names its own drawn shapes, and only while it takes clicks.
test('enabled, the perimeter shapes register as card background', async () => {
const h = harness({ getSnapshot: async () => [row] });
await h.layer.update(h.viewer);
const isBackground = h.backgrounds.get('fire-perimeters');
const own = {
set: h.fills().spec.id,
id: 'fire-perimeter:2026-NMGNF-000123:0',
surface: false,
};
assert.equal(isBackground(own), true);
assert.equal(isBackground({ ...own, set: 'other:1:fills' }), false);
assert.equal(isBackground({ ...own, id: 'other-layer:x' }), false);
h.layer.disable(h.viewer);
assert.equal(h.backgrounds.has('fire-perimeters'), false);
});