Search in sources :

Example 26 with StateEditor

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

the class SimpleEdge method traverse.

@Override
public State traverse(State s0) {
    StateEditor s1 = s0.edit(this);
    s1.incrementTimeInSeconds(seconds);
    s1.incrementWeight(weight);
    // SimpleEdges don't concern themselves with mode
    return s1.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor)

Example 27 with StateEditor

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

the class TemporaryConcreteEdge method traverse.

@Override
public State traverse(State s0) {
    double d = getDistance();
    TraverseMode mode = s0.getNonTransitMode();
    int t = (int) (d / s0.getOptions().getSpeed(mode));
    StateEditor s1 = s0.edit(this);
    s1.incrementTimeInSeconds(t);
    s1.incrementWeight(d);
    return s1.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor) TraverseMode(org.opentripplanner.routing.core.TraverseMode)

Example 28 with StateEditor

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

the class StreetTransitLink method optimisticTraverse.

public State optimisticTraverse(State s0) {
    StateEditor s1 = s0.edit(this);
    s1.incrementWeight(STL_TRAVERSE_COST);
    s1.setBackMode(TraverseMode.LEG_SWITCH);
    return s1.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor)

Example 29 with StateEditor

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

the class TransferEdge method traverse.

public State traverse(State s0) {
    /* Disallow chaining of transfer edges. TODO: This should really be guaranteed by the PathParser
           but the default Pathparser is currently very hard to read because
           we need a complement operator. */
    if (s0.getBackEdge() instanceof TransferEdge)
        return null;
    if (s0.getOptions().wheelchairAccessible && !wheelchairAccessible)
        return null;
    if (this.getDistance() > s0.getOptions().maxTransferWalkDistance)
        return null;
    StateEditor s1 = s0.edit(this);
    s1.incrementTimeInSeconds(time);
    s1.incrementWeight(time);
    s1.setBackMode(TraverseMode.WALK);
    return s1.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor)

Example 30 with StateEditor

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

the class PatternInterlineDwell method traverse.

@Override
public State traverse(State state0) {
    RoutingRequest options = state0.getOptions();
    Trip oldTrip = state0.getBackTrip();
    Trip newTrip = options.arriveBy ? trips.inverse().get(oldTrip) : trips.get(oldTrip);
    if (newTrip == null)
        return null;
    TripPattern newPattern;
    TripTimes newTripTimes;
    TripTimes oldTripTimes = state0.getTripTimes();
    int arrivalTime;
    int departureTime;
    AgencyAndId tripId = state0.getTripId();
    if (options.arriveBy) {
        // traversing backward
        newPattern = ((OnboardVertex) fromv).getTripPattern();
        newTripTimes = newPattern.getResolvedTripTimes(newTrip, state0);
        // FIXME with getLastTime method
        arrivalTime = newTripTimes.getArrivalTime(newTripTimes.getNumStops() - 1);
        departureTime = oldTripTimes.getDepartureTime(0);
    } else {
        // traversing forward
        newPattern = ((OnboardVertex) tov).getTripPattern();
        newTripTimes = newPattern.getResolvedTripTimes(newTrip, state0);
        // FIXME with getLastTime method
        arrivalTime = oldTripTimes.getArrivalTime(oldTripTimes.getNumStops() - 1);
        departureTime = newTripTimes.getDepartureTime(0);
    }
    int boardStopIndex = options.arriveBy ? newPattern.stopPattern.size - 1 : 0;
    if (!newTripTimes.tripAcceptable(state0, boardStopIndex))
        return null;
    int dwellTime = departureTime - arrivalTime;
    if (dwellTime < 0)
        return null;
    StateEditor s1 = state0.edit(this);
    s1.incrementTimeInSeconds(dwellTime);
    // TODO check meaning
    s1.setTripId(newTrip.getId());
    // TODO check meaning
    s1.setPreviousTrip(oldTrip);
    s1.setTripTimes(newTripTimes);
    s1.incrementWeight(dwellTime);
    // Mode should not change.
    return s1.makeState();
}
Also used : Trip(org.onebusaway.gtfs.model.Trip) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) StateEditor(org.opentripplanner.routing.core.StateEditor) TripTimes(org.opentripplanner.routing.trippattern.TripTimes) 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