mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge branch 'main' into manjunath/hal-769-gev-ux-improve-visibility-of-the-250-km-radius-circle
# Conflicts: # scripts/format-scope.json # src/layers/awareness/policy.js # src/layers/awareness/rendering.js
This commit is contained in:
commit
0e3b1f67cf
187 files changed
+20675
-1564
No files matched your search
@@ -57,7 +57,6 @@ export const CONTEXT_RIM_HEIGHT_M = 2500;
|
||||
* keeps the 250 km edge readable between flashes, in screenshots and for
|
||||
* low-vision viewers. Once the pulses rest, and without pulses (reduced
|
||||
* motion, or a scene that cannot animate), it stays on screen at full. */
|
||||
|
||||
export const AWARENESS_RANGE_RING_STYLE = Object.freeze({
|
||||
color: 'rgba(98, 181, 255, 0.95)',
|
||||
outlineColor: 'rgba(4, 12, 16, 0.8)',
|
||||
|
||||
@@ -234,6 +234,41 @@ for (const [place, lat, lon] of [
|
||||
});
|
||||
}
|
||||
|
||||
for (const [place, lat, lon] of [
|
||||
['the North Pole', 90, 0],
|
||||
['the South Pole', -90, 0],
|
||||
['1e-7° from the North Pole', 90 - 1e-7, 45],
|
||||
['1e-8° from the South Pole', -90 + 1e-8, -120],
|
||||
]) {
|
||||
test(`the ring stays a full circle at ${place}`, () => {
|
||||
const center = Cesium.Cartesian3.fromDegrees(lon, lat, 0);
|
||||
const segments = AWARENESS_RANGE_RING_STYLE.segments;
|
||||
const positions = awarenessRangeRingPositions(
|
||||
center,
|
||||
AWARENESS_RADIUS_M,
|
||||
CONTEXT_RIM_HEIGHT_M,
|
||||
);
|
||||
assert.equal(positions.length, segments + 1);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.equalsEpsilon(positions[0], positions.at(-1), 0, 1e-6),
|
||||
'the ring closes on itself',
|
||||
);
|
||||
const distinct = new Set(
|
||||
positions
|
||||
.slice(0, segments)
|
||||
.map(({ x, y, z }) => [x, y, z].map((v) => v.toFixed(1)).join()),
|
||||
);
|
||||
assert.equal(distinct.size, segments, 'every vertex is its own point');
|
||||
// Ordinary chords are 2π × 250 km / 128 ≈ 12.3 km long.
|
||||
for (let i = 0; i < segments; i++) {
|
||||
const chord = Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
||||
assert.ok(chord > 11_500 && chord < 13_000, `chord ${i}: ${chord} m`);
|
||||
}
|
||||
for (const distance of surfaceDistances(center, positions))
|
||||
assert.ok(Math.abs(distance - AWARENESS_RADIUS_M) < 100, `${distance} m`);
|
||||
});
|
||||
}
|
||||
|
||||
test('the ring core and halo contrast on light and dark ground', () => {
|
||||
const core = Cesium.Color.fromCssColorString(
|
||||
AWARENESS_RANGE_RING_STYLE.color,
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
* A closed ring of positions `radiusM` along the surface from `groundCenter`,
|
||||
* raised to `heightM`. Each bearing steps over a sphere with the ellipsoid's
|
||||
* radius of curvature in that direction (Euler's formula), which keeps the
|
||||
* ring within a few metres of the true geodesic radius at 250 km.
|
||||
* ring within ~50 m of the true geodesic radius at 250 km.
|
||||
* @param {Cesium.Cartesian3} groundCenter Ring centre on the ellipsoid.
|
||||
* @param {number} radiusM Surface radius in metres.
|
||||
* @param {number} heightM Height of the ring above the ellipsoid.
|
||||
@@ -48,31 +48,32 @@ export function awarenessRangeRingPositions(
|
||||
const e2 = 1 - (b * b) / (a * a);
|
||||
const sinLat = Math.sin(latitude);
|
||||
const cosLat = Math.cos(latitude);
|
||||
const sinLon = Math.sin(longitude);
|
||||
const cosLon = Math.cos(longitude);
|
||||
const w = 1 - e2 * sinLat * sinLat;
|
||||
const meridional = (a * (1 - e2)) / (w * Math.sqrt(w));
|
||||
const primeVertical = a / Math.sqrt(w);
|
||||
const positions = new Array(segments + 1);
|
||||
// Step along the great circle in 3D from the centre's up, north and east
|
||||
// unit vectors. Unlike the latitude/longitude destination formula, this
|
||||
// stays well conditioned at and next to the poles.
|
||||
const up = [cosLat * cosLon, cosLat * sinLon, sinLat];
|
||||
const north = [-sinLat * cosLon, -sinLat * sinLon, cosLat];
|
||||
const east = [-sinLon, cosLon, 0];
|
||||
const positions = [];
|
||||
for (let i = 0; i <= segments; i++) {
|
||||
const bearing = ((i % segments) / segments) * Cesium.Math.TWO_PI;
|
||||
const cosB = Math.cos(bearing);
|
||||
const sinB = Math.sin(bearing);
|
||||
const angular =
|
||||
radiusM * ((cosB * cosB) / meridional + (sinB * sinB) / primeVertical);
|
||||
const lat = Math.asin(
|
||||
sinLat * Math.cos(angular) + cosLat * Math.sin(angular) * cosB,
|
||||
);
|
||||
const lon =
|
||||
longitude +
|
||||
Math.atan2(
|
||||
sinB * Math.sin(angular) * cosLat,
|
||||
Math.cos(angular) - sinLat * Math.sin(lat),
|
||||
);
|
||||
positions[i] = Cesium.Cartesian3.fromRadians(
|
||||
lon,
|
||||
lat,
|
||||
heightM,
|
||||
Cesium.Ellipsoid.WGS84,
|
||||
const cosA = Math.cos(angular);
|
||||
const sinA = Math.sin(angular);
|
||||
const [x, y, z] = up.map(
|
||||
(u, k) => u * cosA + (north[k] * cosB + east[k] * sinB) * sinA,
|
||||
);
|
||||
const lat = Math.atan2(z, Math.hypot(x, y));
|
||||
const lon = Math.atan2(y, x);
|
||||
positions.push(Cesium.Cartesian3.fromRadians(lon, lat, heightM));
|
||||
}
|
||||
return positions;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user