mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 02:14:01 +00:00
fix(awareness): show a 999.6 m contact as 1.0 km, not 1000 m (#1387)
Choose awareness distance units after rounding so nearby contacts never display as 1000 metres. Contribution by @rudycelekli.
This commit is contained in:
4 files changed
+19
-3
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
- Show a Contacts entry 999.5 m or more away as 1.0 km. The panel kept meters
|
||||||
|
below 1000, then rounded 999.6 m up to "1000 m"
|
||||||
|
(Rudy Celekli, @rudycelekli, #1387).
|
||||||
@@ -4370,6 +4370,9 @@ silent for five minutes are removed. Credits appear when the feed is used.
|
|||||||
coordinator, but it is not a user-visible Data Layers entry. Its visible entry
|
coordinator, but it is not a user-visible Data Layers entry. Its visible entry
|
||||||
point is the right-side `CONTEXT` chooser's `CONTACTS` mode.
|
point is the right-side `CONTEXT` chooser's `CONTACTS` mode.
|
||||||
|
|
||||||
|
Contacts distance labels select metres or kilometres after rounding to the
|
||||||
|
nearest metre, so a 999.5-metre contact displays as `1.0 km`, not `1000 m`.
|
||||||
|
|
||||||
At global scale, ambient Radio cluster badges are hard-opacity shared-host
|
At global scale, ambient Radio cluster badges are hard-opacity shared-host
|
||||||
entries: count/category updates and identity replacement do not run keyhole or
|
entries: count/category updates and identity replacement do not run keyhole or
|
||||||
enter/exit ramps. Shared collision, viewport rejection, allocation, and horizon
|
enter/exit ramps. Shared collision, viewport rejection, allocation, and horizon
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ import {
|
|||||||
formatAwarenessLabel,
|
formatAwarenessLabel,
|
||||||
getAwarenessNavigationTargets,
|
getAwarenessNavigationTargets,
|
||||||
} from './militaryAwarenessEngine.js';
|
} 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';
|
import { NAVIGATION_AUTHORITY_EVENT } from '../navigationPolicy.js';
|
||||||
|
|
||||||
const militaryAwarenessSource = readLayerSource(
|
const militaryAwarenessSource = readLayerSource(
|
||||||
@@ -69,6 +72,12 @@ test('Contacts labels a capped cohort as a lower bound', () => {
|
|||||||
assert.equal(formatAwarenessCount({ count: null }), '?');
|
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({
|
function installAwarenessRuntime({
|
||||||
isEnabled = () => true,
|
isEnabled = () => true,
|
||||||
isEffectivelyEnabled = isEnabled,
|
isEffectivelyEnabled = isEnabled,
|
||||||
|
|||||||
@@ -25,9 +25,10 @@ function presentAwarenessCount(summary = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** A distance as the panel shows it: 850 m, 4.6 km, 120 km, in the UI language. */
|
/** A distance as the panel shows it: 850 m, 4.6 km, 120 km, in the UI language. */
|
||||||
function presentAwarenessDistance(meters) {
|
export function presentAwarenessDistance(meters) {
|
||||||
if (!Number.isFinite(meters) || meters < 0) return '—';
|
if (!Number.isFinite(meters) || meters < 0) return '—';
|
||||||
if (meters < 1000) return formatQuantity(Math.round(meters), 'm');
|
const wholeMeters = Math.round(meters);
|
||||||
|
if (wholeMeters < 1000) return formatQuantity(wholeMeters, 'm');
|
||||||
const digits = meters < 10000 ? 1 : 0;
|
const digits = meters < 10000 ? 1 : 0;
|
||||||
return formatQuantity(meters / 1000, 'km', {
|
return formatQuantity(meters / 1000, 'km', {
|
||||||
minimumFractionDigits: digits,
|
minimumFractionDigits: digits,
|
||||||
|
|||||||
Reference in new issue
Block a user