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

+5 -83
View File
@@ -1,95 +1,17 @@
/**
* @module render/stub/geodesic
* @description The point a fraction of the way along the WGS84 geodesic
* between two places: Vincenty's inverse formula, then the series the
* default renderer interpolates with, term for term, so a rectangle's
* centre matches its to floating-point noise.
* between two places: Vincenty's inverse formula (`geo/geodesic`), then
* the series the default renderer interpolates with, term for term, so a
* rectangle's centre matches its to floating-point noise.
*/
import { TWO_PI, WGS84 } from './math.js';
import { deltaLambda, geodesicInverse as inverse } from '../../geo/geodesic.js';
import { WGS84 } from './math.js';
const EPSILON12 = 1e-12;
const A = WGS84.radii.x;
const B = WGS84.radii.z;
const F = (A - B) / A;
function deltaLambda(sineAlpha, cos2Alpha, sigma, sinSigma, cosSigma, cos2Sm) {
const C = (F * cos2Alpha * (4 + F * (4 - 3 * cos2Alpha))) / 16;
return (
(1 - C) *
F *
sineAlpha *
(sigma + C * sinSigma * (cos2Sm + C * cosSigma * (2 * cos2Sm * cos2Sm - 1)))
);
}
/** Distance, start heading and u² of the geodesic from (lon1, lat1) to (lon2, lat2), radians. */
function inverse(lon1, lat1, lon2, lat2) {
const l = lon2 - lon1;
const u1 = Math.atan((1 - F) * Math.tan(lat1));
const u2 = Math.atan((1 - F) * Math.tan(lat2));
const cosU1 = Math.cos(u1);
const sinU1 = Math.sin(u1);
const cosU2 = Math.cos(u2);
const sinU2 = Math.sin(u2);
const cc = cosU1 * cosU2;
const cs = cosU1 * sinU2;
const ss = sinU1 * sinU2;
const sc = sinU1 * cosU2;
let lambda = l;
let lambdaDot = TWO_PI;
let cosLambda;
let sinLambda;
let sigma;
let cosSigma;
let sinSigma;
let cos2Alpha;
let cos2Sm;
do {
cosLambda = Math.cos(lambda);
sinLambda = Math.sin(lambda);
const temp = cs - sc * cosLambda;
sinSigma = Math.sqrt(cosU2 * cosU2 * sinLambda * sinLambda + temp * temp);
cosSigma = ss + cc * cosLambda;
sigma = Math.atan2(sinSigma, cosSigma);
let sineAlpha;
if (sinSigma === 0) {
sineAlpha = 0;
cos2Alpha = 1;
} else {
sineAlpha = (cc * sinLambda) / sinSigma;
cos2Alpha = 1 - sineAlpha * sineAlpha;
}
lambdaDot = lambda;
cos2Sm = cosSigma - (2 * ss) / cos2Alpha;
if (!isFinite(cos2Sm)) cos2Sm = 0;
lambda =
l + deltaLambda(sineAlpha, cos2Alpha, sigma, sinSigma, cosSigma, cos2Sm);
} while (Math.abs(lambda - lambdaDot) > EPSILON12);
const uSquared = (cos2Alpha * (A * A - B * B)) / (B * B);
const bigA =
1 +
(uSquared * (4096 + uSquared * (uSquared * (320 - 175 * uSquared) - 768))) /
16384;
const bigB =
(uSquared * (256 + uSquared * (uSquared * (74 - 47 * uSquared) - 128))) /
1024;
const cos2Sm2 = cos2Sm * cos2Sm;
const deltaSigma =
bigB *
sinSigma *
(cos2Sm +
(bigB *
(cosSigma * (2 * cos2Sm2 - 1) -
(bigB * cos2Sm * (4 * sinSigma * sinSigma - 3) * (4 * cos2Sm2 - 3)) /
6)) /
4);
return {
distance: B * bigA * (sigma - deltaSigma),
startHeading: Math.atan2(cosU2 * sinLambda, cs - sc * cosLambda),
uSquared,
};
}
/**
* The longitude and latitude (radians) `fraction` of the way along the
* geodesic from (lon1, lat1) to (lon2, lat2).
+2 -10
View File
@@ -9,6 +9,7 @@
* Nothing runs on its own: `testing.tick()` and `testing.advance()` drive the
* loop on a virtual clock, one frame at a time, in the contract's order.
*/
import { horizonFrom } from '../../geo/horizon.js';
import { createInputRouter } from '../input/router.js';
import { CAPABILITIES, CONTRACT_VERSION } from '../contract/index.js';
import { createStubCamera } from './camera.js';
@@ -27,7 +28,6 @@ import {
toDegrees,
toEcef,
vec,
WGS84,
} from './math.js';
const FRAME_MS = 1000 / 60;
@@ -504,15 +504,7 @@ export function createStubRenderer(options = {}) {
}
function isOccluded(position) {
const e = eye();
const r = WGS84.oneOverRadii;
const cv = vec(e.position.x * r.x, e.position.y * r.y, e.position.z * r.z);
const vh = dot(cv, cv) - 1;
const t = vec(position.x * r.x, position.y * r.y, position.z * r.z);
const vt = sub(t, cv);
const vtDotVc = -dot(vt, cv);
if (vh < 0) return vtDotVc > 0;
return vtDotVc > vh && (vtDotVc * vtDotVc) / dot(vt, vt) > vh;
return !horizonFrom(eye().position).isPointVisible(position);
}
let scriptedPicks = null;