fix(cockpit): radar contacts stay where the vessel layer draws them

The vessel layer draws other ships at their last AIS fix and does not
advance them, so dead-reckoning radar contacts moved the mismatch from own
ship to everyone else: a 15 kn ferry reported 90 s ago showed ~700 m ahead
of the ship out of the window. Own ship stays centred where the camera
rides; contacts go back to their last fixes, and the query drops the extra
reach and candidates (which could also cut the nearest ship in a crowd).
This commit is contained in:
Sameh Khamis committed 2026-11-08 14:09:17 -08:00
1 parent 0ba7ba6512
commit f96a89a9ef
7 files changed
+27 -114

No files matched your search

-20
View File
@@ -7,7 +7,6 @@ import {
METRES_PER_NM,
RADAR_MAX_CONTACTS,
RADAR_RANGES_NM,
deadReckonRadarContacts,
nextRadarRange,
projectRadarContacts,
radarPicture,
@@ -97,25 +96,6 @@ 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,