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

-89
View File
@@ -324,92 +324,3 @@ test('features draw as the GeoJSON loader drew them: rhumb edges and their own s
assert.ok(line.positions.length > 40);
await layer.destroy(viewer);
});
test('a double-click follows a dot and zooms to an area, as their entities were; a new view ends the follow', async (t) => {
const point = {
type: 'Feature',
geometry: { type: 'Point', coordinates: [-77.0295, 38.8905] },
properties: { OCC_CLS: 'Government' },
};
const layer = createLibraryViewLayer(entry, {
source: {
loadDataset: async () => ({
features: [polygon, point],
truncated: false,
}),
},
debounceMs: 0,
});
const viewer = { canvas: { clientWidth: 800, clientHeight: 600 } };
const camera = fakeCameraPort();
const follows = [];
const flights = [];
// A getter, defined so: Object.assign would copy its value once.
Object.defineProperty(camera.port, 'followed', {
get: () => follows.at(-1) ?? null,
});
Object.assign(camera.port, {
follow: (target) => follows.push(target),
flyToBounds: (sphere, options) => flights.push({ sphere, options }),
controls: { minDistance: 1, maxDistance: Infinity },
});
let lon = -77.03;
const centre = () => fromDegrees(lon, 38.89, 0);
camera.setPose({
lon,
lat: 38.89,
height: 2000,
position: fromDegrees(lon, 38.89, 2000),
});
let pickAt = () => null;
let dblclick = null;
const { draw, unbind } = bindFakeDraw(viewer, {
camera: camera.port,
query: { pickEllipsoid: centre, pick: (x, y) => pickAt(x, y) },
input: {
onPointer: (type, fn) => {
assert.equal(type, 'dblclick');
dblclick = fn;
return () => (dblclick = null);
},
stockEnabled: (name) => name === 'dblclickFollow',
},
});
t.after(unbind);
await layer.init(viewer);
await layer.enable(viewer);
const live = (role) =>
[...draw.sets.values()].find(
(s) => !s.disposed && s.spec.id.endsWith(role),
);
const at = { position: { x: 1, y: 1 } };
const fills = live(':fills');
pickAt = () => ({ set: fills.spec.id, id: [...fills.items.keys()][0] });
dblclick(at);
assert.equal(flights.length, 1, 'an area is zoomed to');
const dots = live(':dots');
pickAt = () => ({ set: dots.spec.id, id: [...dots.items.keys()][0] });
dblclick(at);
assert.equal(follows.length, 1, 'a dot is followed');
assert.ok(camera.port.followed);
const expected = fromDegrees(-77.0295, 38.8905, 0);
const got = follows[0].position();
assert.ok(
Math.hypot(got.x - expected.x, got.y - expected.y, got.z - expected.z) <
1e-6,
);
// The camera settles elsewhere: the view is drawn anew, which ended a
// follow of an entity it replaced.
lon = -77.2;
camera.setPose({ lon, position: fromDegrees(lon, 38.89, 2000) });
camera.emit('moveEnd');
await new Promise((resolve) => setTimeout(resolve, 5));
assert.equal(camera.port.followed, null);
await layer.disable(viewer);
assert.equal(dblclick, null, 'let go when disabled');
await layer.destroy(viewer);
});