mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
Merge pull request #1432 from Rohilalala/fix/b-vessel-course-north
fix(vessels): show a 359.7° course as 0°, not 360°
This commit is contained in:
4 files changed
+33
-4
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
- Show a vessel course of 359.5° or more as 0°. Vessel cards and the AIS HUD
|
||||||
|
rounded the course without wrapping, so a ship with no reported heading on
|
||||||
|
a 359.7° course read "360°" and "HDG: 360DEG" (Aditya, @Rohilalala, #1432).
|
||||||
@@ -557,7 +557,9 @@ those reports arrive as 102.3 knots and 360 degrees. Both are stored as unknown,
|
|||||||
and vessel cards, the HUD and analyst queries show a missing measurement rather
|
and vessel cards, the HUD and analyst queries show a missing measurement rather
|
||||||
than a reading. Heading keeps its existing separate check for its own sentinel.
|
than a reading. Heading keeps its existing separate check for its own sentinel.
|
||||||
Genuine readings are unchanged, including a stopped vessel's zero and the
|
Genuine readings are unchanged, including a stopped vessel's zero and the
|
||||||
highest speed and course the fields can encode.
|
highest speed and course the fields can encode. Vessel cards and the HUD wrap
|
||||||
|
the direction after rounding to whole degrees, so a course of 359.5° or more
|
||||||
|
reads `0°` (`0DEG` in the HUD) rather than `360°`.
|
||||||
|
|
||||||
For an already tracked vessel, AISStream static messages update name, type,
|
For an already tracked vessel, AISStream static messages update name, type,
|
||||||
destination and IMO without changing its position, motion, fix timestamps,
|
destination and IMO without changing its position, motion, fix timestamps,
|
||||||
|
|||||||
@@ -1321,6 +1321,27 @@ test('buildVesselCard: heading falls back to course; missing parts are omitted',
|
|||||||
assert.deepEqual(bare.details, []);
|
assert.deepEqual(bare.details, []);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('vessel cards read a course that rounds to north as 0°, not 360°', () => {
|
||||||
|
const card = (course) => buildVesselCard(makeRecord({ heading: null, course })).details[0];
|
||||||
|
assert.equal(card(359.4), 'CONTAINER SHIP · 14.5KT · 359°');
|
||||||
|
assert.equal(card(359.7), 'CONTAINER SHIP · 14.5KT · 0°');
|
||||||
|
assert.equal(
|
||||||
|
buildSelectedVesselCard(makeRecord({ heading: null, course: 359.7 })).details[0],
|
||||||
|
'CONTAINER SHIP · 14.5KT · 0°',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the vessel HUD reads a course that rounds to north as HDG 0DEG', () => {
|
||||||
|
const harness = installWireHarness(undefined, { selectedRecord: null });
|
||||||
|
try {
|
||||||
|
Object.assign(harness.record, { heading: null, course: 359.7 });
|
||||||
|
assert.equal(aisLiveVesselsLayer.selectById(harness.record.mmsi), true);
|
||||||
|
assert.match(harness.hud.readout.text, /HDG: 0DEG/);
|
||||||
|
} finally {
|
||||||
|
harness.cleanup();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('buildVesselCard: unnamed vessels title as MMSI; long names truncate', () => {
|
test('buildVesselCard: unnamed vessels title as MMSI; long names truncate', () => {
|
||||||
const unnamed = buildVesselCard(makeRecord({ name: 'VESSEL' }));
|
const unnamed = buildVesselCard(makeRecord({ name: 'VESSEL' }));
|
||||||
assert.equal(unnamed.title, 'MMSI 353136000');
|
assert.equal(unnamed.title, 'MMSI 353136000');
|
||||||
|
|||||||
@@ -55,7 +55,10 @@ export function createCards({
|
|||||||
if (record.speed !== null && record.speed !== undefined)
|
if (record.speed !== null && record.speed !== undefined)
|
||||||
parts.push(formatSpeed(record.speed));
|
parts.push(formatSpeed(record.speed));
|
||||||
const direction = record.heading ?? record.course;
|
const direction = record.heading ?? record.course;
|
||||||
if (Number.isFinite(direction)) parts.push(`${Math.round(direction)}°`);
|
// A course of 359.5° and above rounds to north; modulo keeps it from
|
||||||
|
// printing 360°. The selected card and the HUD wrap the same way.
|
||||||
|
if (Number.isFinite(direction))
|
||||||
|
parts.push(`${Math.round(direction) % 360}°`);
|
||||||
return {
|
return {
|
||||||
id: vesselOverlayEntryId(record),
|
id: vesselOverlayEntryId(record),
|
||||||
actionable: Boolean(record?.mmsi),
|
actionable: Boolean(record?.mmsi),
|
||||||
@@ -86,7 +89,7 @@ export function createCards({
|
|||||||
[
|
[
|
||||||
vesselTypeShort(record) || t('VESSEL'),
|
vesselTypeShort(record) || t('VESSEL'),
|
||||||
formatSpeed(record.speed),
|
formatSpeed(record.speed),
|
||||||
Number.isFinite(direction) ? `${Math.round(direction)}°` : '--°',
|
Number.isFinite(direction) ? `${Math.round(direction) % 360}°` : '--°',
|
||||||
].join(' · '),
|
].join(' · '),
|
||||||
];
|
];
|
||||||
const destination = String(record.destination || '').trim();
|
const destination = String(record.destination || '').trim();
|
||||||
@@ -176,7 +179,7 @@ export function createCards({
|
|||||||
|
|
||||||
function formatHeading(heading) {
|
function formatHeading(heading) {
|
||||||
return t('{heading}DEG', {
|
return t('{heading}DEG', {
|
||||||
heading: Number.isFinite(heading) ? Math.round(heading) : '--',
|
heading: Number.isFinite(heading) ? Math.round(heading) % 360 : '--',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user