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

+2 -4
View File
@@ -13,7 +13,6 @@ import ContextView from './views/ContextView.vue';
import * as Cesium from 'cesium';
import { vesselCockpitInfo } from '../layers/vessels/cockpitSubject.js';
import { VesselRecords } from '../layers/vessels/records.js';
import { RADAR_REACH_M } from '../cockpitRadar.js';
const RECORD = Object.freeze({
mmsi: '211000000',
@@ -328,8 +327,7 @@ test('the bridge radar shows nearby ships without its own and steps its range',
assert.ok(neighbour.x < -0.3 && Math.abs(neighbour.y) < 0.02);
assert.equal(neighbour.relativeCourseDeg, -180);
assert.equal(radar.ownRelativeCourseDeg, 5, 'COG 095 from heading 090');
// Past the range by the dead-reckoning reach, for ships moving into it.
assert.equal(vessels.radarQueries.at(-1).rangeM, 3 * 1852 + RADAR_REACH_M);
assert.equal(vessels.radarQueries.at(-1).rangeM, 3 * 1852);
assert.equal($('#cockpit-radar').hidden, false);
assert.equal($('#cockpit-radar-range').textContent.trim(), '3 NM');
@@ -339,7 +337,7 @@ test('the bridge radar shows nearby ships without its own and steps its range',
$('#cockpit-radar-range').click();
await settle();
assert.equal(store.radar.rangeNm, 6);
assert.equal(vessels.radarQueries.at(-1).rangeM, 6 * 1852 + RADAR_REACH_M);
assert.equal(vessels.radarQueries.at(-1).rangeM, 6 * 1852);
assert.equal($('#cockpit-radar-range').textContent.trim(), '6 NM');
assert.match(
$('#cockpit-radar-range').getAttribute('aria-label'),
+8 -14
View File
@@ -37,8 +37,6 @@ import {
import { lookIsOffset, lookReadoutParts, wrapLookYaw } from '../cockpitLook.js';
import {
RADAR_MAX_CONTACTS,
RADAR_REACH_M,
deadReckonRadarContacts,
radarPicture,
radarRangeM,
radarRangeNm,
@@ -345,8 +343,9 @@ function updateVesselHud(info, nowMs, forceContext) {
/**
* Publish the bridge radar: nearby AIS vessels drawn heading-up from the
* camera's current heading, within the chosen range. Own ship sits where
* the camera rides (its fix dead-reckoned), and every contact is
* dead-reckoned to the same moment, so the picture matches the window.
* the camera rides (its fix dead-reckoned); contacts sit at their last
* fixes, where the vessel layer draws them, so the scope matches the
* window.
* @param {object} info The vessel subject (`readVesselInfo`).
*/
export function updateRadar(info) {
@@ -357,16 +356,11 @@ export function updateRadar(info) {
}
const rangeNm = radarRangeNm(this.radarRangeNm);
const own = this.vesselFix ?? info;
// Ask past the range for ships that have since moved into it; the picture
// trims them to the range once they are dead-reckoned.
const contacts = deadReckonRadarContacts(
layer.getRadarContacts(
own.latitude,
own.longitude,
radarRangeM(rangeNm) + RADAR_REACH_M,
RADAR_MAX_CONTACTS * 4,
),
Date.now(),
const contacts = layer.getRadarContacts(
own.latitude,
own.longitude,
radarRangeM(rangeNm),
RADAR_MAX_CONTACTS,
);
const picture = radarPicture(
{