Keep installation and local GeoJSON pick state off Cesium entities

Installation selection fills and outlines record the installation they
belong to in the layer's installationMarkers store instead of an
installationId expando, and the click handler resolves them from there.
Named-marker points keep their { installationId } pick payload, which is
the app's own object, so sibling layers treat a point click as before; the
marker remembers its record id for visit() instead of reading the point.

The local GeoJSON package tracks the entities each layer loaded in a
per-instance set instead of a __localLayerId tag, and passes the stem
base to registerEntityContext as targetPosition instead of hanging it on
the entity; FIRMS does the same, and voice targeting reads the context
record. QA scripts find a layer's features by their context id.
This commit is contained in:
Sameh Khamis committed 2026-11-03 14:57:31 -08:00
1 parent 0889cd0cb7
commit 08985d5083
13 files changed
+58 -28

No files matched your search

+1 -2
View File
@@ -185,9 +185,8 @@ export function createSelection({
// Refreshed every registration: the anchor re-grounds onto the DEM when
// its floor cell warms, and voice targeting must project the same point
// the sprite renders at.
fire.contextEntity.__localBaseCartesian =
components.model.firePosition(fire);
registerEntityContext(fire.contextEntity, {
targetPosition: components.model.firePosition(fire),
id: recordId,
layerId: id,
layerName: name,
+2
View File
@@ -3,5 +3,7 @@ import { createEntityStore } from '../../data/entityRecords.js';
/**
* What the installations layer last drew for a retained marker entity, so an
* unchanged record leaves it alone: `heightM` (surface height) and `selected`.
* Selection fills and outlines record the installation they belong to as
* `recordId`, which a pick on them resolves through.
*/
export const installationMarkers = createEntityStore();
+6 -3
View File
@@ -128,6 +128,7 @@ export function createNamedMarkers({ state, services, parts, overlayHost }) {
const marker = markers.get(alias);
markers.delete(alias);
marker.point.id = { installationId: record.id };
marker.recordId = record.id;
marker.entry.id = record.id;
markers.set(record.id, marker);
}
@@ -148,10 +149,12 @@ export function createNamedMarkers({ state, services, parts, overlayHost }) {
);
let marker = markers.get(record.id);
if (!marker) {
const id = { installationId: record.id };
marker = {
recordId: record.id,
point: points.add({
id,
// 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: parts.model.colorFor(record),
@@ -197,7 +200,7 @@ export function createNamedMarkers({ state, services, parts, overlayHost }) {
visit(visitor) {
for (let i = 0; i < ordered.length; i++) {
const marker = ordered[i];
visitor(marker.point.id.installationId, marker.point);
visitor(marker.recordId, marker.point);
}
},
refresh,
+2 -2
View File
@@ -84,7 +84,7 @@ export function createRendering({
classificationType,
},
});
fill.installationId = record.id;
installationMarkers.write(fill).recordId = record.id;
selectedFillIds.push(fill.id);
}
governorRequestRender('installation-selection-fill');
@@ -267,7 +267,7 @@ export function createRendering({
classificationType: Cesium.ClassificationType.BOTH,
},
});
outline.installationId = record.id;
installationMarkers.write(outline).recordId = record.id;
entityIds.push(outline.id);
}
Object.assign(installationMarkers.write(entity), {
+5 -2
View File
@@ -1,6 +1,7 @@
import * as Cesium from 'cesium';
import { isPointerFree } from '../../data/inputOwnership.js';
import { LAYER_ID } from './policy.js';
import { installationMarkers } from './markerState.js';
export function createSelection({
state: layerState,
@@ -58,9 +59,11 @@ export function createSelection({
if (!isPointerFree()) return;
if (!layerState.enabled) return;
const picked = viewer.scene.pick(click.position);
const target = picked?.id;
const id =
picked?.id?.installationId ||
(typeof picked?.id?.id === 'string' ? picked.id.id : null);
target?.installationId ||
installationMarkers.read(target)?.recordId ||
(typeof target?.id === 'string' ? target.id : null);
if (id && layerState.recordById.has(id) && id !== layerState.selectedId) {
selectRecord(id);
} else if (layerState.selectedId) {
@@ -3,6 +3,7 @@ import assert from 'node:assert/strict';
import * as C from 'cesium';
import { createRendering } from './rendering.js';
import { createLifecycle } from './lifecycle.js';
import { installationMarkers } from './markerState.js';
function harness() {
const ring = [[-97, 30], [-96.99, 30], [-96.99, 30.01], [-97, 30]];
@@ -23,7 +24,7 @@ test('selected multipart footprints classify Google tiles with one constant tran
const fills = h.state.dataSource.entities.values.slice();
assert.equal(fills.length, 2);
for (const fill of fills) {
assert.equal(fill.installationId, 'base');
assert.equal(installationMarkers.read(fill)?.recordId, 'base');
assert.equal(fill.polygon.classificationType.getValue(), C.ClassificationType.CESIUM_3D_TILE);
assert.equal(fill.polygon.height, undefined);
assert.equal(fill.polygon.extrudedHeight, undefined);