mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32: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
97bd61711c
commit
900c76425c
11 files changed
+174
-41
No files matched your search
@@ -198,11 +198,13 @@ export function createWeatherClock({
|
||||
throw new Error(`Duplicate weather product: ${product.id}`);
|
||||
const entry = { product, controller: null };
|
||||
registry.set(product.id, entry);
|
||||
// The product moves with the world clock, and its frames are time the
|
||||
// world clock's timeline can show while it is on, suspended or not, so
|
||||
// the way back to live stays on screen. Both calls notify the world's
|
||||
// listeners, which may destroy this clock: the release is in place
|
||||
// first, and anything acquired after a destroy is let go at once.
|
||||
// The product moves with the world clock, and the span of its frames is
|
||||
// time the world clock's timeline can show while it is on, suspended or
|
||||
// not, so the way back to live stays on screen. The frames are not
|
||||
// marks: they come every few minutes, and the timeline marks only
|
||||
// events. Both calls notify the world's listeners, which may destroy
|
||||
// this clock: the release is in place first, and anything acquired
|
||||
// after a destroy is let go at once.
|
||||
let unhold = null;
|
||||
let uncover = null;
|
||||
const release = () => {
|
||||
@@ -216,9 +218,12 @@ export function createWeatherClock({
|
||||
uncover = world.register({
|
||||
id: product.id,
|
||||
coverage: () => {
|
||||
const marks = timesFor(product).map((time) => Date.parse(time));
|
||||
return marks.length
|
||||
? { start: marks[0], end: marks.at(-1), marks }
|
||||
const times = timesFor(product);
|
||||
return times.length
|
||||
? {
|
||||
start: Date.parse(times[0]),
|
||||
end: Date.parse(times.at(-1)),
|
||||
}
|
||||
: null;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -367,7 +367,7 @@ test('weather clocks sharing a world: the last one destroyed leaves it live', ()
|
||||
assert.equal(world.isPlaying(), false);
|
||||
});
|
||||
|
||||
test('each product’s frames are world clock coverage, and support the timeline while shown', (t) => {
|
||||
test('each product’s frames span world clock coverage, with no marks, and support the timeline while shown', (t) => {
|
||||
const { clock, world } = harness(t);
|
||||
assert.equal(world.coverage(), null);
|
||||
assert.equal(world.getState().supported, false);
|
||||
@@ -377,11 +377,15 @@ test('each product’s frames are world clock coverage, and support the timeline
|
||||
assert.deepEqual(world.coverage(), {
|
||||
start: Date.parse(time(0)),
|
||||
end: Date.parse(time(10)),
|
||||
marks: [0, 5, 10].map((m) => Date.parse(time(m))),
|
||||
marks: [],
|
||||
});
|
||||
assert.equal(world.getState().supported, true);
|
||||
unregister();
|
||||
assert.deepEqual(world.coverage().marks, [Date.parse(time(5))]);
|
||||
assert.deepEqual(world.coverage(), {
|
||||
start: Date.parse(time(5)),
|
||||
end: Date.parse(time(5)),
|
||||
marks: [],
|
||||
});
|
||||
clock.destroy();
|
||||
assert.equal(world.coverage(), null);
|
||||
assert.equal(world.getState().supported, false);
|
||||
@@ -394,10 +398,11 @@ test('a suspended product keeps its coverage, so the way back to live stays', (t
|
||||
radar.suspended = true;
|
||||
void clock.refresh();
|
||||
assert.equal(world.getState().supported, true);
|
||||
assert.deepEqual(
|
||||
world.coverage().marks,
|
||||
[0, 10].map((m) => Date.parse(time(m))),
|
||||
);
|
||||
assert.deepEqual(world.coverage(), {
|
||||
start: Date.parse(time(0)),
|
||||
end: Date.parse(time(10)),
|
||||
marks: [],
|
||||
});
|
||||
});
|
||||
|
||||
test('new frames reach the world clock through refresh', (t) => {
|
||||
|
||||
@@ -64,11 +64,12 @@ const utc = (value) =>
|
||||
|
||||
/**
|
||||
* Move `world`, the world clock, as its timeline does: `play` toggles play
|
||||
* (from the start of the covered time when live), `latest` goes live, and
|
||||
* `step` (-1 or 1) goes to the previous or next mark, a weather frame among
|
||||
* them, as the timeline's arrow keys do.
|
||||
* (from the start of the covered time when live) and `latest` goes live.
|
||||
* `step` (-1 or 1) goes to the previous or next of `frames`, the weather
|
||||
* frames; the timeline does not mark them, so this is the row's own way to
|
||||
* step through them.
|
||||
*/
|
||||
function moveWorldTime(world, { play, latest, step }) {
|
||||
function moveWorldTime(world, frames, { play, latest, step }) {
|
||||
if (!world) return;
|
||||
if (play === true) {
|
||||
const state = world.getState();
|
||||
@@ -82,11 +83,14 @@ function moveWorldTime(world, { play, latest, step }) {
|
||||
if (latest === true) world.goLive();
|
||||
if (step === -1 || step === 1) {
|
||||
const at = world.getState().timeMs;
|
||||
const marks = world.coverage()?.marks ?? [];
|
||||
const times = frames
|
||||
.map((time) => Date.parse(time))
|
||||
.filter(Number.isFinite)
|
||||
.sort((a, b) => a - b);
|
||||
const to =
|
||||
step < 0
|
||||
? marks.findLast((mark) => mark < at)
|
||||
: marks.find((mark) => mark > at);
|
||||
? times.findLast((frame) => frame < at)
|
||||
: times.find((frame) => frame > at);
|
||||
if (to === undefined) return;
|
||||
world.pause();
|
||||
world.seek(to);
|
||||
@@ -485,8 +489,15 @@ export function createWeatherLayer({
|
||||
});
|
||||
}
|
||||
// Time is the world's: these move the world clock as its timeline
|
||||
// does, and every layer that follows it moves along.
|
||||
if (enabled) moveWorldTime(clock.world, params);
|
||||
// does, and every layer that follows it moves along. A step goes
|
||||
// through every shown observation's frames, and this row's own even
|
||||
// while it is suspended.
|
||||
if (enabled)
|
||||
moveWorldTime(
|
||||
clock.world,
|
||||
[...clock.getTimeline(), ...(manifest?.times ?? [])],
|
||||
params,
|
||||
);
|
||||
notify();
|
||||
},
|
||||
getParams() {
|
||||
|
||||
@@ -678,8 +678,12 @@ test('without a clock the layer keeps one of its own on the world clock and lets
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
assert.equal(worldClock.follows('weather-radar'), true);
|
||||
for (const time of times)
|
||||
assert.ok(worldClock.coverage().marks.includes(Date.parse(time)));
|
||||
// The frames span the timeline's time; they are not marks on it.
|
||||
assert.deepEqual(worldClock.coverage(), {
|
||||
start: Date.parse(times[0]),
|
||||
end: Date.parse(times.at(-1)),
|
||||
marks: [],
|
||||
});
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.equal(worldClock.getState().stepping, false);
|
||||
@@ -702,7 +706,7 @@ test('without a clock the layer keeps one of its own on the world clock and lets
|
||||
assert.ok(h.clears() >= 1);
|
||||
});
|
||||
|
||||
test('reduced motion offers no play; steps still move the world clock from mark to mark', async () => {
|
||||
test('reduced motion offers no play; steps still move the world clock from frame to frame', async () => {
|
||||
const h = layerHarness({ reducedMotion: true });
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
@@ -712,8 +716,8 @@ test('reduced motion offers no play; steps still move the world clock from mark
|
||||
h.layer.getRowControls().chips.some((chip) => chip.id === 'play'),
|
||||
false,
|
||||
);
|
||||
// As the timeline's arrow keys do, a step back from live goes to the
|
||||
// newest frame, and the next one back to the frame before it.
|
||||
// A step back from live goes to the newest frame, and the next one back
|
||||
// to the frame before it.
|
||||
h.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(worldClock.now(), Date.parse(times[2]));
|
||||
@@ -742,7 +746,7 @@ test('a row steps forward and plays from a past time through the world clock', a
|
||||
assert.equal(
|
||||
worldClock.now(),
|
||||
Date.parse(times[2]),
|
||||
'no mark after the newest frame',
|
||||
'no frame after the newest',
|
||||
);
|
||||
worldClock.seek(Date.parse(times[1]));
|
||||
await flush();
|
||||
@@ -1866,8 +1870,8 @@ test('a row steps the world clock through every registered observation; missing
|
||||
.chips.filter(({ id }) =>
|
||||
['previous', 'play', 'next', 'latest'].includes(id),
|
||||
);
|
||||
// As the timeline's arrow keys do, a step back from live goes to the
|
||||
// newest frame, and the next one back to the frame before it.
|
||||
// A step back from live goes to the newest frame, and the next one back
|
||||
// to the frame before it.
|
||||
radar.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(clock.getState().target, times[2]);
|
||||
|
||||
Reference in new issue
Block a user