OBATraverseOptions obaOpts = (OBATraverseOptions) s0.getOptions();
ArrivalAndDepartureService adService = _context.getArrivalAndDepartureService();
Vertex toV = new TPArrivalVertex(_context, _pathState);
Pair<StopEntry> stopPair = _pathState.getStops();
TargetTime targetTime = new TargetTime(s0.getTime(), obaOpts.currentTime);
ArrivalAndDeparturePairQuery query = new ArrivalAndDeparturePairQuery();
query.setResultCount(obaOpts.numItineraries);
query.setApplyRealTime(obaOpts.useRealtime);
query.setIncludePrivateService(false);
/**
* Recall that the stopPair is in reverse order (toStop => fromStop)
*/
List<Pair<ArrivalAndDepartureInstance>> instances = adService.getPreviousArrivalsForStopPair(
stopPair.getSecond(), stopPair.getFirst(), targetTime, query);
State results = null;
for (Pair<ArrivalAndDepartureInstance> pair : instances) {
/**
* For now, we skip real-time arrival that might have been included that
* are beyond our range (ex. vehicle running late)
*/
ArrivalAndDepartureInstance arrival = pair.getSecond();
if (arrival.getBestArrivalTime() > s0.getTime())
break;
Vertex fromV = new TPBlockArrivalVertex(_context, _pathState,
pair.getFirst(), pair.getSecond());
EdgeNarrative narrative = narrative(s0, fromV, toV);
OBAStateEditor edit = (OBAStateEditor) s0.edit(this, narrative);