mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
fix(awareness): show a 999.6 m contact marker as 1.0 km, not 1000 m
The on-globe Contacts markers picked metres before rounding, so a contact 999.5 m or more away read "1000 m" while the Contacts panel read "1.0 km". The marker label now rounds first, as the panel does.
This commit is contained in:
1 parent
15de9d738c
commit
83c4388e64
3 files changed
+13
-4
No files matched your search
@@ -47,8 +47,10 @@ export function findByDoublingRadius(
|
||||
/** @param {number} meters @returns {string} */
|
||||
export function formatAwarenessDistance(meters) {
|
||||
if (!Number.isFinite(meters) || meters < 0) return '—';
|
||||
return meters < 1000
|
||||
? `${Math.round(meters)} m`
|
||||
// Round before the kilometre cut. 999.6 m was printed as "1000 m".
|
||||
const wholeMeters = Math.round(meters);
|
||||
return wholeMeters < 1000
|
||||
? `${wholeMeters} m`
|
||||
: `${(meters / 1000).toFixed(meters < 10000 ? 1 : 0)} km`;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user