use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.
the class StreetBikeParkLink method traverse.
public State traverse(State s0) {
// Do not even consider bike park vertices unless bike P+R is enabled.
if (!s0.getOptions().bikeParkAndRide) {
return null;
}
// turn restrictions.
if (s0.getBackEdge() instanceof StreetBikeParkLink)
return null;
StateEditor s1 = s0.edit(this);
// Assume bike park are more-or-less on-street
s1.incrementTimeInSeconds(1);
s1.incrementWeight(1);
// Do not force any mode, will use the latest one (walking bike or bike)
return s1.makeState();
}
use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.
the class BikeParkEdge method traverseUnpark.
protected State traverseUnpark(State s0) {
RoutingRequest options = s0.getOptions();
/*
* To unpark a bike, we need to be walking, and be allowed to bike.
*/
if (s0.getNonTransitMode() != TraverseMode.WALK || !options.modes.getBicycle())
return null;
StateEditor s0e = s0.edit(this);
s0e.incrementWeight(options.bikeParkCost);
s0e.incrementTimeInSeconds(options.bikeParkTime);
s0e.setBackMode(TraverseMode.LEG_SWITCH);
s0e.setBikeParked(false);
State s1 = s0e.makeState();
return s1;
}
use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.
the class ElevatorHopEdge method traverse.
@Override
public State traverse(State s0) {
RoutingRequest options = s0.getOptions();
if (options.wheelchairAccessible && !wheelchairAccessible) {
return null;
}
TraverseMode mode = s0.getNonTransitMode();
if (mode == TraverseMode.WALK && !permission.allows(StreetTraversalPermission.PEDESTRIAN)) {
return null;
}
if (mode == TraverseMode.BICYCLE && !permission.allows(StreetTraversalPermission.BICYCLE)) {
return null;
}
// there are elevators which allow cars
if (mode == TraverseMode.CAR && !permission.allows(StreetTraversalPermission.CAR)) {
return null;
}
StateEditor s1 = s0.edit(this);
s1.setBackMode(TraverseMode.WALK);
s1.incrementWeight(options.elevatorHopCost);
s1.incrementTimeInSeconds(options.elevatorHopTime);
return s1.makeState();
}
use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.
the class LegSwitchingEdge method traverse.
@Override
public State traverse(State s0) {
StateEditor editor = s0.edit(this);
editor.setBackMode(TraverseMode.LEG_SWITCH);
// Forget the last pattern to allow taking the same route from an intermediate place
editor.setLastPattern(null);
return editor.makeState();
}
use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.
the class OnBoardDepartPatternHop method traverse.
public State traverse(State state0) {
RoutingRequest options = state0.getOptions();
if (options.reverseOptimizing || options.reverseOptimizeOnTheFly) {
throw new UnsupportedOperationException("Cannot (yet) reverse-optimize depart-on-board mode.");
}
/* Can't be traversed backwards. */
if (options.arriveBy)
return null;
StateEditor s1 = state0.edit(this);
// s1.setBackMode(TraverseMode.BOARDING); TODO Do we need this?
s1.setServiceDay(serviceDay);
s1.setTripTimes(tripTimes);
// s1.incrementNumBoardings(); TODO Needed?
s1.setTripId(trip.getId());
s1.setPreviousTrip(trip);
s1.setZone(endStop.getZoneId());
s1.setRoute(trip.getRoute().getId());
int remainingTime = (int) Math.round((1.0 - positionInHop) * tripTimes.getRunningTime(stopIndex));
s1.incrementTimeInSeconds(remainingTime);
s1.incrementWeight(remainingTime);
s1.setBackMode(getMode());
s1.setEverBoarded(true);
return s1.makeState();
}
Aggregations