}
}
if (options.arriveBy) {
/* Traverse backward: not much to do */
StateEditor s1 = s0.edit(this);
TransitStop fromVertex = (TransitStop) getFromVertex();
//apply board slack
s1.incrementTimeInSeconds(options.boardSlack);
s1.alightTransit();
s1.setBackMode(getMode());
return s1.makeState();
} else {
/* Traverse forward: apply stop(pair)-specific costs */
// Do not pre-board if transit modes are not selected.
// Return null here rather than in StreetTransitLink so that walk-only
// options can be used to find transit stops without boarding vehicles.
if (!options.modes.isTransit())
return null;
// If we've hit our transfer limit, don't go any further
if (s0.getNumBoardings() > options.maxTransfers)
return null;
/* apply transfer rules */
/*
* look in the global transfer table for the rules from the previous stop to this stop.
*/
long t0 = s0.getTimeSeconds();
long slack;
if (s0.isEverBoarded()) {
slack = options.transferSlack - options.alightSlack;
} else {
slack = options.boardSlack;
}
long board_after = t0 + slack;
long transfer_penalty = 0;
// penalize transfers more heavily if requested by the user
if (s0.isEverBoarded()) {
// this is not the first boarding, therefore we must have "transferred" -- whether
// via a formal transfer or by walking.
transfer_penalty += options.transferPenalty;
}
StateEditor s1 = s0.edit(this);
s1.setTimeSeconds(board_after);
long wait_cost = board_after - t0;
s1.incrementWeight(wait_cost + transfer_penalty);
s1.setBackMode(getMode());
return s1.makeState();
}
}