diff --git a/tasks/enduro-trails/prototype/static/app.js b/tasks/enduro-trails/prototype/static/app.js index 55ad66a..7343454 100644 --- a/tasks/enduro-trails/prototype/static/app.js +++ b/tasks/enduro-trails/prototype/static/app.js @@ -593,6 +593,13 @@ function getRouteSegmentDistances() { segDists.push(dist); } + // Scale so sum of segments == route.distance_m exactly + const rawTotal = segDists.slice(1).reduce((a, b) => a + b, 0); + if (rawTotal > 0 && route.distance_m > 0) { + const scale = route.distance_m / rawTotal; + for (let i = 1; i < segDists.length; i++) segDists[i] = Math.round(segDists[i] * scale); + } + return segDists; } @@ -930,7 +937,7 @@ function renderRouteCards(routes) { const container = document.getElementById('route-cards'); container.innerHTML = routes.map((route, i) => { const color = ROUTE_COLORS[i] || '#888888'; - const distKm = (route.distance_m / 1000).toFixed(0); + const distKm = (route.distance_m / 1000).toFixed(1); const timeStr = formatDuration(route.duration_s); const isActive = i === activeRouteIdx; const s = route.stats || {}; @@ -1917,7 +1924,7 @@ function hideMiniRouteSheet() { function updateMiniRouteCard() { const r = routeResults[activeRouteIdx]; if (!r) return; - const km = (r.distance_m / 1000).toFixed(0); + const km = (r.distance_m / 1000).toFixed(1); const dirt = r.stats?.dirt_total_pct ?? '-'; document.getElementById('mini-dot').style.background = ROUTE_COLORS[activeRouteIdx % ROUTE_COLORS.length]; document.getElementById('mini-label').textContent = `Вариант ${activeRouteIdx + 1} из ${routeResults.length}`;