mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
Timeline marks carry labels; a tap by a tick goes to its mark
A layer's world clock coverage may now give each mark as an object,
{ time, label?, id?, kind? }, as well as a bare epoch ms number, and the
two may be mixed. worldClock.coverage() keeps marks as the sorted list of
distinct times, so existing readers are unchanged, and adds markDetails:
the merged marks in time order (then kind, label and id), each frozen and
holding only the fields given. Marks given alike by several sources appear
once, a bare time is dropped where a labelled mark shares it, and a mark
with no finite time is ignored. The contract is documented in the
worldClock JSDoc and docs/APPLICATION.md.
Launches label their marks with the mission's name (the launch's where it
has none), cut to 27 characters in capitals as the mission index shows
names. Earthquakes of magnitude 6 and up label theirs with the magnitude
as the map shows it and the feed's place cut to 40 characters, such as
"M6.4 · 113 km SSE of Lata, Solomon Islands"; the layer now tells the clock
when the labels change as well as the times.
On the timeline, a pointer within 6 px of a tick shows its label over the
track (nothing for an unlabelled mark), and a tap there goes exactly to
the mark's time instead of the point tapped. A tap elsewhere and a drag
work as before, and ticks stay ticks. The arrow keys still step from mark
to mark; with the handle on a mark, its labels follow the time in the
handle's aria-valuetext, and show over the track while it has focus.
This commit is contained in:
1 parent
7cb854c923
commit
558e4a919a
17 files changed
+490
-50
No files matched your search
@@ -2,7 +2,7 @@ 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 { EARTHQUAKE_MARK_MAGNITUDE, earthquakeMarkLabel } from './model.js';
|
||||
import { worldClock } from '../../time/worldClock.js';
|
||||
function harness(source) {
|
||||
const sources = [];
|
||||
@@ -94,8 +94,15 @@ 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: 'strong', usgsId: 'us-strong', mag: 6, time: 5_000 },
|
||||
{
|
||||
...row,
|
||||
stableId: 'great',
|
||||
usgsId: 'us-great',
|
||||
mag: 7.2,
|
||||
place: ' 113 km SSE of Lata, Solomon Islands region of the Pacific ',
|
||||
time: 3_000,
|
||||
},
|
||||
{ ...row, stableId: 'untimed', mag: 6.5, time: null },
|
||||
];
|
||||
let snapshot = rows;
|
||||
@@ -106,10 +113,25 @@ test('the timeline marks only strong quakes, while the layer is on', async () =>
|
||||
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);
|
||||
// Each labelled with its magnitude and, cut short, its place.
|
||||
assert.deepEqual(worldClock.coverage(), {
|
||||
start: 3_000,
|
||||
end: 5_000,
|
||||
marks: [3_000, 5_000],
|
||||
markDetails: [
|
||||
{
|
||||
time: 3_000,
|
||||
label: 'M7.2 · 113 km SSE of Lata, Solomon Islands reg…',
|
||||
id: 'us-great',
|
||||
kind: 'earthquake',
|
||||
},
|
||||
{
|
||||
time: 5_000,
|
||||
label: 'M6.0 · Fixture',
|
||||
id: 'us-strong',
|
||||
kind: 'earthquake',
|
||||
},
|
||||
],
|
||||
});
|
||||
const told = changes;
|
||||
await h.layer.update(h.viewer);
|
||||
@@ -127,3 +149,12 @@ test('the timeline marks only strong quakes, while the layer is on', async () =>
|
||||
assert.equal(worldClock.coverage(), null);
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
test('a strong quake with no place is labelled with its magnitude alone', () => {
|
||||
assert.equal(earthquakeMarkLabel({ mag: 6.44, place: null }), 'M6.4');
|
||||
assert.equal(earthquakeMarkLabel({ mag: 6, place: ' ' }), 'M6.0');
|
||||
assert.equal(
|
||||
earthquakeMarkLabel({ mag: 8.1, place: 'Off the coast' }),
|
||||
'M8.1 · Off the coast',
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user