fix(cockpit): the bridge radar matches the view out of the window

The radar centred on the ship's last AIS fix while the camera rode that fix
dead-reckoned up to 180 s ahead: at 20 kn about a nautical mile apart, so a
ship already passed still showed ahead. Own ship now sits where the camera
rides and each contact is dead-reckoned to the same moment; the query reaches
past the range for ships that have since moved into it.

Ships with no MMSI each get a key of their own instead of all sharing an
empty one on the scope.
This commit is contained in:
Sameh Khamis committed 2026-11-08 14:09:17 -08:00
1 parent 18c15d0352
commit 052731202d
9 files changed
+154 -29

No files matched your search

+20
View File
@@ -7,6 +7,7 @@ import {
METRES_PER_NM,
RADAR_MAX_CONTACTS,
RADAR_RANGES_NM,
deadReckonRadarContacts,
nextRadarRange,
projectRadarContacts,
radarPicture,
@@ -96,6 +97,25 @@ test('course is drawn relative to the bow and stays null when unknown', () => {
assert.equal(drifting.relativeCourseDeg, null);
});
test('contacts are dead-reckoned along course over ground to now', () => {
const nowMs = 1_800_000_000_000;
const fixEpochMs = nowMs - 120_000;
// 12 kn due north, fix received a minute ago: ~370 m (0.2 NM) on.
const moving = contact('moving', 1, 0, {
motionCourse: 0,
velocityMps: 12 * 0.514444,
fixEpochMs,
feedEpochMs: fixEpochMs,
receivedAtMs: nowMs - 60_000,
});
const adrift = contact('adrift', 1, 0, { motionCourse: null });
const [ahead, still] = deadReckonRadarContacts([moving, adrift], nowMs);
const movedNm = (ahead.latitude - moving.latitude) / NM_LAT;
assert.ok(Math.abs(movedNm - 0.2) < 0.005, `moved ${movedNm} NM`);
assert.ok(Math.abs(ahead.longitude - moving.longitude) < 1e-9);
assert.equal(still, adrift, 'no direction, no move');
});
test('contacts beyond the range are left out', () => {
const contacts = projectRadarContacts(
OWN,