mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-16 01:19:49 +00:00
Trip: Mark trip as untravelable if important departures or arrivals are cancelled.
This commit is contained in:
parent
097b2bb29f
commit
a873801249
1 changed files with 10 additions and 1 deletions
|
@ -187,11 +187,20 @@ public final class Trip implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
/** Returns true if no legs overlap, false otherwise. */
|
||||
/**
|
||||
* Returns true if it looks like the trip can be traveled. Returns false if legs overlap, important
|
||||
* departures or arrivals are cancelled and that sort of thing.
|
||||
*/
|
||||
public boolean isTravelable() {
|
||||
Date time = null;
|
||||
|
||||
for (final Leg leg : legs) {
|
||||
if (leg instanceof Public) {
|
||||
final Public publicLeg = (Public) leg;
|
||||
if (publicLeg.departureStop.departureCancelled || publicLeg.arrivalStop.arrivalCancelled)
|
||||
return false;
|
||||
}
|
||||
|
||||
final Date departureTime = leg.getDepartureTime();
|
||||
if (time != null && departureTime.before(time))
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue