mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Draw the installations layer's named markers through the renderer's ports
The named-site dots are a draw-port point set with horizon culling instead of a raw point collection; their on-screen count tests the ellipsoid horizon and projects through the query port, and they follow the camera port's changed and moveEnd events and the frame port's preRender. Points that only change look (a selection) are restyled in place. Clicks on a dot read the draw hit; the item id is not the bare record id, so sibling layers' pick-owner checks still treat a dot click as nobody's. Code that only asks whether a click hit anything (the CCTV layer) now sees a dot click as a hit, as it already did for the site markers: a draw item's pick always resolves to its id. The named markers leave the Cesium allow-list. The site markers in rendering.js stay entities.
This commit is contained in:
1 parent
e327760074
commit
faded8a418
10 files changed
+377
-115
No files matched your search
@@ -1,55 +1,112 @@
|
||||
import { installationClassLabel, installationTitle } from './classLabel.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import {
|
||||
MILITARY_LABEL_CAP,
|
||||
MILITARY_POINT_CAP,
|
||||
} from '../../data/militaryNames.js';
|
||||
import { LAYER_ID, COLOR_BY_CLASS } from './policy.js';
|
||||
import { fromDegrees } from '../../geo/index.js';
|
||||
import { horizonFrom } from '../../geo/horizon.js';
|
||||
import {
|
||||
cameraOf,
|
||||
drawOf,
|
||||
findFrame,
|
||||
findQuery,
|
||||
} from '../../render/rendererOf.js';
|
||||
import {
|
||||
CAMERA_CHANGED_THRESHOLD,
|
||||
LAYER_ID,
|
||||
COLOR_BY_CLASS,
|
||||
} from './policy.js';
|
||||
import { createInfrastructureOverlayEntry } from '../../data/infrastructureOverlayEntry.js';
|
||||
|
||||
let instances = 0;
|
||||
|
||||
/**
|
||||
* A named marker's point item id. Not the bare record id: the shared pick
|
||||
* registry resolves a draw item's pick to its item id, and a point click has
|
||||
* never been this layer's for sibling layers' owner checks (a tracked
|
||||
* aircraft is released by it, as by a click on empty map). The click handler
|
||||
* reads the record id from the item's `meta`.
|
||||
*/
|
||||
export const namedPointId = (recordId) => `named:${recordId}`;
|
||||
|
||||
const samePlace = (a, b) =>
|
||||
Boolean(a) && a.x === b.x && a.y === b.y && a.z === b.z;
|
||||
|
||||
/** Bounded point markers; the shared overlay owns text projection and decluttering. */
|
||||
export function createNamedMarkers({ state, services, parts, overlayHost }) {
|
||||
const setId = `${LAYER_ID}:${++instances}:names`;
|
||||
let points = null;
|
||||
let entries = [];
|
||||
const markers = new Map();
|
||||
const screen = new Cesium.Cartesian2();
|
||||
const occluder = new Cesium.EllipsoidalOccluder(Cesium.Ellipsoid.WGS84);
|
||||
let shownPoints = 0;
|
||||
/** Where each drawn point item is, by item id. */
|
||||
let drawn = new Map();
|
||||
let ordered = [];
|
||||
const viewMatrix = new Cesium.Matrix4();
|
||||
let lastPose = null;
|
||||
let width = 0,
|
||||
height = 0;
|
||||
let removeChanged = null,
|
||||
removeEnd = null,
|
||||
removeFrame = null;
|
||||
|
||||
function refresh() {
|
||||
/** Whether the eye moved or the canvas resized since the last refresh. */
|
||||
function viewChanged(viewer, pose) {
|
||||
const same = (a, b) => a.x === b.x && a.y === b.y && a.z === b.z;
|
||||
return (
|
||||
!lastPose ||
|
||||
!same(pose.position, lastPose.position) ||
|
||||
!same(pose.direction, lastPose.direction) ||
|
||||
!same(pose.up, lastPose.up) ||
|
||||
width !== viewer.scene.canvas.clientWidth ||
|
||||
height !== viewer.scene.canvas.clientHeight
|
||||
);
|
||||
}
|
||||
|
||||
// Reused projection buffers, grown to the marker count.
|
||||
let worldXyz = new Float64Array(0);
|
||||
let screenXy = new Float32Array(0);
|
||||
|
||||
function refresh(pose = null) {
|
||||
const viewer = state.viewer;
|
||||
if (!state.enabled || !points) return;
|
||||
width = viewer.scene.canvas.clientWidth;
|
||||
height = viewer.scene.canvas.clientHeight;
|
||||
if (viewer.camera.viewMatrix)
|
||||
Cesium.Matrix4.clone(viewer.camera.viewMatrix, viewMatrix);
|
||||
occluder.cameraPosition = viewer.camera.positionWC;
|
||||
shownPoints = 0;
|
||||
pose ??= cameraOf(viewer).pose();
|
||||
lastPose = {
|
||||
position: { ...pose.position },
|
||||
direction: { ...pose.direction },
|
||||
up: { ...pose.up },
|
||||
};
|
||||
// The ellipsoid horizon from the eye, the test the draw set's own
|
||||
// horizon cull makes, so the count agrees with what is drawn.
|
||||
const horizon = horizonFrom(pose.position);
|
||||
if (worldXyz.length < ordered.length * 3) {
|
||||
worldXyz = new Float64Array(ordered.length * 3);
|
||||
screenXy = new Float32Array(ordered.length * 2);
|
||||
}
|
||||
let shown = 0;
|
||||
for (let index = 0; index < ordered.length; index++) {
|
||||
const marker = ordered[index];
|
||||
const point = marker.point;
|
||||
point.show = marker.named && occluder.isPointVisible(point.position);
|
||||
point.show = marker.named && horizon.isPointVisible(point.position);
|
||||
if (!point.show) continue;
|
||||
const projected = Cesium.SceneTransforms.worldToWindowCoordinates(
|
||||
viewer.scene,
|
||||
point.position,
|
||||
screen,
|
||||
);
|
||||
if (
|
||||
projected &&
|
||||
screen.x >= 0 &&
|
||||
screen.y >= 0 &&
|
||||
screen.x < width &&
|
||||
screen.y < height
|
||||
)
|
||||
shownPoints++;
|
||||
worldXyz[shown * 3] = point.position.x;
|
||||
worldXyz[shown * 3 + 1] = point.position.y;
|
||||
worldXyz[shown * 3 + 2] = point.position.z;
|
||||
shown++;
|
||||
}
|
||||
shownPoints = 0;
|
||||
const query = findQuery(viewer);
|
||||
if (!query || !shown) return;
|
||||
query.projectMany(
|
||||
worldXyz.subarray(0, shown * 3),
|
||||
screenXy.subarray(0, shown * 2),
|
||||
);
|
||||
for (let i = 0; i < shown; i++) {
|
||||
const x = screenXy[i * 2];
|
||||
const y = screenXy[i * 2 + 1];
|
||||
// NaN, behind the eye, fails every test.
|
||||
if (x >= 0 && y >= 0 && x < width && y < height) shownPoints++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,20 +128,20 @@ export function createNamedMarkers({ state, services, parts, overlayHost }) {
|
||||
}
|
||||
function frame() {
|
||||
const viewer = state.viewer;
|
||||
if (
|
||||
viewer?.camera.viewMatrix &&
|
||||
(!Cesium.Matrix4.equals(viewMatrix, viewer.camera.viewMatrix) ||
|
||||
width !== viewer.scene.canvas.clientWidth ||
|
||||
height !== viewer.scene.canvas.clientHeight)
|
||||
)
|
||||
refresh();
|
||||
if (!viewer || !points) return;
|
||||
const pose = cameraOf(viewer).pose();
|
||||
if (viewChanged(viewer, pose)) refresh(pose);
|
||||
}
|
||||
function enable() {
|
||||
const viewer = state.viewer;
|
||||
if (!viewer || removeChanged || removeEnd || removeFrame) return;
|
||||
removeChanged = viewer.camera.changed?.addEventListener(cameraChanged);
|
||||
removeEnd = viewer.camera.moveEnd?.addEventListener(cameraChanged);
|
||||
removeFrame = viewer.scene.preRender?.addEventListener(frame);
|
||||
const camera = cameraOf(viewer);
|
||||
// The sensitivity this layer claims for raw camera listeners while on.
|
||||
removeChanged = camera.on('changed', cameraChanged, {
|
||||
threshold: CAMERA_CHANGED_THRESHOLD,
|
||||
});
|
||||
removeEnd = camera.on('moveEnd', cameraChanged);
|
||||
removeFrame = findFrame(viewer)?.on('preRender', frame) ?? null;
|
||||
if (points) points.show = true;
|
||||
publishLabels();
|
||||
overlayHost.setVisible(LAYER_ID, true);
|
||||
@@ -101,14 +158,25 @@ export function createNamedMarkers({ state, services, parts, overlayHost }) {
|
||||
shownPoints = 0;
|
||||
}
|
||||
|
||||
/** The point item a marker draws. */
|
||||
function pointItem(marker, record) {
|
||||
return {
|
||||
id: namedPointId(marker.recordId),
|
||||
pos: marker.point.position,
|
||||
pixelSize: 7,
|
||||
color: parts.model.colorFor(record),
|
||||
outlineColor: [0, 0, 0, 1],
|
||||
outlineWidth: 1,
|
||||
disableDepthTest: Infinity,
|
||||
show: marker.named,
|
||||
meta: { installationId: marker.recordId },
|
||||
};
|
||||
}
|
||||
|
||||
function sync(records) {
|
||||
const viewer = state.viewer;
|
||||
if (!viewer?.scene?.primitives) return;
|
||||
if (!points) {
|
||||
points = viewer.scene.primitives.add(
|
||||
new Cesium.PointPrimitiveCollection(),
|
||||
);
|
||||
}
|
||||
if (!viewer?.scene) return;
|
||||
points ??= drawOf(viewer).points({ id: setId, horizonCull: true });
|
||||
points.show = state.enabled;
|
||||
const named = records
|
||||
.filter((r) => r.namedArea || r.id === state.selectedId)
|
||||
@@ -132,15 +200,12 @@ export function createNamedMarkers({ state, services, parts, overlayHost }) {
|
||||
marker.entry.id = record.id;
|
||||
markers.set(record.id, marker);
|
||||
}
|
||||
for (const [id, marker] of markers)
|
||||
if (!keep.has(id)) {
|
||||
points.remove(marker.point);
|
||||
markers.delete(id);
|
||||
}
|
||||
for (const id of markers.keys()) if (!keep.has(id)) markers.delete(id);
|
||||
ordered = [];
|
||||
entries = [];
|
||||
const items = [];
|
||||
for (const record of named) {
|
||||
const position = Cesium.Cartesian3.fromDegrees(
|
||||
const position = fromDegrees(
|
||||
record.longitude,
|
||||
record.latitude,
|
||||
record.pointOnly
|
||||
@@ -151,17 +216,9 @@ export function createNamedMarkers({ state, services, parts, overlayHost }) {
|
||||
if (!marker) {
|
||||
marker = {
|
||||
recordId: record.id,
|
||||
point: points.add({
|
||||
// The app's own pick payload. An object, not the bare record id, so the
|
||||
// shared pick registry keeps treating a point click as it always has.
|
||||
id: { installationId: record.id },
|
||||
position,
|
||||
pixelSize: 7,
|
||||
color: new Cesium.Color(...parts.model.colorFor(record)),
|
||||
outlineColor: Cesium.Color.BLACK,
|
||||
outlineWidth: 1,
|
||||
disableDepthTestDistance: Infinity,
|
||||
}),
|
||||
// What `visit` hands out: the marker's id, position and whether
|
||||
// it is on this side of the horizon.
|
||||
point: { id: { installationId: record.id }, position, show: false },
|
||||
entry: createInfrastructureOverlayEntry({
|
||||
id: record.id,
|
||||
source: LAYER_ID,
|
||||
@@ -175,7 +232,7 @@ export function createNamedMarkers({ state, services, parts, overlayHost }) {
|
||||
} else {
|
||||
marker.point.position = position;
|
||||
}
|
||||
marker.named = record.namedArea;
|
||||
marker.named = Boolean(record.namedArea);
|
||||
marker.entry.variant =
|
||||
record.id === state.selectedId ? 'selected' : 'card';
|
||||
marker.entry.selected = record.id === state.selectedId;
|
||||
@@ -190,13 +247,25 @@ export function createNamedMarkers({ state, services, parts, overlayHost }) {
|
||||
marker.entry.priority = record.areaM2 || 0;
|
||||
entries.push(marker.entry);
|
||||
ordered.push(marker);
|
||||
items.push(pointItem(marker, record));
|
||||
}
|
||||
// Restyled points that keep their ids and places change in place; any
|
||||
// other change draws the set anew.
|
||||
if (
|
||||
items.length === drawn.size &&
|
||||
items.every((item) => samePlace(drawn.get(item.id), item.pos))
|
||||
)
|
||||
points.upsert(items);
|
||||
else points.set(items);
|
||||
drawn = new Map(items.map((item) => [item.id, { ...item.pos }]));
|
||||
if (state.enabled) publishLabels();
|
||||
refresh();
|
||||
services.render.governorRequestRender('installation-names');
|
||||
}
|
||||
return {
|
||||
sync,
|
||||
/** The draw set's id, for matching its click hits. */
|
||||
setId,
|
||||
visit(visitor) {
|
||||
for (let i = 0; i < ordered.length; i++) {
|
||||
const marker = ordered[i];
|
||||
@@ -217,8 +286,9 @@ export function createNamedMarkers({ state, services, parts, overlayHost }) {
|
||||
destroy() {
|
||||
hide();
|
||||
ordered = [];
|
||||
if (points) state.viewer?.scene.primitives.remove(points);
|
||||
points?.dispose();
|
||||
points = null;
|
||||
drawn = new Map();
|
||||
entries = [];
|
||||
markers.clear();
|
||||
},
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as C from 'cesium';
|
||||
import { createNamedMarkers } from './namedMarkers.js';
|
||||
import { createNamedMarkers, namedPointId } from './namedMarkers.js';
|
||||
import { createLifecycle } from './lifecycle.js';
|
||||
import { bindFakeCesiumCamera } from '../../testSupport/fakeCameraPort.mjs';
|
||||
import { fakeDrawPort } from '../../testSupport/fakeDrawPort.mjs';
|
||||
import { fakeSceneFrame, fakeSceneQuery } from '../../testSupport/fakeCesiumScene.mjs';
|
||||
import { createLocalInfrastructureOverlayEntry } from '../../data/localGeojsonCore.js';
|
||||
|
||||
function setup(t) {
|
||||
@@ -17,11 +19,11 @@ function setup(t) {
|
||||
setVisible(_id, value) { visible = value; },
|
||||
};
|
||||
let x = -100;
|
||||
const projections = new Set();
|
||||
t.mock.method(C.SceneTransforms, 'worldToWindowCoordinates', (_scene, _point, scratch) => { projections.add(scratch); scratch.x = x; scratch.y = 300; return scratch; });
|
||||
const camera = { changed: new C.Event(), moveEnd: new C.Event(), positionWC: C.Cartesian3.fromDegrees(0, 0, 1e6), viewMatrix: C.Matrix4.clone(C.Matrix4.IDENTITY) };
|
||||
t.mock.method(C.SceneTransforms, 'worldToWindowCoordinates', () => new C.Cartesian2(x, 300));
|
||||
const camera = { changed: new C.Event(), moveEnd: new C.Event(), positionWC: C.Cartesian3.fromDegrees(0, 0, 1e6), directionWC: new C.Cartesian3(0, 0, -1) };
|
||||
const state = { viewer: { camera, dataSources: { add() {}, remove() {} }, scene: { canvas: { clientWidth: 1280, clientHeight: 800 }, preRender: new C.Event(), primitives: { add: (p) => p, remove() {} } } }, enabled: true, contextAnchor: { latitude: 0, longitude: 0 } };
|
||||
bindFakeCesiumCamera(state.viewer);
|
||||
const draw = fakeDrawPort();
|
||||
bindFakeCesiumCamera(state.viewer, { draw, query: fakeSceneQuery(state.viewer), frame: fakeSceneFrame(state.viewer) });
|
||||
const services = { render: { governorRequestRender() {} }, picking: { registerPickOwner() {}, unregisterPickOwner() {} }, context: { clearSelectedEntityContextForLayer() {} } };
|
||||
let loads = 0;
|
||||
const parts = { model: { colorFor: () => [1, 165 / 255, 0, 1] }, rendering: { attach() { state.dataSource = { show: false }; }, detach() {}, installationSurfaceHeightM: () => 0, clearRendered() {} }, viewport: { scheduleLoad: () => loads++, clearUnavailableRetry() {} }, selection: { installInteraction() {} }, ingestion: { setInstallationStatus() {} } };
|
||||
@@ -30,7 +32,8 @@ function setup(t) {
|
||||
const lifecycle = createLifecycle(ctx).methods;
|
||||
lifecycle.init(state.viewer); lifecycle.enable();
|
||||
const records = [1, 2].map((n) => ({ id: `osm:military:w${n}`, name: `Site ${n}`, namedArea: true, areaM2: 100 / n, latitude: 0, longitude: 0, pointOnly: true }));
|
||||
return { state, camera, get labels() { return labels; }, get options() { return options; }, get visible() { return visible; }, projections, records, markers: parts.namedMarkers, lifecycle, setX: (value) => { x = value; }, publications: () => publications, loads: () => loads };
|
||||
const points = () => [...draw.sets.values()].find((set) => set.kind === 'points' && !set.disposed);
|
||||
return { state, camera, draw, points, get labels() { return labels; }, get options() { return options; }, get visible() { return visible; }, records, markers: parts.namedMarkers, lifecycle, setX: (value) => { x = value; }, publications: () => publications, loads: () => loads };
|
||||
}
|
||||
|
||||
test('Contacts camera motion reprojects and declutters existing labels without source loads or primitive replacement', (t) => {
|
||||
@@ -45,10 +48,14 @@ test('Contacts camera motion reprojects and declutters existing labels without s
|
||||
assert.equal(h.visible, true);
|
||||
assert.equal(h.loads(), 0);
|
||||
assert.equal(h.publications(), 3);
|
||||
assert.equal(h.projections.size, 1);
|
||||
h.setX(1400); h.camera.viewMatrix[12] = 1; h.state.viewer.scene.preRender.raiseEvent();
|
||||
const items = [...h.points().items.values()];
|
||||
assert.deepEqual(items.map((item) => [item.id, item.pixelSize, item.outlineWidth, item.disableDepthTest, item.show]), h.records.map((r) => [namedPointId(r.id), 7, 1, Infinity, true]));
|
||||
assert.equal(h.points().spec.horizonCull, true);
|
||||
assert.equal(h.points().show, true);
|
||||
h.setX(1400); h.camera.positionWC = C.Cartesian3.fromDegrees(0, 0, 1.1e6); h.state.viewer.scene.preRender.raiseEvent();
|
||||
assert.equal(h.markers.stats().pointsOnScreen, 0, 'small pose changes refresh before render');
|
||||
h.lifecycle.disable();
|
||||
assert.equal(h.points().show, false);
|
||||
assert.equal(h.camera.changed.numberOfListeners, 1, 'only the viewport listener remains');
|
||||
assert.equal(h.state.viewer.scene.preRender.numberOfListeners, 0);
|
||||
assert.equal(h.labels.length, 0);
|
||||
@@ -85,7 +92,7 @@ test('wide named markers retain primitives until close polygons publish with the
|
||||
h.lifecycle.destroy(h.state.viewer);
|
||||
});
|
||||
|
||||
test('canonical aliases transfer named marker ownership without replacing primitives', (t) => {
|
||||
test('canonical aliases transfer named marker ownership without replacing markers or labels', (t) => {
|
||||
const h = setup(t);
|
||||
h.setX(600);
|
||||
const parent = h.records[1];
|
||||
@@ -105,6 +112,7 @@ test('canonical aliases transfer named marker ownership without replacing primit
|
||||
assert.equal(point, originalPoint);
|
||||
assert.equal(currentLabel, label);
|
||||
assert.equal(point.id.installationId, record.id);
|
||||
assert.deepEqual(h.points().items.get(namedPointId(record.id)).meta, { installationId: record.id });
|
||||
assert.equal(currentLabel.id, record.id);
|
||||
});
|
||||
}
|
||||
@@ -126,12 +134,11 @@ test('the bounded host cohort ranks wide points and polygon titles by area', (t)
|
||||
const first = h.labels[0];
|
||||
const publications = h.publications();
|
||||
for (let i = 0; i < 100; i++) {
|
||||
h.camera.viewMatrix[12] += 0.01;
|
||||
h.camera.positionWC = C.Cartesian3.fromDegrees(0, 0, 1e6 + i + 1);
|
||||
h.state.viewer.scene.preRender.raiseEvent();
|
||||
}
|
||||
assert.equal(h.labels[0], first);
|
||||
assert.equal(h.publications(), publications, 'camera frames never rebuild host entries');
|
||||
assert.equal(h.projections.size, 1, 'point projection reuses scratch storage');
|
||||
h.lifecycle.destroy(h.state.viewer);
|
||||
assert.equal(h.labels.length, 0);
|
||||
});
|
||||
|
||||
@@ -52,10 +52,13 @@ export function createSelection({
|
||||
};
|
||||
layerState.clickSubscription = inputFor(viewer).onClick((event) => {
|
||||
if (!layerState.enabled) return;
|
||||
const picked = event.pick;
|
||||
const target = picked?.id;
|
||||
// A named marker is a draw item; site markers are still entities.
|
||||
const hit = event.drawHit;
|
||||
const target = event.pick?.id;
|
||||
const id =
|
||||
target?.installationId ||
|
||||
(hit?.set === parts.namedMarkers?.setId
|
||||
? hit.meta?.installationId
|
||||
: null) ||
|
||||
installationMarkers.read(target)?.recordId ||
|
||||
(typeof target?.id === 'string' ? target.id : null);
|
||||
if (id && layerState.recordById.has(id) && id !== layerState.selectedId) {
|
||||
|
||||
@@ -4,7 +4,9 @@ import * as Cesium from 'cesium';
|
||||
import * as context from '../../data/contextStore.js';
|
||||
import { createSelection } from './selection.js';
|
||||
import { createRendering } from './rendering.js';
|
||||
import { createNamedMarkers } from './namedMarkers.js';
|
||||
import { createNamedMarkers, namedPointId } from './namedMarkers.js';
|
||||
import { bindFakeCesiumScene } from '../../testSupport/fakeCesiumScene.mjs';
|
||||
import { fakeInput } from '../../input/testDoubles.mjs';
|
||||
|
||||
function harness(t) {
|
||||
const previousWindow = globalThis.window;
|
||||
@@ -45,17 +47,17 @@ function harness(t) {
|
||||
clientHeight: 800,
|
||||
}),
|
||||
primitives: { add: (p) => p, remove() {} },
|
||||
pick: () => picked,
|
||||
},
|
||||
},
|
||||
};
|
||||
let picked;
|
||||
const { draw } = bindFakeCesiumScene(state.viewer);
|
||||
const input = fakeInput(state.viewer);
|
||||
t.mock.method(
|
||||
Cesium.SceneTransforms,
|
||||
'worldToWindowCoordinates',
|
||||
(_scene, _point, scratch) => {
|
||||
scratch.x = 640;
|
||||
scratch.y = 400;
|
||||
return scratch;
|
||||
},
|
||||
() => new Cesium.Cartesian2(640, 400),
|
||||
);
|
||||
let labels = [];
|
||||
const services = {
|
||||
@@ -91,6 +93,7 @@ function harness(t) {
|
||||
state.clickSubscription();
|
||||
parts.namedMarkers.destroy();
|
||||
parts.rendering.clearRendered();
|
||||
input.destroy();
|
||||
if (previousWindow === undefined) delete globalThis.window;
|
||||
else globalThis.window = previousWindow;
|
||||
if (previousDocument === undefined) delete globalThis.document;
|
||||
@@ -107,7 +110,18 @@ function harness(t) {
|
||||
};
|
||||
assert.equal(selection.selectRecord(record.id), true);
|
||||
assertSelected(true);
|
||||
return { state, selection, assertSelected };
|
||||
return {
|
||||
state,
|
||||
selection,
|
||||
assertSelected,
|
||||
draw,
|
||||
parts,
|
||||
/** Click on what `pick` names, as the scene would pick it. */
|
||||
click(value) {
|
||||
picked = value;
|
||||
input.tap({ x: 640, y: 400 });
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
for (const layerId of ['flights', 'military', 'satellites']) {
|
||||
@@ -153,3 +167,22 @@ test('destroy removes all installation context listeners', (t) => {
|
||||
h.assertSelected(true);
|
||||
}
|
||||
});
|
||||
|
||||
test('a click on a named marker point selects its site; again releases it', (t) => {
|
||||
const h = harness(t);
|
||||
h.state.selectedId = null;
|
||||
context.clearSelectedEntityContextForLayer('military-installations');
|
||||
h.parts.rendering.renderRecords();
|
||||
h.assertSelected(false);
|
||||
const setId = h.parts.namedMarkers.setId;
|
||||
const item = h.draw.set(setId).items.get(namedPointId('base'));
|
||||
assert.deepEqual(item.meta, { installationId: 'base' });
|
||||
const pointPick = { id: { set: setId, id: item.id, meta: item.meta } };
|
||||
h.click(pointPick);
|
||||
h.assertSelected(true);
|
||||
h.click(pointPick);
|
||||
h.assertSelected(false);
|
||||
// Another set's item with the same meta is not this layer's point.
|
||||
h.click({ id: { set: 'other:1', id: item.id, meta: item.meta } });
|
||||
h.assertSelected(false);
|
||||
});
|
||||
Reference in new issue
Block a user