mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 18:34:02 +00:00
fix(annotations): label a 996 m line or route as 1.0 km, not 1000 m
Placed route, arrow and drawn-line labels picked metres before rounding to ten metres, so anything from 995 m to 1 km read "1000 m", even where the draw hint for the same line read "1.0 km". The label now rounds first, then picks the unit, and does the same at the 10 km cut, where 9,960 m read "10.0 km".
This commit is contained in:
1 parent
a4d3701c3c
commit
e4a964375a
3 files changed
+21
-3
No files matched your search
@@ -1573,8 +1573,11 @@ function greatCircleM(a, b) {
|
||||
|
||||
function formatDistance(m) {
|
||||
if (!Number.isFinite(m)) return null;
|
||||
if (m >= 1000) return `${(m / 1000).toFixed(m >= 10000 ? 0 : 1)} km`;
|
||||
return `${Math.round(m / 10) * 10} m`;
|
||||
// Round before each unit cut: 996 m was printed as "1000 m" and
|
||||
// 9,960 m as "10.0 km".
|
||||
const tens = Math.round(m / 10) * 10;
|
||||
if (tens < 1000) return `${tens} m`;
|
||||
return `${(m / 1000).toFixed(Math.round(m / 100) >= 100 ? 0 : 1)} km`;
|
||||
}
|
||||
|
||||
function composeRouteLabel(baseLabel, distM, durS, mode, fallback) {
|
||||
|
||||
Reference in new issue
Block a user