public void testBoardAlightStopIndex() { Vertex stop_b_arrive = graph.getVertex("agency:C_arrive"); Vertex stop_b_depart = graph.getVertex("agency:C_depart"); Map<TripPattern, Integer> stopIndex = new HashMap<TripPattern, Integer>(); for (Edge edge : stop_b_depart.getOutgoing()) { TransitBoardAlight tba = (TransitBoardAlight) edge; stopIndex.put(tba.getPattern(), tba.getStopIndex()); } for (Edge edge : stop_b_arrive.getIncoming()) { TransitBoardAlight tba = (TransitBoardAlight) edge; if (stopIndex.containsKey(tba.getPattern())) assertEquals((Integer) stopIndex.get(tba.getPattern()), new Integer(tba.getStopIndex())); } }
private boolean checkForInterliningArriveBy( RoutingRequest options, int nBoardings, RaptorRoute route, List<RaptorState> boardStates) { int firstStop = route.getNStops() - 1; boolean started = false; final List<RaptorState> states = statesByStop[route.stops[firstStop].index]; if (states == null) return false; INTERLINE: for (RaptorState oldState : states) { if (oldState.nBoardings != nBoardings - 1) { continue; } if (oldState.route == null) { continue; } if (oldState.route.stops[0] != oldState.stop) { continue; } RaptorInterlineData interline = oldState.route.interlinesIn.get(oldState.tripId); if (interline == null || interline.fromRoute != route) { continue; } RaptorState stayOn = oldState.clone(); stayOn.arrivalTime += options.getBoardSlack(); // go backwards in time stayOn.interlining = true; // generate a board state for this interline RaptorState boardState = new RaptorState(stayOn); // we need to subtract out the boardSlack that we are about to mistakenly pay boardState.weight = -options.getBoardSlack() - options.getAlightSlack(); boardState.nBoardings = boardState.nBoardings = nBoardings - 1; boardState.boardStop = route.stops[firstStop]; boardState.boardStopSequence = firstStop; TransitBoardAlight alight = route.alights[firstStop - 1][interline.fromPatternIndex]; TableTripPattern pattern = alight.getPattern(); boardState.tripTimes = pattern.getTripTimes(interline.fromTripIndex); final ServiceDay serviceDay = oldState.serviceDay; boardState.arrivalTime = (int) serviceDay.time(boardState.tripTimes.getArrivalTime(firstStop - 1)); boardState.patternIndex = interline.fromPatternIndex; boardState.tripId = interline.fromTripId; boardState.serviceDay = serviceDay; boardState.route = route; boardState.walkDistance = oldState.walkDistance; for (RaptorState state : boardStates) { if (state.eDominates(boardState)) { continue INTERLINE; } } boardStates.add(boardState); started = true; } return started; }
/* Somewhat hackish convenience method to grab a hop edge on a particular route leaving a particular stop. */ private PatternHop getHopEdge(String stopId, String routeId) { Vertex stopDepartVertex = graph.getVertex("agency:" + stopId + "_depart"); for (Edge edge : stopDepartVertex.getOutgoing()) { if (edge instanceof TransitBoardAlight) { TransitBoardAlight tba = ((TransitBoardAlight) edge); if (tba.boarding && tba.getPattern().route.getId().getId().equals(routeId)) { for (Edge edge2 : tba.getToVertex().getOutgoing()) { if (edge2 instanceof PatternHop) { return (PatternHop) edge2; } } } } } return null; }