From b7e00f18a4b1ef2f92fdd17fd4418b72f250aae0 Mon Sep 17 00:00:00 2001 From: Rudy Celekli Date: Sun, 25 Oct 2026 11:32:15 -0400 Subject: [PATCH 1/4] fix(directions): show a 996 m leg as 1.0 km, not 1000 m routeDistanceText checked the raw meters against 1000 but printed them rounded to tens, so 995 m or more read "1000 m". Compare the rounded value so it moves to kilometres. --- changelog.d/1386-route-distance-kilometre.md | 3 +++ src/data/directions.test.mjs | 2 ++ src/layers/directions/index.js | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog.d/1386-route-distance-kilometre.md diff --git a/changelog.d/1386-route-distance-kilometre.md b/changelog.d/1386-route-distance-kilometre.md new file mode 100644 index 000000000..0a60fcc62 --- /dev/null +++ b/changelog.d/1386-route-distance-kilometre.md @@ -0,0 +1,3 @@ +- Show a route leg of 995 m or more as 1.0 km. The route summary and step + cards kept meters below 1000, then rounded 996 m up to "1000 m" + (Rudy Celekli, @rudycelekli, #1386). diff --git a/src/data/directions.test.mjs b/src/data/directions.test.mjs index 4c9b54bd8..187f1a8d0 100644 --- a/src/data/directions.test.mjs +++ b/src/data/directions.test.mjs @@ -846,6 +846,8 @@ test('route numbers follow the page language and never break from their unit', ( t.after(() => setLocale('en')); assert.equal(routeDistanceText(8.4), '8\u00a0m'); assert.equal(routeDistanceText(236), '240\u00a0m'); + assert.equal(routeDistanceText(994), '990\u00a0m'); + assert.equal(routeDistanceText(996), '1.0\u00a0km'); assert.equal(routeDistanceText(1500), '1.5\u00a0km'); assert.equal(routeDistanceText(2_345_000), '2345\u00a0km'); assert.equal(routeDurationText(39), '39\u00a0s'); diff --git a/src/layers/directions/index.js b/src/layers/directions/index.js index 2b8f8875e..95e4cf258 100644 --- a/src/layers/directions/index.js +++ b/src/layers/directions/index.js @@ -112,7 +112,8 @@ export const FLIGHT_PROGRESS_MS = 250; export function routeDistanceText(meters) { if (!Number.isFinite(meters) || meters < 0) return ''; if (meters < 100) return formatQuantity(Math.round(meters), 'm'); - if (meters < 1000) return formatQuantity(Math.round(meters / 10) * 10, 'm'); + const tens = Math.round(meters / 10) * 10; + if (tens < 1000) return formatQuantity(tens, 'm'); const km = meters / 1000; return km < 10 ? formatQuantity(km, 'km', { From d6ae581652effa0c207992ceaf57c68bf673b6e2 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sun, 25 Oct 2026 08:48:30 -0700 Subject: [PATCH 2/4] docs: document PR #1386 rounding behavior --- docs/CURRENT-STATE.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index be09e5664..7543cb4f0 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -4081,6 +4081,9 @@ routing it shows `Routing…`, and a router miss reads The layer holds continuous render only while a route is drawn (the dashes animate). Disable clears all state. +Route distance labels round to the nearest ten metres before selecting the +unit, so 995 metres and above display as `1.0 km` rather than `1000 m`. + **Keys needed: none.** Directions works on a keyless boot, and the layer is off until the operator turns it on. From 455dbf2b5f56932782bdb2b07ec435fabec9b559 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sun, 25 Oct 2026 08:49:00 -0700 Subject: [PATCH 3/4] docs: clarify unit transition examples --- docs/CURRENT-STATE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 7543cb4f0..f171806e0 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -4082,7 +4082,8 @@ The layer holds continuous render only while a route is drawn (the dashes animate). Disable clears all state. Route distance labels round to the nearest ten metres before selecting the -unit, so 995 metres and above display as `1.0 km` rather than `1000 m`. +unit, switching to kilometres at 995 metres; a 996-metre leg displays as +`1.0 km` rather than `1000 m`. **Keys needed: none.** Directions works on a keyless boot, and the layer is off until the operator turns it on. From 48e649a95e57a9ae6d4f02dd89b16c0237b2e0e6 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sun, 25 Oct 2026 08:50:11 -0700 Subject: [PATCH 4/4] docs(directions): scope the distance rounding threshold precisely --- docs/CURRENT-STATE.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index f171806e0..87fadd8a7 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -4081,9 +4081,9 @@ routing it shows `Routing…`, and a router miss reads The layer holds continuous render only while a route is drawn (the dashes animate). Disable clears all state. -Route distance labels round to the nearest ten metres before selecting the -unit, switching to kilometres at 995 metres; a 996-metre leg displays as -`1.0 km` rather than `1000 m`. +At the metre/kilometre boundary, route distance labels use the rounded +ten-metre value to select the unit, switching to kilometres at 995 metres; +a 996-metre leg displays as `1.0 km` rather than `1000 m`. **Keys needed: none.** Directions works on a keyless boot, and the layer is off until the operator turns it on.