From 4de4991ff630d2014c93769ea83032f4536dd5cb Mon Sep 17 00:00:00 2001 From: Spythere Date: Mon, 10 Feb 2025 21:23:36 +0100 Subject: [PATCH] fix: generating arrival km --- src/components/Timetable/TrainTimetable.vue | 29 ++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/components/Timetable/TrainTimetable.vue b/src/components/Timetable/TrainTimetable.vue index 6db7ce7..0992660 100644 --- a/src/components/Timetable/TrainTimetable.vue +++ b/src/components/Timetable/TrainTimetable.vue @@ -89,9 +89,10 @@ const computedTimetableRows = computed(() => { for (const stop of stopList) { if (stop.arrivalLine && stop.arrivalLine == currentPath.arrivalLine) { - console.log('arrivalKm', arrivalKm, stop.stopDistance); + console.log('arrivalKm', arrivalKm); + console.log('stopDistance', stop.stopDistance); - if (arrivalKm >= stop.stopDistance) arrivalKm = stop.stopDistance; + if (arrivalKm >= stop.stopDistance) arrivalKm = (Number(stopRows[stopRows.length - 1].departureKm ?? '0') + stop.stopDistance) / 2; if (currentPath.arrivalLineData) { arrivalSpeed = currentPath.arrivalLineData.routeSpeed; @@ -171,14 +172,17 @@ const computedTimetableRows = computed(() => { } if (stop.departureLine && stop.departureLine == currentPath.departureLine) { + arrivalKm = stop.stopDistance; + // Reverse search for last scenery checkpoint if (currentPath.departureLineData) { - console.log(stop.departureLine, currentPath.sceneryName, stop.stopDistance, currentPath.departureLineData.routeLength); + if (currentPath.departureLineData.routeLength != 0 && !currentPath.departureLineData.isRouteSBL) + arrivalKm = stop.stopDistance + currentPath.departureLineData.routeLength / 1000; - if (currentPath.departureLineData.isRouteSBL) arrivalKm = stop.stopDistance + (currentPath.departureLineData.routeSpeed <= 130 ? 1.0 : 2.0); - else arrivalKm = stop.stopDistance + currentPath.departureLineData.routeLength / 1000; + if (stopRows[stopRows.length - 1].isMain && currentPath.departureLineData.isRouteSBL && stop.departureLine == currentPath.departureLine) + arrivalKm = stop.stopDistance + currentPath.departureLineData.routeLength / 1000; - for (let i = stopRows.length - 1; i > 0; i--) { + for (let i = stopRows.length - 1; i >= 0; i--) { stopRows[i].departureTracks = currentPath.departureLineData.routeTracks; stopRows[i].departureSpeed = currentPath.departureLineData.routeSpeed; stopRows[i].realLine = currentPath.departureLineData.realLineNo?.toString() ?? ''; @@ -187,6 +191,19 @@ const computedTimetableRows = computed(() => { stopRows[i].departureSpeed = currentPath.departureLineData.routeSpeed; stopRows[i].departureTracks = currentPath.departureLineData.routeTracks; + console.log( + stop.departureLine, + currentPath.sceneryName, + stop.stopDistance, + currentPath.departureLineData.routeLength, + currentPath.departureLineData.isRouteSBL + ); + + /* + if (currentPath.departureLineData.isRouteSBL) + arrivalKm = stop.stopDistance + (currentPath.departureLineData.routeSpeed <= 130 ? 1.0 : 2.0); + else */ + abbrevs = getAbbrevs(currentPath.departureLineData); stopRows[i].abbrevs = abbrevs; break;