mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
The wind reading at the map centre now asks the renderer's query port where the ellipsoid lies under the middle of the canvas and converts it with the app's WGS84 helpers, instead of Cesium's camera pick and Cartographic. The inspection marker projects its point with the query port, hides it beyond the ellipsoid's horizon with isOccluded, and follows rendered frames through the frame port's postRender phase instead of the scene's event. The layer entry no longer carries a Cesium namespace: the rendering part, which stays Cesium-bound, defaults it, owns the fallback globe imagery host, and loads the adapter factories a viewer with no renderer bound gets its ports from. The wind entry, its inspection reading and its marker leave the allow-list. They still read the viewer's canvas size and container element.
70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {
|
|
windFrom,
|
|
formatWindSpeed,
|
|
inspectWindAtCenter,
|
|
} from './inspection.js';
|
|
import { fromDegrees } from '../../geo/ellipsoid.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]),
|
|
},
|
|
};
|
|
let center = fromDegrees(0, 0);
|
|
const picks = [];
|
|
const view = {
|
|
canvas: { clientWidth: 800, clientHeight: 600 },
|
|
query: {
|
|
pickEllipsoid(x, y) {
|
|
picks.push([x, y]);
|
|
return center;
|
|
},
|
|
},
|
|
};
|
|
const result = inspectWindAtCenter(snapshot, view, {
|
|
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');
|
|
assert.deepEqual(picks, [[400, 300]], 'the pick is at the canvas center');
|
|
assert.equal(result.position, center);
|
|
center = fromDegrees(70, 20);
|
|
assert.equal(
|
|
inspectWindAtCenter(snapshot, view).coordinates,
|
|
'20.00°N · 70.00°E',
|
|
);
|
|
center = null;
|
|
assert.equal(
|
|
inspectWindAtCenter(snapshot, view).coordinates,
|
|
'No surface reading',
|
|
);
|
|
assert.equal(
|
|
inspectWindAtCenter(snapshot, { query: view.query }).coordinates,
|
|
'No surface reading',
|
|
'no canvas, no reading',
|
|
);
|
|
});
|