Files
gods-eye-view/src/layers/transit/index.js
T
German Khokhlov 3814221cbc Scope world overlays to each scene attachment
Move the world overlay into scene.services.overlay. Each attachment owns its
sources, collision domains, paint lanes, canvases, observers, timers and
accessible action subscribers. Keep both canvases inside the engine container,
with detection beside the card root so its screen blend still reaches the
scene. Release shared font measurements only after the last host detaches.

Resolve retained layer publications against their attached engine, clear the
outgoing source before releasing its renderer, and reconnect the shell's action
subscription on attachment. Keep destroyed hosts inert and give parked engines
fresh services. Bind annotation rectangles and the existing tracked bridge to
their engine's overlay. The tracked bridge itself remains page-owned.

Preserve Cesium's projection, card placement, arbitration, fades, hit tests,
blend order and render demand. Navara keeps the same shared behaviour. No
user-visible change is intended. Exercise simultaneous hosts, either teardown,
stale handles, reattachment and a retained selected card on the fake and
headless Cesium engines. Update QA reads and package ownership for the service.

No coupling metric falls or grows: renderer lines remain 0 Cesium and 189
Navara; external Cesium import files 3; viewer lines 891; Navara kind checks 1;
engine sniff calls 0; extension reads 3; ground passes 1; SDK loads 3;
ScreenSpaceEventHandler files 4; engine-name lines 32.

Each host now takes the page's overlay ids from the host it replaces and gives
them back to a remaining host when destroyed, and the chrome's static overlay
placeholders are gone. The new hosts had left the ids on those empty
placeholders, so the voice pointer policy, the id selectors and the QA probes
that read #world-overlay-canvas missed the drawn canvas.

Checked in the browser, keyless: the overlay baselines on both engines, CCTV
v2 (58 checks), military names, and the engine, voice, ground-layer and Ghost
Maps switches pass. The transit script fails the same 25 checks as before.
2026-11-07 19:27:31 +04:00

86 lines
2.9 KiB
JavaScript

import { bindOverlayHost } from '../../overlays/bindOverlayHost.js';
import { createTransitSource } from './source.js';
import { createTrails } from './trails.js';
import { createState } from './state.js';
import { createHeight } from './height.js';
import { createRendering } from './rendering.js';
import { createSelection } from './selection.js';
import { createIngestion } from './ingestion.js';
import { createViewport } from './viewport.js';
import { createQueries } from './queries.js';
import { createControls } from './controls.js';
import { createLifecycle } from './lifecycle.js';
import { createTesting } from './testing.js';
import { TRANSIT_POLL_MS } from './policy.js';
/**
* Construct one Transit layer with its own scene state and supplied services.
*
* Nothing here is module-global: the renderer, the marker sets, the vehicle
* and height maps, the in-flight requests, the manager handle and the overlay
* host all live on the instance this returns, and `destroy()` releases every
* shared registration it took (pick owner, render hold, camera sensitivity).
*
* @param {{services: object}} options
* @returns {object} The data-layer module the manager registers.
*/
export function createTransitLayer({
services,
source = createTransitSource(),
rendererFactory,
}) {
if (!services?.overlays || !services?.render) {
throw new TypeError('A transit layer needs overlay and render services');
}
if (
typeof source?.requestSnapshot !== 'function' ||
typeof source?.getHistory !== 'function'
) {
throw new TypeError(
'A transit source needs snapshot and history operations',
);
}
const parts = {};
services = {
...services,
overlays: bindOverlayHost(services.overlays, () => parts.renderer?.engine),
};
const state = createState({ services });
const context = { state, services, parts, source, rendererFactory };
parts.trails = createTrails(context);
parts.height = createHeight(context);
parts.selection = createSelection(context);
parts.rendering = createRendering(context);
parts.ingestion = createIngestion(context);
parts.viewport = createViewport(context);
parts.queries = createQueries(context);
parts.controls = createControls(context);
parts.lifecycle = createLifecycle(context);
parts.testing = createTesting(context);
return Object.assign(
{ updateInterval: TRANSIT_POLL_MS },
parts.lifecycle.methods,
parts.queries.methods,
parts.controls.methods,
parts.testing,
);
}
export {
TRANSIT_MODE_COLORS,
TRANSIT_POLL_MS,
TRANSIT_SELECTED_OVERLAY_SOURCE_ID,
TRANSIT_SELECTED_OVERLAY_SOURCE_OPTIONS,
aggregateTransitFeedHealth,
buildTransitSelectionCopy,
createTransitSelectedOverlayEntry,
interpolatedVehiclePosition,
isStaleVehicleFix,
transitDetectionClass,
transitDetectionId,
transitDetectionMetric,
transitVehicleKey,
vehicleFixAgeMs,
} from './policy.js';