mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
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:
1 parent
f24b66d80d
commit
e74c7c1f44
29 files changed
+2260
-2064
No files matched your search
@@ -0,0 +1,150 @@
|
||||
/**
|
||||
* @module geo/geodesic
|
||||
* @description Surface distance along the WGS84 geodesic between two
|
||||
* points, by the default renderer's own method (`EllipsoidGeodesic`,
|
||||
* Vincenty's inverse formula): the same series in the same order, so the
|
||||
* distance agrees with the renderer's to floating-point noise. Angles in
|
||||
* radians, distances in metres.
|
||||
*/
|
||||
import { WGS84 } from './ellipsoid.js';
|
||||
|
||||
const MAJOR = WGS84.radii.x;
|
||||
const MINOR = WGS84.radii.z;
|
||||
const FLATTENING = (MAJOR - MINOR) / MAJOR;
|
||||
const EPSILON12 = 1e-12;
|
||||
/**
|
||||
* Vincenty converges in a handful of steps except between nearly antipodal
|
||||
* points, where it may not converge at all; stop there instead of hanging.
|
||||
*/
|
||||
const MAX_ITERATIONS = 200;
|
||||
|
||||
/** Vincenty's longitude correction, shared with the direct series. */
|
||||
export function deltaLambda(
|
||||
sineAlpha,
|
||||
cosineSquaredAlpha,
|
||||
sigma,
|
||||
sineSigma,
|
||||
cosineSigma,
|
||||
cosineTwiceSigmaMidpoint,
|
||||
) {
|
||||
const f = FLATTENING;
|
||||
const C =
|
||||
(f * cosineSquaredAlpha * (4.0 + f * (4.0 - 3.0 * cosineSquaredAlpha))) /
|
||||
16.0;
|
||||
return (
|
||||
(1.0 - C) *
|
||||
f *
|
||||
sineAlpha *
|
||||
(sigma +
|
||||
C *
|
||||
sineSigma *
|
||||
(cosineTwiceSigmaMidpoint +
|
||||
C *
|
||||
cosineSigma *
|
||||
(2.0 * cosineTwiceSigmaMidpoint * cosineTwiceSigmaMidpoint - 1.0)))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vincenty's inverse: the geodesic from (lon1, lat1) to (lon2, lat2),
|
||||
* radians, as its length in metres, its start heading and its u².
|
||||
*/
|
||||
export function geodesicInverse(lon1, lat1, lon2, lat2) {
|
||||
const l = lon2 - lon1;
|
||||
const u1 = Math.atan((1 - FLATTENING) * Math.tan(lat1));
|
||||
const u2 = Math.atan((1 - FLATTENING) * Math.tan(lat2));
|
||||
const cosineU1 = Math.cos(u1);
|
||||
const sineU1 = Math.sin(u1);
|
||||
const cosineU2 = Math.cos(u2);
|
||||
const sineU2 = Math.sin(u2);
|
||||
const cc = cosineU1 * cosineU2;
|
||||
const cs = cosineU1 * sineU2;
|
||||
const ss = sineU1 * sineU2;
|
||||
const sc = sineU1 * cosineU2;
|
||||
|
||||
let lambda = l;
|
||||
let lambdaDot;
|
||||
let cosineLambda;
|
||||
let sineLambda;
|
||||
let sigma;
|
||||
let cosineSigma;
|
||||
let sineSigma;
|
||||
let cosineSquaredAlpha;
|
||||
let cosineTwiceSigmaMidpoint;
|
||||
let iterations = 0;
|
||||
do {
|
||||
cosineLambda = Math.cos(lambda);
|
||||
sineLambda = Math.sin(lambda);
|
||||
const temp = cs - sc * cosineLambda;
|
||||
sineSigma = Math.sqrt(
|
||||
cosineU2 * cosineU2 * sineLambda * sineLambda + temp * temp,
|
||||
);
|
||||
cosineSigma = ss + cc * cosineLambda;
|
||||
sigma = Math.atan2(sineSigma, cosineSigma);
|
||||
let sineAlpha;
|
||||
if (sineSigma === 0.0) {
|
||||
sineAlpha = 0.0;
|
||||
cosineSquaredAlpha = 1.0;
|
||||
} else {
|
||||
sineAlpha = (cc * sineLambda) / sineSigma;
|
||||
cosineSquaredAlpha = 1.0 - sineAlpha * sineAlpha;
|
||||
}
|
||||
lambdaDot = lambda;
|
||||
cosineTwiceSigmaMidpoint = cosineSigma - (2.0 * ss) / cosineSquaredAlpha;
|
||||
if (!isFinite(cosineTwiceSigmaMidpoint)) cosineTwiceSigmaMidpoint = 0.0;
|
||||
lambda =
|
||||
l +
|
||||
deltaLambda(
|
||||
sineAlpha,
|
||||
cosineSquaredAlpha,
|
||||
sigma,
|
||||
sineSigma,
|
||||
cosineSigma,
|
||||
cosineTwiceSigmaMidpoint,
|
||||
);
|
||||
} while (
|
||||
Math.abs(lambda - lambdaDot) > EPSILON12 &&
|
||||
++iterations < MAX_ITERATIONS
|
||||
);
|
||||
|
||||
const uSquared =
|
||||
(cosineSquaredAlpha * (MAJOR * MAJOR - MINOR * MINOR)) / (MINOR * MINOR);
|
||||
const A =
|
||||
1.0 +
|
||||
(uSquared *
|
||||
(4096.0 + uSquared * (uSquared * (320.0 - 175.0 * uSquared) - 768.0))) /
|
||||
16384.0;
|
||||
const B =
|
||||
(uSquared *
|
||||
(256.0 + uSquared * (uSquared * (74.0 - 47.0 * uSquared) - 128.0))) /
|
||||
1024.0;
|
||||
const cosineSquaredTwiceSigmaMidpoint =
|
||||
cosineTwiceSigmaMidpoint * cosineTwiceSigmaMidpoint;
|
||||
const deltaSigma =
|
||||
B *
|
||||
sineSigma *
|
||||
(cosineTwiceSigmaMidpoint +
|
||||
(B *
|
||||
(cosineSigma * (2.0 * cosineSquaredTwiceSigmaMidpoint - 1.0) -
|
||||
(B *
|
||||
cosineTwiceSigmaMidpoint *
|
||||
(4.0 * sineSigma * sineSigma - 3.0) *
|
||||
(4.0 * cosineSquaredTwiceSigmaMidpoint - 3.0)) /
|
||||
6.0)) /
|
||||
4.0);
|
||||
return {
|
||||
distance: MINOR * A * (sigma - deltaSigma),
|
||||
startHeading: Math.atan2(cosineU2 * sineLambda, cs - sc * cosineLambda),
|
||||
uSquared,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Geodesic surface distance between two points; heights are ignored.
|
||||
* @param {{lon: number, lat: number}} start Radians.
|
||||
* @param {{lon: number, lat: number}} end Radians.
|
||||
* @returns {number} Metres.
|
||||
*/
|
||||
export function surfaceDistance(start, end) {
|
||||
return geodesicInverse(start.lon, start.lat, end.lon, end.lat).distance;
|
||||
}
|
||||
Reference in new issue
Block a user