fix(cctv): show a camera facing 359.6° as HDG 0°, not HDG 360°

The CCTV HUD heading token and the camera panel's meta line rounded the
bearing without wrapping, so a camera facing 359.5° or more (a feed
bearing, or a heading calibrated just west of north) read "HDG 360°".
Both now wrap after rounding: 359.6° reads "HDG 0°", 359.4° "HDG 359°".
This commit is contained in:
Aditya committed 2026-10-28 15:06:07 +05:30
1 parent a4d3701c3c
commit 940050d4e5
5 files changed
+39 -3

No files matched your search

+2 -1
View File
@@ -44,7 +44,8 @@ export function isHeadingEstimated(camera) {
* @returns {string}
*/
export function headingHudToken(camera) {
const hdg = Math.round(Number(camera?.headingDeg) || 0);
// 359.5° and above rounds to north; modulo keeps it from printing 360°.
const hdg = Math.round(Number(camera?.headingDeg) || 0) % 360;
return isHeadingEstimated(camera)
? t('HDG {value}° (ESTIMATED)', { value: hdg })
: t('HDG {value}°', { value: hdg });
@@ -44,6 +44,15 @@ test('HUD token tags a synthetic bearing and rounds the degrees', () => {
);
});
test('HUD token reads a bearing that rounds to north as 0°, not 360°', () => {
assert.equal(headingHudToken({ headingDeg: 359.4 }), 'HDG 359°');
assert.equal(headingHudToken({ headingDeg: 359.6 }), 'HDG 0°');
assert.equal(
headingHudToken({ headingDeg: 359.5, headingConfidence: 'low' }),
'HDG 0° (ESTIMATED)',
);
});
test('HUD token stays untagged for surveyed and calibrated bearings', () => {
assert.equal(
headingHudToken({ headingDeg: 67.5, headingConfidence: 'high' }),