query.setLookaheadTime(obaOpts.lookaheadTime);
List<Pair<ArrivalAndDepartureInstance>> instances = adService.getNextDeparturesForStopPair(
stopPair.getFirst(), stopPair.getSecond(), targetTime, query);
State results = null;
for (Pair<ArrivalAndDepartureInstance> pair : instances) {
ArrivalAndDepartureInstance departure = pair.getFirst();
if (departure.getBestDepartureTime() < s0.getTime()
- query.getLookaheadTime() * 1000)
continue;
Vertex toV = new TPBlockDepartureVertex(_context, _pathState, departure,
pair.getSecond());
int dwellTime = computeWaitTime(s0, pair);
double w = ItineraryWeightingLibrary.computeWeightForWait(s0, dwellTime);
EdgeNarrative narrative = narrative(s0, fromV, toV);
OBAStateEditor edit = (OBAStateEditor) s0.edit(this, narrative);
edit.setTime(departure.getBestDepartureTime());
edit.incrementWeight(w);
/**
* If the departure time is less than the starting state time, it must
* mean the departure was included as determined by the lookahead
* parameter. Thus, we indicate that we have a lookahead itinerary.
*/
if (departure.getBestDepartureTime() < s0.getTime())
edit.setLookaheadItinerary();
if (departure.getBlockSequence() != null)
edit.appendTripSequence(departure.getBlockSequence());
else
edit.appendTripSequence(departure.getBlockTrip());
State s1 = edit.makeState();
results = s1.addToExistingResultChain(results);
}
return results;
}