From 569c7cfb1b61b734f47eb5301515789abbc8d09a Mon Sep 17 00:00:00 2001 From: Denis Groshev Date: Wed, 4 Nov 2026 23:59:17 +0100 Subject: [PATCH] feat(installations): look a mapped site up by id or scene pick getById returns a loaded installation with its drawn position, as getNearby does, without selecting it; findByPick resolves a scene pick (a named marker's installationId or a site entity) the way the layer's own click selection reads it. Both return null while the layer is off. --- src/layers/installations/controls.js | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/layers/installations/controls.js b/src/layers/installations/controls.js index 2fa31e59e..5cbe0ca29 100644 --- a/src/layers/installations/controls.js +++ b/src/layers/installations/controls.js @@ -164,6 +164,41 @@ export function createControls({ state: layerState, services, parts, source }) { ); }, + /** + * A loaded mapped installation by id, as `getNearby` returns it (with its + * drawn `position`), or null while the layer is off or the id is not + * loaded. Read-only: nothing is selected. + * @param {string} id Source-backed installation id. + * @returns {object|null} + */ + getById(id) { + if (!layerState.enabled || id === null || id === undefined) return null; + const record = layerState.recordById.get(String(id)); + if (!record || record.kind !== 'installation') return null; + return { + ...record, + position: Cesium.Cartesian3.fromDegrees( + record.longitude, + record.latitude, + parts.rendering.installationSurfaceHeightM(record), + ), + }; + }, + + /** + * The mapped installation a `scene.pick()` result landed on: a named + * marker point (`{ installationId }`) or a site entity, as this layer's + * own click selection reads them. Null for anything else. + * @param {object|null|undefined} picked + * @returns {object|null} As {@link getById}. + */ + findByPick(picked) { + const id = + picked?.id?.installationId || + (typeof picked?.id?.id === 'string' ? picked.id.id : null); + return id ? methods.getById(id) : null; + }, + /** * Select and frame a mapped installation from another contextual UI. * @param {string} id Source-backed installation id.