Skip to content

Commit

Permalink
mark events as technical stop if there is overlay without stop type
Browse files Browse the repository at this point in the history
  • Loading branch information
derklaro committed Jan 11, 2025
1 parent d269d8f commit d54b8d4
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,18 @@ private void collectJourney(
events,
inBorder);
}

if (events.size() > 1 && previousEvent != null && previousEvent.getEventType() == JourneyEventType.DEPARTURE) {
// ensure that events with a scheduled overlay (arrival time != departure time)
// have a technical or passenger stop scheduled - for some reason that's not directly
// done in the train timetables even tho the time for stopping is planned
var arrivalEvent = events.get(events.size() - 2);
var hasOverlay = !previousEvent.getScheduledTime().isEqual(arrivalEvent.getScheduledTime());
if (previousEvent.getStopType() == JourneyStopType.NONE && hasOverlay) {
arrivalEvent.setStopType(JourneyStopType.TECHNICAL);
previousEvent.setStopType(JourneyStopType.TECHNICAL);
}
}
}

// drop the first event if it is an arrival event - journeys can only depart
Expand All @@ -226,13 +238,23 @@ private void collectJourney(
var firstEvent = events.getFirst();
if (firstEvent.getEventType() == JourneyEventType.ARRIVAL) {
events.removeFirst();
if (firstEvent.getStopType() == JourneyStopType.TECHNICAL) {
// ensure that the first event never has a technical stop scheduled
var newFirst = events.getFirst();
newFirst.setStopType(JourneyStopType.NONE);
}
}

// drop the last event if it is a departure event - journeys cannot depart from
// a station as their last event, they have to change to another train to depart.
var lastEvent = events.getLast();
if (lastEvent.getEventType() == JourneyEventType.DEPARTURE) {
events.removeLast();
if (lastEvent.getStopType() == JourneyStopType.TECHNICAL) {
// ensure that the last event never has a technical stop scheduled
var newLast = events.getLast();
newLast.setStopType(JourneyStopType.NONE);
}
}

// update the events associated with the journey if they changed
Expand Down

0 comments on commit d54b8d4

Please sign in to comment.