Skip to content

Commit

Permalink
Merge pull request #63 from naviqore/bug/NAV-100-Fix-legs-not-connect…
Browse files Browse the repository at this point in the history
…ed-error-in-raptor

FIX: NAV-100 - Fix edge case where two legs have same departure times…
  • Loading branch information
munterfi authored Jun 14, 2024
2 parents 965d76d + 4f19d17 commit c45a09f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/ch/naviqore/raptor/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,16 @@ public record Leg(String routeId, @Nullable String tripId, String fromStopId, St

@Override
public int compareTo(@NotNull Connection.Leg other) {
return Integer.compare(this.departureTime, other.departureTime);
// sort legs first by departure time than by arrival time since there some legs that actually have the same
// departure and arrival time (really short distance local service) and therefore the following leg may
// have the same departure time but a later arrival time
int comparison = Integer.compare(this.departureTime, other.departureTime);
if (comparison != 0) {
return comparison;
} else {
return Integer.compare(this.arrivalTime, other.arrivalTime);
}

}

}
Expand Down

0 comments on commit c45a09f

Please sign in to comment.