Search in sources :

Example 31 with StateEditor

use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.

the class PatternInterlineDwell method optimisticTraverse.

@Override
public State optimisticTraverse(State s0) {
    StateEditor s1 = s0.edit(this);
    // FIXME too optimistic
    s1.incrementTimeInSeconds(0);
    return s1.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor)

Example 32 with StateEditor

use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.

the class SampleEdge method traverse.

@Override
public /**
 * We want to use exactly the same logic here as is used in propagating to samples
 */
State traverse(State s0) {
    StateEditor s1 = s0.edit(this);
    s1.incrementWalkDistance(this.length);
    s1.incrementTimeInMilliseconds((int) (1000 * this.length / s0.getOptions().walkSpeed));
    return s1.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor)

Example 33 with StateEditor

use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.

the class SimpleTransfer method traverse.

@Override
public State traverse(State s0) {
    // Forbid taking shortcuts composed of two transfers in a row
    if (s0.backEdge instanceof SimpleTransfer) {
        return null;
    }
    if (s0.backEdge instanceof StreetTransitLink) {
        return null;
    }
    if (distance > s0.getOptions().maxTransferWalkDistance) {
        return null;
    }
    // Only transfer right after riding a vehicle.
    RoutingRequest rr = s0.getOptions();
    double walkspeed = rr.walkSpeed;
    StateEditor se = s0.edit(this);
    se.setBackMode(TraverseMode.WALK);
    int time = (int) Math.ceil(distance / walkspeed) + 2 * StreetTransitLink.STL_TRAVERSE_COST;
    se.incrementTimeInSeconds(time);
    se.incrementWeight(time * rr.walkReluctance);
    se.incrementWalkDistance(distance);
    return se.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest)

Example 34 with StateEditor

use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.

the class StationStopEdge method traverse.

@Override
public State traverse(State s0) {
    if (s0.backEdge instanceof StationStopEdge) {
        return null;
    }
    StateEditor s1 = s0.edit(this);
    s1.setBackMode(TraverseMode.LEG_SWITCH);
    s1.incrementWeight(1);
    // Increment weight, but not time. See Javadoc on this class.
    return s1.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor)

Example 35 with StateEditor

use of org.opentripplanner.routing.core.StateEditor in project OpenTripPlanner by opentripplanner.

the class FreeEdge method traverse.

@Override
public State traverse(State s0) {
    StateEditor s1 = s0.edit(this);
    s1.incrementWeight(1);
    // do not change mode, which means it may be null at the start of a trip
    return s1.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor)

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