mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
The timeline marks launches and strong earthquakes, not every weather frame
The timeline drew a tick for every registered mark, and the weather clock registered every radar, satellite and lightning frame, which come every few minutes, so the track was a wall of dashes and the arrow keys crept from frame to frame. Weather products now register only the span of their frames (start and end, as before) with no marks. Holds, the gate and the next-frame wait while the world plays are unchanged. A weather row's step param goes to the previous or next weather frame (every shown product's frames, and the row's own while it is suspended) rather than to the timeline's marks. The Earthquakes layer registers with the world clock once, at init, and unregisters on destroy. While on, its quakes of magnitude 6 and up (EARTHQUAKE_MARK_MAGNITUDE) are marks, and its coverage is their own span, or none without any, so it never stretches the timeline beyond the feed. Off, it has none. It tells the clock when the set of marks changes. The map still draws every M2.5+ quake. Launches stay marks. With no mark ahead or behind, the arrow keys step along the track as shown.
This commit is contained in:
1 parent
326cab4cf2
commit
7cb854c923
11 files changed
+181
-41
No files matched your search
@@ -2,6 +2,8 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createEarthquakesLayer } from './index.js';
|
||||
import { createUsgsEarthquakeSource } from './source.js';
|
||||
import { EARTHQUAKE_MARK_MAGNITUDE } from './model.js';
|
||||
import { worldClock } from '../../time/worldClock.js';
|
||||
function harness(source) {
|
||||
const sources = [];
|
||||
const events = [];
|
||||
@@ -88,3 +90,40 @@ test('USGS body completion honors cancellation even with an uncooperative transp
|
||||
name: 'AbortError',
|
||||
});
|
||||
});
|
||||
test('the timeline marks only strong quakes, while the layer is on', async () => {
|
||||
assert.equal(EARTHQUAKE_MARK_MAGNITUDE, 6);
|
||||
const rows = [
|
||||
{ ...row, stableId: 'small', mag: 4.5, time: 1_000 },
|
||||
{ ...row, stableId: 'strong', mag: 6, time: 5_000 },
|
||||
{ ...row, stableId: 'great', mag: 7.2, time: 3_000 },
|
||||
{ ...row, stableId: 'untimed', mag: 6.5, time: null },
|
||||
];
|
||||
let snapshot = rows;
|
||||
const h = harness({ getSnapshot: async () => snapshot });
|
||||
assert.equal(worldClock.coverage(), null, 'nothing loaded, no time to show');
|
||||
let changes = 0;
|
||||
const unsubscribe = worldClock.subscribe(() => changes++);
|
||||
await h.layer.update(h.viewer);
|
||||
// Every quake is drawn; only M6 and up are marks, spanning their own time.
|
||||
assert.equal(h.sources[0].entities.values.length, 4);
|
||||
assert.deepEqual(worldClock.coverage(), {
|
||||
start: 3_000,
|
||||
end: 5_000,
|
||||
marks: [3_000, 5_000],
|
||||
});
|
||||
const told = changes;
|
||||
await h.layer.update(h.viewer);
|
||||
assert.equal(changes, told, 'the same strong quakes are not told again');
|
||||
snapshot = rows.slice(0, 1);
|
||||
await h.layer.update(h.viewer);
|
||||
assert.equal(worldClock.coverage(), null, 'small shakes alone cover no time');
|
||||
snapshot = rows;
|
||||
await h.layer.update(h.viewer);
|
||||
h.layer.disable(h.viewer);
|
||||
assert.equal(worldClock.coverage(), null, 'off, no time to show');
|
||||
h.layer.enable(h.viewer);
|
||||
assert.deepEqual(worldClock.coverage().marks, [3_000, 5_000]);
|
||||
h.layer.destroy();
|
||||
assert.equal(worldClock.coverage(), null);
|
||||
unsubscribe();
|
||||
});
|
||||
Reference in new issue
Block a user