mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
feat(flights): a tracked flight's trail splits at gaps, follows the drawn aircraft, and a lost aircraft coasts then reads SIGNAL LOST
The trail no longer joins a day of history into one line. It lifts the pen across a gap of more than 48 minutes, an implied speed over 1,500 kt, or a report without altitude (a parked aircraft within 0.1 nm for under 3 h stays joined), and every history point is kept as its own segment. History never gets an invented altitude. The live end is the path the aircraft was drawn along, thinned to its shape, so it no longer cuts corners through turns; a late report trims what was drawn after it. Old segments are frozen in chunks, so a 2,000-point trail costs about 0.1 ms a frame. A tracked aircraft that misses an update shows STALE and is dimmed. It keeps flying on its last speed and heading for five minutes (at most 1,500 kt), then stops, dimmed, labelled SIGNAL LOST with the time since its last report, and is kept for ten minutes after that report so the camera keeps its target. Aircraft on or near known ground hold at their last report instead of coasting. Military flights follow the same rules.
This commit is contained in:
1 parent
66a8ff06cb
commit
8fec5a76bf
49 files changed
+6486
-363
No files matched your search
@@ -164,3 +164,99 @@ test('a route belongs to its callsign: a new callsign drops it, a blank one keep
|
||||
assert.equal(next.meta.airline, null);
|
||||
assert.equal(next.meta.routeCallsign, null);
|
||||
});
|
||||
|
||||
test('a contact with no altitude yet is marked as drawn at an invented height; a held one is not', () => {
|
||||
const store = records();
|
||||
const none = store.receive(
|
||||
observation({ baroAltitudeM: null, ellipsoidAltitudeM: null }),
|
||||
view(),
|
||||
);
|
||||
assert.equal(none.meta.renderAltitudeInvented, true);
|
||||
const known = store.receive(
|
||||
observation({ positionTimeMs: 1700000005000 }),
|
||||
view(),
|
||||
);
|
||||
assert.equal(known.meta.renderAltitudeInvented, false);
|
||||
const held = store.receive(
|
||||
observation({
|
||||
baroAltitudeM: null,
|
||||
ellipsoidAltitudeM: null,
|
||||
positionTimeMs: 1700000010000,
|
||||
}),
|
||||
view(),
|
||||
);
|
||||
assert.equal(held.meta.renderAltitudeInvented, false);
|
||||
const parked = records().receive(
|
||||
observation({ id: 'abc124', baroAltitudeM: null, onGround: true }),
|
||||
view(),
|
||||
);
|
||||
assert.equal(parked.meta.renderAltitudeInvented, false);
|
||||
});
|
||||
|
||||
test('the tracked contact is stale from its first missed update and kept until ten minutes after its newest fix', () => {
|
||||
const realNow = Date.now;
|
||||
const fixMs = Date.UTC(2026, 10, 9, 20, 0);
|
||||
let clock = fixMs + 5_000;
|
||||
Date.now = () => clock;
|
||||
try {
|
||||
for (const snapshot of [
|
||||
{ complete: true },
|
||||
{ complete: true, retainIds: new Set(['abc123']) },
|
||||
{ complete: false },
|
||||
]) {
|
||||
const store = records();
|
||||
store.receive(observation({ positionTimeMs: fixMs }), view());
|
||||
const absent = (tracked) =>
|
||||
store.absence('abc123', { ...snapshot, likelyLanded: false, tracked });
|
||||
clock = fixMs + 15_000;
|
||||
assert.equal(absent(true), 'stale');
|
||||
assert.equal(store.missingPolls.get('abc123'), 1);
|
||||
// Kept long after the untracked limits, measured from the fix time.
|
||||
clock = fixMs + 9 * 60_000;
|
||||
assert.equal(absent(true), 'stale');
|
||||
clock = fixMs + 10 * 60_000 - 1;
|
||||
assert.equal(absent(true), 'stale');
|
||||
clock = fixMs + 10 * 60_000;
|
||||
assert.equal(absent(true), 'remove');
|
||||
assert.equal(store.missingPolls.has('abc123'), false);
|
||||
}
|
||||
// Untracked contacts keep their own limits.
|
||||
const store = records();
|
||||
store.receive(observation({ positionTimeMs: fixMs }), view());
|
||||
clock = fixMs + 15_000;
|
||||
const untracked = (snapshot) =>
|
||||
store.absence('abc123', { ...snapshot, likelyLanded: false });
|
||||
assert.equal(untracked({ complete: false }), 'retain');
|
||||
assert.deepEqual(
|
||||
[1, 2, 3].map(() => untracked({ complete: true })),
|
||||
['stale', 'stale', 'remove'],
|
||||
);
|
||||
} finally {
|
||||
Date.now = realNow;
|
||||
}
|
||||
});
|
||||
|
||||
test('a repeated fix time marks the contact as not updated; removal is unchanged', () => {
|
||||
const store = records();
|
||||
const fixMs = Date.UTC(2026, 10, 9, 20, 0);
|
||||
store.beginSnapshot(fixMs + 2_000);
|
||||
store.receive(observation({ positionTimeMs: fixMs }), view());
|
||||
assert.equal(store.fixRepeated.has('abc123'), false);
|
||||
// The next poll re-sends the same position.
|
||||
store.beginSnapshot(fixMs + 12_000);
|
||||
store.receive(observation({ positionTimeMs: fixMs }), view());
|
||||
assert.equal(store.fixRepeated.has('abc123'), true);
|
||||
assert.equal(store.missingPolls.has('abc123'), false);
|
||||
// The same snapshot read again is not a missed update.
|
||||
store.beginSnapshot(fixMs + 12_000);
|
||||
store.receive(observation({ positionTimeMs: fixMs }), view());
|
||||
assert.equal(store.fixRepeated.has('abc123'), true);
|
||||
// A newer fix clears it.
|
||||
store.beginSnapshot(fixMs + 22_000);
|
||||
store.receive(observation({ positionTimeMs: fixMs + 10_000 }), view());
|
||||
assert.equal(store.fixRepeated.has('abc123'), false);
|
||||
store.beginSnapshot(fixMs + 32_000);
|
||||
store.receive(observation({ positionTimeMs: fixMs + 10_000 }), view());
|
||||
store.forget('abc123');
|
||||
assert.equal(store.fixRepeated.has('abc123'), false);
|
||||
});
|
||||
Reference in new issue
Block a user