Skip to content

Commit

Permalink
Merge pull request #111 from camsys/experimental-realtime-match
Browse files Browse the repository at this point in the history
rewrite realtime matching logic
  • Loading branch information
mbsalvatore authored Mar 8, 2024
2 parents 619dc1f + bec225a commit ec78499
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/main/java/org/opentripplanner/model/Timetable.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,23 +273,23 @@ public TripTimes createUpdatedTripTimes(TimetableSnapshotSourceMetrics metrics,

final long today = updateServiceDate.getAsDate(timeZone).getTime() / 1000;

for (int i = 0; i < numStops; i++) {
while (update != null) {
boolean match = false;
if (update != null) {
if (update.hasStopSequence()) {
match = update.getStopSequence() == newTimes.getStopSequence(i);
int i;
for (i = 0; i < numStops; i++) {
if (update.hasStopSequence() && update.getStopSequence() == newTimes.getStopSequence(i)) {
match = true;
break;
}
if (!match || !update.hasStopSequence()) {
if (update.hasStopId()) {
match = pattern.getStop(i).getId().getId().equals(update.getStopId());
}
if (update.hasStopId() && pattern.getStop(i).getId().getId().equals(update.getStopId())) {
match = true;
break;
}
}

if (match) {
StopTimeUpdate.ScheduleRelationship scheduleRelationship =
update.hasScheduleRelationship() ? update.getScheduleRelationship()
: StopTimeUpdate.ScheduleRelationship.SCHEDULED;
: StopTimeUpdate.ScheduleRelationship.SCHEDULED;
if (scheduleRelationship == StopTimeUpdate.ScheduleRelationship.SKIPPED) {
LOG.trace("Partially canceled trips are unsupported by this method." +
" Skipping TripUpdate.");
Expand Down Expand Up @@ -354,22 +354,22 @@ public TripTimes createUpdatedTripTimes(TimetableSnapshotSourceMetrics metrics,
}
}
}

if (updates.hasNext()) {
update = updates.next();
} else {
update = null;
}
} else {
if (delay == null) {
newTimes.updateArrivalTime(i, TripTimes.UNAVAILABLE);
newTimes.updateDepartureTime(i, TripTimes.UNAVAILABLE);
} else {
newTimes.updateArrivalDelay(i, delay);
newTimes.updateDepartureDelay(i, delay);
}
// if (delay == null) {
// newTimes.updateArrivalTime(i, TripTimes.UNAVAILABLE);
// newTimes.updateDepartureTime(i, TripTimes.UNAVAILABLE);
// } else {
// newTimes.updateArrivalDelay(i, delay);
// newTimes.updateDepartureDelay(i, delay);
// }
}
if (updates.hasNext()) {
update = updates.next();
} else {
update = null;
}
}

if (update != null) {
LOG.trace("Part of a TripUpdate object could not be applied successfully to trip {}.", tripId);
return null;
Expand Down

0 comments on commit ec78499

Please sign in to comment.