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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations