Commit 2b1bd70b authored by Volker Krause's avatar Volker Krause
Browse files

Consider more variations for merging train reservations

- use conflicting arrival times as an exclusion criteria
- compare locations with the dedicated tools for that rather than by just
checking for exactly matching names
- don't insist on train numbers for bound train reservations, if everything
else matches.
parent daab5598
......@@ -361,14 +361,17 @@ static bool isSameTrainTrip(const TrainTrip &lhs, const TrainTrip &rhs)
// so we have to use the slightly less robust location comparison
if (!lhs.departureTime().isValid() && !rhs.departureTime().isValid()) {
qCDebug(CompareLog) << "unbound trip" << lhs.departureStation().name() << rhs.departureStation().name() << lhs.arrivalStation().name() << rhs.arrivalStation().name();
return lhs.departureStation().name() == rhs.departureStation().name() && lhs.arrivalStation().name() == rhs.arrivalStation().name();
} else if (!equalAndPresent(lhs.departureTime(), rhs.departureTime())) {
return LocationUtil::isSameLocation(lhs.departureStation(), rhs.departureStation(), LocationUtil::Exact)
&& LocationUtil::isSameLocation(lhs.arrivalStation(), rhs.arrivalStation(), LocationUtil::Exact);
} else if (!equalAndPresent(lhs.departureTime(), rhs.departureTime()) || conflictIfPresent(lhs.arrivalTime(), rhs.arrivalTime())) {
return false;
}
// if we don't have train numbers, also fall back to the less robust location comparison
if (lhs.trainNumber().isEmpty() || rhs.trainNumber().isEmpty()) {
qCDebug(CompareLog) << "missing train number" << lhs.trainNumber() << rhs.trainNumber();
return false;
return LocationUtil::isSameLocation(lhs.departureStation(), rhs.departureStation(), LocationUtil::Exact)
&& LocationUtil::isSameLocation(lhs.arrivalStation(), rhs.arrivalStation(), LocationUtil::Exact);
}
const auto isSameLine = isSameLineName(lhs.trainNumber(), rhs.trainNumber());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment