ArrivalAndDepartureService service = _context.getArrivalAndDepartureService();
State results = null;
OBAState state = (OBAState) s0;
int maxBlockSequence = state.getMaxBlockSequence();
if (maxBlockSequence < 0) {
ArrivalAndDepartureInstance nextTransferStop = service.getNextTransferStopArrivalAndDeparture(_from);
if (nextTransferStop != null) {
long departure = _from.getBestDepartureTime();
long arrival = nextTransferStop.getBestArrivalTime();
int runningTime = (int) ((arrival - departure) / 1000);
Vertex fromVertex = new BlockDepartureVertex(_context, _from);
Vertex toVertex = new BlockArrivalVertex(_context, nextTransferStop);
EdgeNarrative narrative = narrative(s0, fromVertex, toVertex);
StateEditor edit = s0.edit(this, narrative);
edit.incrementTimeInSeconds(runningTime);
edit.incrementWeight(runningTime);
State result = edit.makeState();
results = result.addToExistingResultChain(results);
maxBlockSequence = nextTransferStop.getBlockStopTime().getBlockSequence();
} else {
maxBlockSequence = Integer.MAX_VALUE;
}
}
ArrivalAndDepartureInstance nextStop = service.getNextStopArrivalAndDeparture(_from);
if (nextStop != null
&& nextStop.getBlockStopTime().getBlockSequence() < maxBlockSequence) {
long departure = _from.getBestDepartureTime();
long arrival = nextStop.getBestArrivalTime();
int runningTime = (int) ((arrival - departure) / 1000);
Vertex fromVertex = new BlockDepartureVertex(_context, _from);
Vertex toVertex = new BlockArrivalVertex(_context, nextStop);
EdgeNarrative narrative = narrative(s0, fromVertex, toVertex);
OBAStateEditor edit = (OBAStateEditor) s0.edit(this, narrative);
edit.incrementTimeInSeconds(runningTime);
edit.incrementWeight(runningTime);
if (state.getMaxBlockSequence() < 0)
edit.setMaxBlockSequence(maxBlockSequence);
State tr = edit.makeState();
results = tr.addToExistingResultChain(results);
}