feat(weather): add globe wind, observed weather and cyclone context (#617)

Wind (NOAA GFS and ECMWF IFS: animated particles, colour field, a reading at map centre), observed weather (NOAA MRMS radar, GOES and NESDIS infrared clouds, lightning density) on one shared history timeline, NHC and CPHC cyclone advisories with tracks and cones, and a WEATHER panel in the right rail. On 3D Tiles the observed products render as raised shells with a sharper window around the view.

Co-authored-by: Gustavo Beneduzi <[email protected]>
Co-authored-by: Daniel Slay <[email protected]>
Co-authored-by: Rehaan Delmotra <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-09-22 17:45:39 -05:00
1 parent f01b6a5d84
commit 0251c74109
180 files changed
+30645 -434

No files matched your search

+112
View File
@@ -0,0 +1,112 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
windFrom,
formatWindSpeed,
inspectWindAtCenter,
} from './inspection.js';
test('wind directions describe the source of the flow and calm is not north', () => {
assert.equal(windFrom(10, 0), 'W');
assert.equal(windFrom(-10, 0), 'E');
assert.equal(windFrom(0, 10), 'S');
assert.equal(windFrom(0, -10), 'N');
assert.equal(windFrom(0, 0), 'Calm');
assert.equal(formatWindSpeed(10, 'km/h'), '36.0 km/h');
assert.equal(formatWindSpeed(10, 'mph'), '22.4 mph');
});
test('center inspection uses a fixed forecast reading without double-converting scalar units', () => {
const snapshot = {
grid: { nx: 2, ny: 2, lo1: 0, la1: 90, dx: 180, dy: 180 },
u: Float32Array.from([10, 10, 10, 10]),
v: new Float32Array(4),
scalar: {
kind: 'temperature',
units: '°C',
values: Float32Array.from([20, 20, 20, 20]),
},
};
const viewer = {
camera: { pickEllipsoid: () => ({ longitude: 0, latitude: 0 }) },
scene: { canvas: { clientWidth: 800, clientHeight: 600 } },
};
const cesium = {
Cartesian2: class {
constructor(x, y) {
this.x = x;
this.y = y;
}
},
Ellipsoid: { WGS84: {} },
Cartographic: { fromCartesian: (p) => p },
Math: { toDegrees: (x) => (x * 180) / Math.PI },
};
const result = inspectWindAtCenter(snapshot, viewer, cesium, {
overlay: 'temperature',
units: 'km/h',
model: 'GFS',
validTime: 'fixed',
status: 'forecast',
});
assert.equal(result.wind, '36.0 km/h from W');
assert.equal(result.scalarValue, '20.0 °C');
assert.equal(result.validTime, 'fixed');
assert.equal(result.coordinates, '0.00°N · 0.00°E');
viewer.camera.pickEllipsoid = () => null;
assert.equal(
inspectWindAtCenter(snapshot, viewer, cesium).coordinates,
'No surface reading',
);
});
test('inspection marker follows only its captured point, hides beyond limb, and releases its listener', async () => {
const { createWindInspectionMarker } = await import('./inspection.js');
let listener = null;
let visible = true;
const projected = [];
const nodes = [];
const container = {
ownerDocument: { createElement: () => ({ style: {}, setAttribute() {}, remove() { nodes.splice(nodes.indexOf(this), 1); } }) },
appendChild(node) { nodes.push(node); },
getBoundingClientRect: () => ({ left: 5, top: 10 }),
};
const viewer = {
camera: { positionWC: {} },
scene: {
mode: 3,
canvas: { clientWidth: 800, clientHeight: 600, getBoundingClientRect: () => ({ left: 15, top: 30 }) },
postRender: { addEventListener(fn) { assert.equal(listener, null); listener = fn; return () => { listener = null; }; } },
cartesianToCanvasCoordinates(point) { projected.push(point); return { x: 100, y: 200 }; },
requestRender() {},
},
};
const cesium = {
SceneMode: { SCENE3D: 3 }, Ellipsoid: { WGS84: {} },
EllipsoidalOccluder: class { isPointVisible() { return visible; } },
};
const owner = createWindInspectionMarker({ container, viewer, cesium });
const point = { x: 1, y: 2, z: 3 };
owner.show(point);
assert.equal(nodes.length, 1);
assert.match(nodes[0].style.cssText, /pointer-events:none/);
assert.equal(nodes[0].style.left, '110px');
assert.equal(nodes[0].style.top, '220px');
viewer.camera.positionWC = { moved: true };
visible = false;
listener();
assert.equal(nodes[0].hidden, true);
assert.ok(projected.every((value) => value === point));
visible = true;
listener();
assert.equal(nodes[0].hidden, false);
owner.show({ x: 4 });
assert.equal(nodes.length, 1);
owner.clear();
assert.equal(nodes.length, 0);
assert.equal(listener, null);
owner.show(point);
owner.destroy();
owner.destroy();
assert.equal(nodes.length, 0);
assert.equal(listener, null);
});