mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 02:14:01 +00:00
Merge pull request #1450 from Rohilalala/fix/e-route-distance-ten-km
fix(directions): show a 9.96 km route as 10 km, not 10.0 km
This commit is contained in:
4 files changed
+10
-2
No files matched your search
@@ -0,0 +1,3 @@
|
||||
- Show a route of 9.95 km or more as 10 km. The Directions row and step
|
||||
cards kept one decimal until the raw distance reached 10 km, so 9.96 km
|
||||
read "10.0 km" (Aditya, @Rohilalala, #1450).
|
||||
@@ -4317,7 +4317,9 @@ animate). Disable clears all state.
|
||||
|
||||
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`.
|
||||
a 996-metre leg displays as `1.0 km` rather than `1000 m`. Whole kilometres
|
||||
start where the label would round to 10.0 km, so a 9.96 km route displays as
|
||||
`10 km` rather than `10.0 km`.
|
||||
|
||||
**Keys needed: none.** Directions works on a keyless boot, and the layer is off
|
||||
until the operator turns it on.
|
||||
|
||||
@@ -849,6 +849,8 @@ test('route numbers follow the page language and never break from their unit', (
|
||||
assert.equal(routeDistanceText(994), '990\u00a0m');
|
||||
assert.equal(routeDistanceText(996), '1.0\u00a0km');
|
||||
assert.equal(routeDistanceText(1500), '1.5\u00a0km');
|
||||
assert.equal(routeDistanceText(9940), '9.9\u00a0km');
|
||||
assert.equal(routeDistanceText(9960), '10\u00a0km');
|
||||
assert.equal(routeDistanceText(2_345_000), '2345\u00a0km');
|
||||
assert.equal(routeDurationText(39), '39\u00a0s');
|
||||
assert.equal(routeDurationText(59.4), '59\u00a0s');
|
||||
|
||||
@@ -113,7 +113,8 @@ export function routeDistanceText(meters) {
|
||||
const tens = Math.round(meters / 10) * 10;
|
||||
if (tens < 1000) return formatQuantity(tens, 'm');
|
||||
const km = meters / 1000;
|
||||
return km < 10
|
||||
// Pick the unit from the tenth it prints: 9.96 km read "10.0 km".
|
||||
return Math.round(meters / 100) < 100
|
||||
? formatQuantity(km, 'km', {
|
||||
minimumFractionDigits: 1,
|
||||
maximumFractionDigits: 1,
|
||||
|
||||
Reference in new issue
Block a user