Skip to content

Commit

Permalink
Merge pull request #355 from HSLdevcom/DT-4527
Browse files Browse the repository at this point in the history
DT-4527: Use timeRange as time range for departures requested
  • Loading branch information
optionsome authored May 3, 2021
2 parents df4b099 + 664026b commit 6d6d0ea
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/main/java/org/opentripplanner/routing/graph/GraphIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -811,10 +811,14 @@ protected boolean lessThan(final TripTimeShort t1, final TripTimeShort t2) {

final TimetableSnapshot snapshot = (graph.timetableSnapshotSource != null)
? graph.timetableSnapshotSource.getTimetableSnapshot() : null;

Date date = new Date(startTime * 1000);
final ServiceDate[] serviceDates = {new ServiceDate(date).previous(), new ServiceDate(date), new ServiceDate(date).next()};
// Loop through all possible days
int timeRangeInDays = timeRange / 86400;
int serviceDateArrayLength = (timeRangeInDays > 1 ? timeRangeInDays : 2);
ServiceDate[] serviceDates = new ServiceDate[serviceDateArrayLength + 1];
for(int i = -1; i < serviceDateArrayLength; i++) {
ServiceDate serviceDate = new ServiceDate(date).shift(i);
serviceDates[i + 1] = serviceDate;
}
for (final ServiceDate serviceDate : serviceDates) {
final ServiceDay sd = new ServiceDay(graph, serviceDate, calendarService,
pattern.route.getAgency().getId());
Expand Down Expand Up @@ -854,12 +858,15 @@ protected boolean lessThan(final TripTimeShort t1, final TripTimeShort t2) {
ret.insertWithOverflow(new TripTimeShort(freq.materialize(stopIndex, departureTime, true),
stopIndex, currStop, sd));
departureTime += freq.headway;
}
}
}
stopIndex++;
}
stopIndex++;
}
if (ret.size() >= numberOfDepartures) {
break;
}
}

final List<TripTimeShort> result = new ArrayList<>();
while(ret.size()>0) {
Expand Down

0 comments on commit 6d6d0ea

Please sign in to comment.