mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
feat(vessels): key vessels by their source's stable id, and share a selected vessel
AIS Vessels are keyed by the id their live source gives, with the MMSI as an attribute: an MMSI can be shared, spoofed or reused, so two vessels with one MMSI are now two vessels. Looking a vessel up or selecting it by MMSI still finds it. A share link made while a vessel is selected opens that vessel. A UUID vessel id travels as 16 bytes in a new thing field (13). A shared thing that is not reporting now says so in a sentence per kind, with its id (ICAO, NORAD, MMSI or vessel UUID) on a second line.
This commit is contained in:
1 parent
57ff81f723
commit
cbbf55cacd
74 files changed
+2481
-586
No files matched your search
@@ -279,6 +279,13 @@ export function createSnapshotTimeline({
|
||||
} else keepUp(timeMs, state);
|
||||
}
|
||||
|
||||
/** Load the time shown afresh. */
|
||||
function reloadShown() {
|
||||
if (!started || clock.isLive()) return;
|
||||
failedUntil = -Infinity;
|
||||
jumpTo(clock.getState().timeMs);
|
||||
}
|
||||
|
||||
return {
|
||||
/** The source's timeline while the layer follows the clock, else null. */
|
||||
get timeline() {
|
||||
@@ -304,16 +311,17 @@ export function createSnapshotTimeline({
|
||||
clock.register({ id, coverage: () => span() }),
|
||||
clock.subscribe(follow),
|
||||
];
|
||||
const unsubscribe = timeline.subscribe?.(() => clock.coverageChanged());
|
||||
// A source tells of new coverage, or of a better answer for times it
|
||||
// has answered; paused, a time already shown is loaded again.
|
||||
const unsubscribe = timeline.subscribe?.(() => {
|
||||
clock.coverageChanged();
|
||||
if (!clock.isPlaying() && lead !== null && !inflight) reloadShown();
|
||||
});
|
||||
if (typeof unsubscribe === 'function') releases.push(unsubscribe);
|
||||
follow(clock.getState());
|
||||
},
|
||||
/** Load the time shown afresh, as when the area the layer asks for moved. */
|
||||
reload() {
|
||||
if (!started || clock.isLive()) return;
|
||||
failedUntil = -Infinity;
|
||||
jumpTo(clock.getState().timeMs);
|
||||
},
|
||||
reload: () => reloadShown(),
|
||||
/** The layer is off: stop following and drop what loads. */
|
||||
stop() {
|
||||
if (!started) return;
|
||||
|
||||
@@ -302,3 +302,35 @@ test('a layer never has two loads out: the older is aborted before a newer start
|
||||
h.follower.stop();
|
||||
assert.equal(live(), 0);
|
||||
});
|
||||
|
||||
test('a source that tells of a better answer has the paused time loaded again, not a playing one', async () => {
|
||||
const h = harness();
|
||||
h.follower.start();
|
||||
const at = WALL - 600_000;
|
||||
h.clock.seek(at);
|
||||
await flush();
|
||||
await h.answer();
|
||||
const before = loads(h.calls).length;
|
||||
for (const listener of h.coverageListeners) listener();
|
||||
await flush();
|
||||
assert.equal(loads(h.calls).length, before + 1);
|
||||
assert.equal(loads(h.calls).at(-1).atMs, at);
|
||||
await h.answer(h.pending.length - 1);
|
||||
h.clock.play();
|
||||
const playing = loads(h.calls).length;
|
||||
for (const listener of h.coverageListeners) listener();
|
||||
await flush();
|
||||
assert.ok(
|
||||
loads(h.calls)
|
||||
.slice(playing)
|
||||
.every((call) => call.atMs !== at),
|
||||
'playing, the time shown is not loaded again',
|
||||
);
|
||||
h.clock.goLive();
|
||||
await flush();
|
||||
const live = loads(h.calls).length;
|
||||
for (const listener of h.coverageListeners) listener();
|
||||
await flush();
|
||||
assert.equal(loads(h.calls).length, live, 'live, nothing is loaded');
|
||||
h.follower.stop();
|
||||
});
|
||||
Reference in new issue
Block a user