use of org.opentripplanner.routing.core.RoutingRequest in project OpenTripPlanner by opentripplanner.
the class PatternHop method optimisticTraverse.
public State optimisticTraverse(State state0) {
RoutingRequest options = state0.getOptions();
// Ignore this edge if either of its stop is banned hard
if (!options.bannedStopsHard.isEmpty()) {
if (options.bannedStopsHard.matches(((PatternStopVertex) fromv).getStop()) || options.bannedStopsHard.matches(((PatternStopVertex) tov).getStop())) {
return null;
}
}
int runningTime = getPattern().scheduledTimetable.getBestRunningTime(stopIndex);
StateEditor s1 = state0.edit(this);
s1.incrementTimeInSeconds(runningTime);
s1.setBackMode(getMode());
s1.incrementWeight(runningTime);
return s1.makeState();
}
use of org.opentripplanner.routing.core.RoutingRequest in project OpenTripPlanner by opentripplanner.
the class PatternHop method traverse.
public State traverse(State s0) {
RoutingRequest options = s0.getOptions();
// Ignore this edge if either of its stop is banned hard
if (!options.bannedStopsHard.isEmpty()) {
if (options.bannedStopsHard.matches(((PatternStopVertex) fromv).getStop()) || options.bannedStopsHard.matches(((PatternStopVertex) tov).getStop())) {
return null;
}
}
TripTimes tripTimes = s0.getTripTimes();
int runningTime = tripTimes.getRunningTime(stopIndex);
StateEditor s1 = s0.edit(this);
s1.incrementTimeInSeconds(runningTime);
if (s0.getOptions().arriveBy)
s1.setZone(getBeginStop().getZoneId());
else
s1.setZone(getEndStop().getZoneId());
// s1.setRoute(pattern.getExemplar().route.getId());
s1.incrementWeight(runningTime);
s1.setBackMode(getMode());
return s1.makeState();
}
use of org.opentripplanner.routing.core.RoutingRequest in project OpenTripPlanner by opentripplanner.
the class ElevatorBoardEdge method traverse.
@Override
public State traverse(State s0) {
RoutingRequest options = s0.getOptions();
StateEditor s1 = s0.edit(this);
// We always walk in elevators, even when we have a bike with us
s1.setBackMode(TraverseMode.WALK);
s1.incrementWeight(options.elevatorBoardCost);
s1.incrementTimeInSeconds(options.elevatorBoardTime);
return s1.makeState();
}
use of org.opentripplanner.routing.core.RoutingRequest in project OpenTripPlanner by opentripplanner.
the class ParkAndRideEdge method traverse.
@Override
public State traverse(State s0) {
RoutingRequest request = s0.getOptions();
if (!request.parkAndRide) {
return null;
}
if (request.arriveBy) {
/*
* To get back a car, we need to walk and have car mode enabled.
*/
if (s0.getNonTransitMode() != TraverseMode.WALK) {
return null;
}
if (!s0.isCarParked()) {
throw new IllegalStateException("Stolen car?");
}
StateEditor s1 = s0.edit(this);
int time = request.carDropoffTime;
s1.incrementWeight(time);
s1.incrementTimeInSeconds(time);
s1.setCarParked(false);
s1.setBackMode(TraverseMode.LEG_SWITCH);
return s1.makeState();
} else {
/*
* To park a car, we need to be in one and have allowed walk modes.
*/
if (s0.getNonTransitMode() != TraverseMode.CAR) {
return null;
}
if (s0.isCarParked()) {
throw new IllegalStateException("Can't drive 2 cars");
}
StateEditor s1 = s0.edit(this);
int time = request.carDropoffTime;
s1.incrementWeight(time);
s1.incrementTimeInSeconds(time);
s1.setCarParked(true);
s1.setBackMode(TraverseMode.LEG_SWITCH);
return s1.makeState();
}
}
use of org.opentripplanner.routing.core.RoutingRequest in project OpenTripPlanner by opentripplanner.
the class AnalystProfileRouterPrototype method findClosestStops.
/**
* Perform an on-street search around a point with a specific mode to find nearby stops.
* TODO merge with NearbyStopFinder
*/
private TObjectIntMap<Stop> findClosestStops(final TraverseMode mode) {
RoutingRequest rr = new RoutingRequest(mode);
GenericLocation gl = new GenericLocation(request.fromLat, request.fromLon);
rr.from = gl;
// FIXME destination must be set, even though this is meaningless for one-to-many
rr.to = gl;
rr.setRoutingContext(graph);
// Set batch after context, so both origin and dest vertices will be found.
rr.batch = (true);
rr.walkSpeed = request.walkSpeed;
// RR dateTime defaults to currentTime.
// If elapsed time is not capped, searches are very slow.
int minAccessTime = 0;
int maxAccessTime = request.maxWalkTime;
rr.worstTime = (rr.dateTime + maxAccessTime * 60);
AStar astar = new AStar();
rr.dominanceFunction = new DominanceFunction.EarliestArrival();
rr.setNumItineraries(1);
StopFinderTraverseVisitor visitor = new StopFinderTraverseVisitor(mode, minAccessTime * 60);
astar.setTraverseVisitor(visitor);
// timeout in seconds
astar.getShortestPathTree(rr, 5);
rr.cleanup();
return visitor.stopsFound;
}
Aggregations