fix(input): no double-click follow or zoom on the map

The globe viewer's own double-click tracked a picked entity with a
position or zoomed to one without. Layers moving onto the draw port had it
re-created one by one (data/stockFollow.js); following is a click in GEV,
so the viewer's handler is removed where the viewer is made and every
re-creation goes: earthquakes, cyclones, air quality, news, perimeters,
drone airspace, ghost maps, places, radio, cables, CCTV, ALPR, launches,
bikeshare, Local ADS-B, installations, directions, trails, data packs,
annotations, the library's view and local GeoJSON. The Cockpit's own
double-click and the draw tool's finishing double-click stay.
This commit is contained in:
Sameh Khamis committed 2026-11-14 09:10:14 -08:00
1 parent bb2d22dbce
commit b86014244d
69 files changed
+94 -2797

No files matched your search

+1 -19
View File
@@ -1,7 +1,6 @@
import { hitTestWorldOverlay } from '../../overlays/worldOverlay.js';
import { VESSEL_OVERLAY_SOURCE_ID } from '../../data/vesselLabels.js';
import { inputFor } from '../../input/dispatcher.js';
import { followOnDoubleClick } from '../../data/stockFollow.js';
import {
registerPickOwner,
unregisterPickOwner,
@@ -231,20 +230,7 @@ export function createCyclonesLayer({
if (id) layer.setParams({ stormId: id });
else if (!event.topHit) layer.setParams({ clear: true });
});
// A double-click follows a storm's point or zooms to its track or cone,
// as the default renderer did for their entities.
const follow = followOnDoubleClick({
viewer,
inputFor,
name: 'weather-cyclones',
enabled: () => enabled && !destroyed && selectionOwner === owner,
targetFor: (hit) => rendering?.followTargetFor?.(hit) ?? null,
});
owner.follow = follow;
owner.unsubscribe = () => {
unsubscribe();
follow.destroy();
};
owner.unsubscribe = unsubscribe;
}
function removeSelection() {
const owner = selectionOwner;
@@ -313,7 +299,6 @@ export function createCyclonesLayer({
if (next.unavailable) {
// An expired advisory must not remain presented as current hazard context.
rendering.clear();
selectionOwner?.follow?.stop();
snapshot = next;
selectedId = null;
++navigationGeneration;
@@ -333,8 +318,6 @@ export function createCyclonesLayer({
return false;
snapshot = next;
error = null;
// A storm point no longer in the advisory takes its follow with it.
selectionOwner?.follow?.retain((key) => rendering.drawsFollowKey(key));
if (!snapshot.storms.some((storm) => storm.id === selectedId))
select(
selectionIntent === 'cleared'
@@ -352,7 +335,6 @@ export function createCyclonesLayer({
error = cause?.message || ADVISORIES_UNAVAILABLE;
// Failed acquisition has no bounded last-good age guarantee at this layer.
rendering?.clear();
selectionOwner?.follow?.stop();
snapshot = null;
selectedId = null;
++navigationGeneration;
+2 -44
View File
@@ -63,10 +63,7 @@ export function createCycloneRendering({ viewer, overlayHost }) {
let centers = new Map(),
forecasts = [],
spheres = new Map(),
itemStorms = new Map(),
// Per drawn item, where a double-click follows it (a point) or what it
// zooms to (a track, cone or outline).
itemPlaces = new Map();
itemStorms = new Map();
let counts = { storms: 0, tracks: 0, cones: 0, forecastPoints: 0 };
let itemCount = 0;
@@ -102,8 +99,7 @@ export function createCycloneRendering({ viewer, overlayHost }) {
if (destroyed) return false;
const nextCenters = new Map(),
nextSpheres = new Map(),
nextItemStorms = new Map(),
nextItemPlaces = new Map();
nextItemStorms = new Map();
const nextForecasts = [],
nextLines = [],
nextCones = [],
@@ -126,7 +122,6 @@ export function createCycloneRendering({ viewer, overlayHost }) {
const center = ecef(at);
const extent = [center];
own(`cyclone:${storm.id}:center`);
nextItemPlaces.set(`cyclone:${storm.id}:center`, { at: center });
nextCenters.set(storm.id, { id: storm.id, at });
const label = {
id: storm.id,
@@ -147,9 +142,6 @@ export function createCycloneRendering({ viewer, overlayHost }) {
// Lines take ECEF (draw.d.ts `LineItem`).
const positions = line.map((c) => ecef(pair(c)));
extent.push(...positions);
nextItemPlaces.set(`cyclone:${storm.id}:track:${index}`, {
extent: positions,
});
nextLines.push({
id: own(`cyclone:${storm.id}:track:${index}`),
positions,
@@ -169,9 +161,6 @@ export function createCycloneRendering({ viewer, overlayHost }) {
const all = rings.map((ring) => ring.map(pair));
const ecefRings = all.map((ring) => ring.map(ecef));
extent.push(...ecefRings[0]);
nextItemPlaces.set(`cyclone:${storm.id}:cone:${index}`, {
extent: ecefRings[0],
});
nextCones.push({
id: own(`cyclone:${storm.id}:cone:${index}`),
geometry: { kind: 'polygon', rings: all },
@@ -179,10 +168,6 @@ export function createCycloneRendering({ viewer, overlayHost }) {
height: 'clampGround',
});
ecefRings.forEach((ring, ringIndex) => {
nextItemPlaces.set(
`cyclone:${storm.id}:cone:${index}:outline:${ringIndex}`,
{ extent: ring },
);
nextLines.push({
id: own(
`cyclone:${storm.id}:cone:${index}:outline:${ringIndex}`,
@@ -203,9 +188,6 @@ export function createCycloneRendering({ viewer, overlayHost }) {
const pos = lonLat(point.position);
const p = ecef(pos);
extent.push(p);
nextItemPlaces.set(`cyclone:${storm.id}:forecast:${index}`, {
at: p,
});
nextForecasts.push({
id: own(`cyclone:${storm.id}:forecast:${index}`),
pos,
@@ -230,7 +212,6 @@ export function createCycloneRendering({ viewer, overlayHost }) {
forecasts = nextForecasts;
spheres = nextSpheres;
itemStorms = nextItemStorms;
itemPlaces = nextItemPlaces;
counts = nextCounts;
itemCount = nextItemStorms.size;
committed = true;
@@ -254,28 +235,6 @@ export function createCycloneRendering({ viewer, overlayHost }) {
if (!setIds.has(hit.set)) return null;
return itemStorms.get(hit.id) ?? null;
},
/**
* What a double-click on a hit follows or zooms to (`followOnDoubleClick`
* in `data/stockFollow.js`), as the default renderer did for the
* advisory's entities: a center or forecast point is followed, a track,
* cone or outline zoomed to.
*/
followTargetFor(hit) {
if (!committed || !hit || hit.surface || !setIds.has(hit.set))
return null;
const place = itemPlaces.get(hit.id);
if (!place) return null;
if (place.extent) return { zoomTo: sphereFromPoints(place.extent) };
const at = place.at;
return { key: `${hit.set}:${hit.id}`, position: () => ({ ...at }) };
},
/** Whether the item a follow's key (`<set>:<item>`) names is drawn now. */
drawsFollowKey(key) {
for (const set of setIds)
if (key.startsWith(`${set}:`))
return committed && itemPlaces.has(key.slice(set.length + 1));
return false;
},
getFocusSphere(id) {
return spheres.get(id) || null;
},
@@ -291,7 +250,6 @@ export function createCycloneRendering({ viewer, overlayHost }) {
forecasts = [];
spheres = new Map();
itemStorms = new Map();
itemPlaces = new Map();
itemCount = 0;
selected = null;
counts = { storms: 0, tracks: 0, cones: 0, forecastPoints: 0 };
-40
View File
@@ -451,43 +451,3 @@ test('labels publish committed anchors to the shared overlay and follow selectio
h.rendering.destroy();
assert.equal(h.overlay.calls.at(-1), afterClear[1]);
});
test('a double-click follows a storm’s points and zooms to its tracks and cones, as their entities did', async () => {
const h = harness();
await h.rendering.setSnapshot({ storms: [storm()] });
for (const id of h.sets.points.items.keys()) {
const target = h.rendering.followTargetFor(h.hit('points', id));
assert.ok(target?.position, `${id} is followed`);
assert.equal(target.key, `${h.sets.points.spec.id}:${id}`);
}
const center = h.rendering
.followTargetFor(h.hit('points', 'cyclone:ep152026:center'))
.position();
const want = fromDegrees(179, 15, 0);
assert.ok(
Math.hypot(center.x - want.x, center.y - want.y, center.z - want.z) < 1e-6,
);
for (const kind of ['lines', 'cones'])
for (const id of h.sets[kind].items.keys()) {
const target = h.rendering.followTargetFor(h.hit(kind, id));
assert.ok(target?.zoomTo?.radius > 0, `${id} is zoomed to`);
}
assert.equal(
h.rendering.followTargetFor({
set: 'other:points',
id: 'cyclone:ep152026:center',
surface: false,
}),
null,
);
const key = `${h.sets.points.spec.id}:cyclone:ep152026:center`;
assert.equal(h.rendering.drawsFollowKey(key), true);
assert.equal(h.rendering.drawsFollowKey(`other:points:x`), false);
h.rendering.clear();
assert.equal(h.rendering.drawsFollowKey(key), false, 'cleared: not drawn');
assert.equal(
h.rendering.followTargetFor(h.hit('points', 'cyclone:ep152026:center')),
null,
);
h.rendering.destroy();
});