Search in sources :

Example 11 with StateEditor

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();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor)

Example 12 with StateEditor

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;
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor) State(org.opentripplanner.routing.core.State) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest)

Example 13 with StateEditor

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();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) TraverseMode(org.opentripplanner.routing.core.TraverseMode)

Example 14 with StateEditor

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();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor)

Example 15 with StateEditor

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();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest)

Aggregations

StateEditor (org.opentripplanner.routing.core.StateEditor)38 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)17 State (org.opentripplanner.routing.core.State)5 TraverseMode (org.opentripplanner.routing.core.TraverseMode)4 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)4 Trip (org.onebusaway.gtfs.model.Trip)2 BikeRentalStationVertex (org.opentripplanner.routing.vertextype.BikeRentalStationVertex)2 PatternStopVertex (org.opentripplanner.routing.vertextype.PatternStopVertex)2 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)2 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 RoutingContext (org.opentripplanner.routing.core.RoutingContext)1 ServiceDay (org.opentripplanner.routing.core.ServiceDay)1 TransferTable (org.opentripplanner.routing.core.TransferTable)1 Edge (org.opentripplanner.routing.graph.Edge)1 BikeParkVertex (org.opentripplanner.routing.vertextype.BikeParkVertex)1