fix(awareness): show a 999.6 m contact as 1.0 km, not 1000 m

The Contacts panel checked the raw meters against 1000 but printed them rounded, so 999.5 m or more read "1000 m". Compare the rounded meters so the distance moves to kilometres.
This commit is contained in:
Rudy Celekli committed 2026-10-25 11:32:19 -04:00
1 parent abd81155f9
commit 6c225605c4
3 files changed
+16 -3

No files matched your search

+10 -1
View File
@@ -42,7 +42,10 @@ import {
formatAwarenessLabel,
getAwarenessNavigationTargets,
} from './militaryAwarenessEngine.js';
import { formatAwarenessCount } from '../layers/awareness/panel.js';
import {
formatAwarenessCount,
presentAwarenessDistance,
} from '../layers/awareness/panel.js';
import { NAVIGATION_AUTHORITY_EVENT } from '../navigationPolicy.js';
const militaryAwarenessSource = readLayerSource(
@@ -69,6 +72,12 @@ test('Contacts labels a capped cohort as a lower bound', () => {
assert.equal(formatAwarenessCount({ count: null }), '?');
});
test('Contacts moves a distance that rounds to 1,000 m into kilometres', () => {
assert.equal(presentAwarenessDistance(999.4), '999\u00a0m');
assert.equal(presentAwarenessDistance(999.6), '1.0\u00a0km');
assert.equal(presentAwarenessDistance(4600), '4.6\u00a0km');
});
function installAwarenessRuntime({
isEnabled = () => true,
isEffectivelyEnabled = isEnabled,