Draw submarine cables through the renderer's draw and camera ports

Cable lines, landing pins, polygon fills, reference stems and reference
points are now five draw sets per layer (submarine-cables:N:lines and so
on) instead of GeoJSON data sources and entities. Clicks resolve through
the draw hit; flights and the sweep's eye go through the camera port.
The layer keeps the styling the GeoJSON loader gave it: cable colours,
widths and alphas, simplestyle stroke, fill and marker properties, fills
that keep the source's alpha, raised polygons at their heights, the
default pin image, and features without a reference drawn but neither
picked nor culled. Lines are densified along rhumb lines at the
renderer's own granularity, so the draped geodesic arcs land on the same
vertices the rhumb-line polylines did.

Supporting pieces:
- geo/rhumb, geo/horizon and geo/geodesic port the default renderer's
  rhumb line, ellipsoidal occluder and Vincenty inverse; the stub
  renderer now uses the shared horizon test and Vincenty inverse
  instead of its own copies. render/color gains cssColor, which reads
  CSS colours as the renderer does (hex, rgb, hsl; not named colours).
- The Cesium draw port changes a line in place when only whether it
  shows changes (draped, on its ground primitive, waiting for it to be
  ready rather than restarting its build) or where an undraped line
  runs; anything else still rebuilds. Icon sets honour their blend.

Ingestion, interaction, overlay, policy, rendering, state and surface no
longer import Cesium and leave the allow-list. Pins are culled at the
horizon each frame by the draw port instead of on the sweep, and
marker-symbol glyphs are not drawn inside pins.
This commit is contained in:
Sameh Khamis committed 2026-11-06 22:10:53 -08:00
1 parent f24b66d80d
commit e74c7c1f44
29 files changed
+2260 -2064

No files matched your search

+19 -16
View File
@@ -1,3 +1,4 @@
import { cameraOf } from '../../render/rendererOf.js';
import {
cableClassificationTypeForScene,
cableClassificationTypeForStack,
@@ -14,9 +15,8 @@ export function createLifecycle({ state, parts, source, mapStackEventTarget }) {
init(viewer) {
state._viewer = viewer;
state._classificationType = cableClassificationTypeForScene(
viewer?.scene,
);
state._clampTo = cableClassificationTypeForScene(viewer?.scene);
parts.rendering.attach(viewer);
if (!state._mapStackListener && mapStackEventTarget?.addEventListener) {
state._mapStackListener = (event) => {
parts.rendering.applyCableClassification(
@@ -31,6 +31,12 @@ export function createLifecycle({ state, parts, source, mapStackEventTarget }) {
);
}
parts.interaction.beginInteraction(viewer);
// The eye the sweep gate's motion probe reads, only when it probes.
const eye = {
get positionWC() {
return cameraOf(viewer).pose()?.position ?? null;
},
};
if (!state._preRenderRemover) {
state._preRenderRemover = viewer.scene.preRender.addEventListener(
() => {
@@ -41,7 +47,7 @@ export function createLifecycle({ state, parts, source, mapStackEventTarget }) {
if (
!state._enabled ||
!state._loaded ||
!state._referenceSweepGate.shouldRun(viewer.camera)
!state._referenceSweepGate.shouldRun(eye)
)
return;
parts.rendering.updateReferenceVisibility();
@@ -49,7 +55,7 @@ export function createLifecycle({ state, parts, source, mapStackEventTarget }) {
);
}
if (!state._moveEndRemover) {
state._moveEndRemover = viewer.camera.moveEnd.addEventListener(() => {
state._moveEndRemover = cameraOf(viewer).on('moveEnd', () => {
if (!state._enabled) return;
state._referenceSweepGate.markDirty();
viewer.scene.requestRender?.();
@@ -80,19 +86,21 @@ export function createLifecycle({ state, parts, source, mapStackEventTarget }) {
state._loading = false;
state._loadingLabel = '';
}
// Free the entities rather than hide them; enable() rebuilds from the
// Free the items rather than hide them; enable() rebuilds from the
// cached JSON. An in-flight load's own post-await ownership check
// removes whatever that stale generation adds later.
parts.rendering.releaseDataSources(state._viewer);
// keeps that stale generation from drawing anything later.
parts.rendering.releaseDrawing();
parts.rendering.updateVisibility();
},
update(viewer) {
return parts.ingestion.load(viewer || state._viewer);
},
destroy(viewer) {
destroy() {
if (state._abort) state._abort.abort();
parts.rendering.releaseDataSources(viewer || state._viewer);
parts.rendering.releaseDrawing({ clearSets: false });
parts.rendering.detach();
state._cachedCableJson = null;
state._cachedLandingJson = null;
// hide() clears every published host entry and goes invisible while
@@ -126,15 +134,10 @@ export function createLifecycle({ state, parts, source, mapStackEventTarget }) {
state._error = null;
state._lastUpdate = null;
state._loadingLabel = '';
state._cableDataSource = null;
state._landingDataSource = null;
state._referenceDataSource = null;
state._referenceRecords = [];
state._surfaceRecords = [];
state._surfaceItems = [];
state._referenceLabelCount = 0;
state._publishScratch.length = 0;
state._markerBlendDone = false;
state._markerBlendInvariantWarned = false;
parts.rendering.resetPublishSignature();
state._referenceSweepGate.reset();
},