Skip to content

Commit 48bc480

Browse files
committed
fixup! feat: correctly update arrival/departure/travel times when a node is masked
1 parent d325f2d commit 48bc480

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/app/services/data/trainrunsection.service.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -883,13 +883,15 @@ export class TrainrunSectionService implements OnDestroy {
883883
let stopTime: number;
884884
while (iterator.hasNext()) {
885885
const nextPair = iterator.next();
886+
const rightIsTarget =
887+
nextPair.node.getId() === nextPair.trainrunSection.getTargetNode().getId();
886888

887889
if (prevInitialTargetArrival !== null) {
888-
stopTime = MathUtils.mod60(nextPair.trainrunSection.getSourceDeparture() - prevInitialTargetArrival);
890+
stopTime = MathUtils.mod60((rightIsTarget ? nextPair.trainrunSection.getSourceDeparture(): nextPair.trainrunSection.getTargetDeparture()) - prevInitialTargetArrival);
889891
trsTimeStructure.leftDepartureTime = trsTimeStructure.rightArrivalTime + stopTime;
890892
trsTimeStructure.leftArrivalTime = trsTimeStructure.rightDepartureTime - stopTime;
891893
}
892-
prevInitialTargetArrival = nextPair.trainrunSection.getTargetArrival();
894+
prevInitialTargetArrival = rightIsTarget ? nextPair.trainrunSection.getTargetArrival() : nextPair.trainrunSection.getSourceArrival();
893895

894896
const isLastRightNode = !nextPair.node.isNonStop(nextPair.trainrunSection) && !nextPair.node.getIsCollapsed();
895897
trsTimeStructure.travelTime = isLastRightNode ?
@@ -911,8 +913,7 @@ export class TrainrunSectionService implements OnDestroy {
911913
trsTimeStructure,
912914
precision,
913915
);
914-
const rightIsTarget =
915-
nextPair.node.getId() === nextPair.trainrunSection.getTargetNode().getId();
916+
916917
this.updateTrainrunSectionTime(
917918
nextPair.trainrunSection.getId(),
918919
rightIsTarget ? trsTimeStructure.leftArrivalTime : trsTimeStructure.rightArrivalTime,

0 commit comments

Comments
 (0)