use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.
the class StreetBikeRentalLink method traverse.
public State traverse(State s0) {
// Do not even consider bike rental vertices unless bike rental is enabled.
if (!s0.getOptions().allowBikeRental) {
return null;
}
// turn restrictions.
if (s0.getBackEdge() instanceof StreetBikeRentalLink) {
return null;
}
StateEditor s1 = s0.edit(this);
// assume bike rental stations are more-or-less on-street
s1.incrementTimeInSeconds(1);
s1.incrementWeight(1);
s1.setBackMode(s0.getNonTransitMode());
return s1.makeState();
}
use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.
the class StreetTransitLink method traverse.
public State traverse(State s0) {
// Forbid taking shortcuts composed of two street-transit links in a row. Also avoids spurious leg transitions.
if (s0.backEdge instanceof StreetTransitLink) {
return null;
}
// Do not re-enter the street network following a transfer.
if (s0.backEdge instanceof SimpleTransfer) {
return null;
}
RoutingRequest req = s0.getOptions();
if (s0.getOptions().wheelchairAccessible && !wheelchairAccessible) {
return null;
}
if (s0.getOptions().bikeParkAndRide && !s0.isBikeParked()) {
// Forbid taking your own bike in the station if bike P+R activated.
return null;
}
if (s0.isBikeRenting()) {
// TODO Check this condition, does this always make sense?
return null;
}
// Do not check here whether any transit modes are selected. A check for the presence of
// transit modes will instead be done in the following PreBoard edge.
// This allows searching for nearby transit stops using walk-only options.
StateEditor s1 = s0.edit(this);
/* Note that in arriveBy searches this is double-traversing link edges to fork the state into both WALK and CAR mode. This is an insane hack. */
if (s0.getNonTransitMode() == TraverseMode.CAR) {
if (req.kissAndRide && !s0.isCarParked()) {
s1.setCarParked(true);
} else {
return null;
}
}
s1.incrementTimeInSeconds(transitStop.getStreetToStopTime() + STL_TRAVERSE_COST);
s1.incrementWeight(STL_TRAVERSE_COST + transitStop.getStreetToStopTime());
s1.setBackMode(TraverseMode.LEG_SWITCH);
return s1.makeState();
}
use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.
the class PathwayEdge method traverse.
public State traverse(State s0) {
int time = traversalTime;
if (s0.getOptions().wheelchairAccessible) {
if (wheelchairTraversalTime < 0) {
return null;
}
time = wheelchairTraversalTime;
}
StateEditor s1 = s0.edit(this);
s1.incrementTimeInSeconds(time);
s1.incrementWeight(time);
s1.setBackMode(getMode());
return s1.makeState();
}
use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.
the class PreBoardEdge method traverse.
@Override
public State traverse(State s0) {
RoutingRequest options = s0.getOptions();
// Ignore this edge if its stop is banned
if (!options.bannedStops.isEmpty()) {
if (options.bannedStops.matches(((TransitStop) fromv).getStop())) {
return null;
}
}
if (!options.bannedStopsHard.isEmpty()) {
if (options.bannedStopsHard.matches(((TransitStop) fromv).getStop())) {
return null;
}
}
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 {
// 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();
}
}
use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.
the class PreBoardEdge method optimisticTraverse.
public State optimisticTraverse(State s0) {
// do not include minimum transfer time in heuristic weight
// (it is path-dependent)
StateEditor s1 = s0.edit(this);
s1.setBackMode(getMode());
return s1.makeState();
}
Aggregations