Search in sources :

Example 21 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class TestHopFactory method testRouting.

public void testRouting() throws Exception {
    Vertex stop_a = graph.getVertex(feedId + ":A");
    Vertex stop_b = graph.getVertex(feedId + ":B");
    Vertex stop_c = graph.getVertex(feedId + ":C");
    Vertex stop_d = graph.getVertex(feedId + ":D");
    Vertex stop_e = graph.getVertex(feedId + ":E");
    RoutingRequest options = new RoutingRequest();
    options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 0, 0);
    ShortestPathTree spt;
    GraphPath path;
    // A to B
    options.setRoutingContext(graph, stop_a, stop_b);
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(stop_b, false);
    assertNotNull(path);
    assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_b));
    // A to C
    options.setRoutingContext(graph, stop_a, stop_c);
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(stop_c, false);
    assertNotNull(path);
    assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_c));
    // A to D
    options.setRoutingContext(graph, stop_a, stop_d);
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(stop_d, false);
    assertNotNull(path);
    assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_c, stop_d));
    long endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 0, 0) + 40 * 60;
    assertEquals(endTime, path.getEndTime());
    // A to E
    options.setRoutingContext(graph, stop_a, stop_e);
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(stop_e, false);
    assertNotNull(path);
    assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_c, stop_e));
    endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 0, 0) + 70 * 60;
    assertEquals(endTime, path.getEndTime());
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) TransitStopVertex(org.opentripplanner.routing.vertextype.TransitStopVertex) ShortestPathTree(org.opentripplanner.routing.spt.ShortestPathTree) GraphPath(org.opentripplanner.routing.spt.GraphPath) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest)

Example 22 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class GraphPathFinder method getPaths.

/**
 * This no longer does "trip banning" to find multiple itineraries.
 * It just searches once trying to find a non-transit path.
 */
public List<GraphPath> getPaths(RoutingRequest options) {
    if (options == null) {
        LOG.error("PathService was passed a null routing request.");
        return null;
    }
    if (options.streetSubRequestModes.isTransit()) {
        throw new UnsupportedOperationException("Transit search not supported");
    }
    // Reuse one instance of AStar for all N requests, which are carried out sequentially
    AStar aStar = new AStar();
    if (options.rctx == null) {
        options.setRoutingContext(router.graph);
    // The special long-distance heuristic should be sufficient to constrain the search to the right area.
    }
    // If this Router has a GraphVisualizer attached to it, set it as a callback for the AStar search
    if (router.graphVisualizer != null) {
        aStar.setTraverseVisitor(router.graphVisualizer.traverseVisitor);
    // options.disableRemainingWeightHeuristic = true; // DEBUG
    }
    // FORCING the dominance function to weight only
    options.dominanceFunction = new DominanceFunction.MinimumWeight();
    LOG.debug("rreq={}", options);
    // Choose an appropriate heuristic for goal direction.
    RemainingWeightHeuristic heuristic;
    if (options.disableRemainingWeightHeuristic || options.oneToMany) {
        heuristic = new TrivialRemainingWeightHeuristic();
    } else {
        heuristic = new EuclideanRemainingWeightHeuristic();
    }
    options.rctx.remainingWeightHeuristic = heuristic;
    /* maxWalk has a different meaning than it used to. It's the radius around the origin or destination within
         * which you can walk on the streets. An unlimited value would cause the bidi heuristic to do unbounded street
         * searches and consider the whole graph walkable.
         *
         * After the limited areas of the street network around the origin and destination are explored, the
         * options.maxWalkDistance will be set to unlimited for similar reasons to maxTransfers above. That happens
         * in method org.opentripplanner.routing.algorithm.astar.strategies.InterleavedBidirectionalHeuristic.initialize
         */
    if (options.maxWalkDistance == Double.MAX_VALUE)
        options.maxWalkDistance = DEFAULT_MAX_WALK;
    if (options.maxWalkDistance > CLAMP_MAX_WALK)
        options.maxWalkDistance = CLAMP_MAX_WALK;
    long searchBeginTime = System.currentTimeMillis();
    LOG.debug("BEGIN SEARCH");
    double timeout = searchBeginTime + router.streetRoutingTimeoutSeconds() * 1000;
    // Convert from absolute to relative time
    timeout -= System.currentTimeMillis();
    // Convert milliseconds to seconds
    timeout /= 1000;
    if (timeout <= 0) {
        // Catch the case where advancing to the next (lower) timeout value means the search is timed out
        // before it even begins. Passing a negative relative timeout in the SPT call would mean "no timeout".
        options.rctx.aborted = true;
        return null;
    }
    // Don't dig through the SPT object, just ask the A star algorithm for the states that reached the target.
    aStar.getShortestPathTree(options, timeout);
    List<GraphPath> paths = aStar.getPathsToTarget().stream().filter(path -> {
        double duration = options.useRequestedDateTimeInMaxHours ? options.arriveBy ? options.dateTime - path.getStartTime() : path.getEndTime() - options.dateTime : path.getDuration();
        return duration < options.maxHours * 60 * 60;
    }).collect(Collectors.toList());
    LOG.debug("we have {} paths", paths.size());
    LOG.debug("END SEARCH ({} msec)", System.currentTimeMillis() - searchBeginTime);
    Collections.sort(paths, options.getPathComparator(options.arriveBy));
    return paths;
}
Also used : Logger(org.slf4j.Logger) Iterator(java.util.Iterator) PathNotFoundException(org.opentripplanner.routing.error.PathNotFoundException) LoggerFactory(org.slf4j.LoggerFactory) GraphPath(org.opentripplanner.routing.spt.GraphPath) TrivialRemainingWeightHeuristic(org.opentripplanner.routing.algorithm.astar.strategies.TrivialRemainingWeightHeuristic) Collectors(java.util.stream.Collectors) RoutingValidationException(org.opentripplanner.routing.error.RoutingValidationException) DominanceFunction(org.opentripplanner.routing.spt.DominanceFunction) List(java.util.List) EuclideanRemainingWeightHeuristic(org.opentripplanner.routing.algorithm.astar.strategies.EuclideanRemainingWeightHeuristic) Router(org.opentripplanner.standalone.server.Router) RemainingWeightHeuristic(org.opentripplanner.routing.algorithm.astar.strategies.RemainingWeightHeuristic) RoutingErrorCode(org.opentripplanner.routing.api.response.RoutingErrorCode) AStar(org.opentripplanner.routing.algorithm.astar.AStar) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) Collections(java.util.Collections) TrivialRemainingWeightHeuristic(org.opentripplanner.routing.algorithm.astar.strategies.TrivialRemainingWeightHeuristic) EuclideanRemainingWeightHeuristic(org.opentripplanner.routing.algorithm.astar.strategies.EuclideanRemainingWeightHeuristic) RemainingWeightHeuristic(org.opentripplanner.routing.algorithm.astar.strategies.RemainingWeightHeuristic) AStar(org.opentripplanner.routing.algorithm.astar.AStar) GraphPath(org.opentripplanner.routing.spt.GraphPath) TrivialRemainingWeightHeuristic(org.opentripplanner.routing.algorithm.astar.strategies.TrivialRemainingWeightHeuristic) EuclideanRemainingWeightHeuristic(org.opentripplanner.routing.algorithm.astar.strategies.EuclideanRemainingWeightHeuristic) DominanceFunction(org.opentripplanner.routing.spt.DominanceFunction)

Example 23 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class RaptorRequestMapper method mapRequest.

public static RaptorRequest<TripSchedule> mapRequest(RoutingRequest request, ZonedDateTime startOfTime, Collection<? extends RaptorTransfer> accessTimes, Collection<? extends RaptorTransfer> egressTimes) {
    RaptorRequestBuilder<TripSchedule> builder = new RaptorRequestBuilder<>();
    int time = DateMapper.secondsSinceStartOfTime(startOfTime, request.getDateTime().toInstant());
    if (request.arriveBy) {
        builder.searchParams().latestArrivalTime(time);
    } else {
        builder.searchParams().earliestDepartureTime(time);
    }
    if (request.maxTransfers != null) {
        builder.searchParams().maxNumberOfTransfers(request.maxTransfers);
    }
    builder.profile(RaptorProfile.MULTI_CRITERIA).enableOptimization(Optimization.PARETO_CHECK_AGAINST_DESTINATION).slackProvider(new SlackProvider(request.transferSlack, request.boardSlack, request.boardSlackForMode, request.alightSlack, request.alightSlackForMode));
    builder.searchParams().searchWindow(request.searchWindow).addAccessStops(accessTimes.stream().map(t -> (RaptorTransfer) t).collect(Collectors.toList())).addEgressStops(egressTimes.stream().map(t -> (RaptorTransfer) t).collect(Collectors.toList())).boardSlackInSeconds(request.boardSlack).timetableEnabled(true);
    builder.mcCostFactors().waitReluctanceFactor(request.waitReluctance).walkReluctanceFactor(request.walkReluctance);
    return builder.build();
}
Also used : RaptorRequest(org.opentripplanner.transit.raptor.api.request.RaptorRequest) TripSchedule(org.opentripplanner.routing.algorithm.raptor.transit.TripSchedule) RaptorTransfer(org.opentripplanner.transit.raptor.api.transit.RaptorTransfer) RaptorProfile(org.opentripplanner.transit.raptor.api.request.RaptorProfile) RaptorRequestBuilder(org.opentripplanner.transit.raptor.api.request.RaptorRequestBuilder) ZonedDateTime(java.time.ZonedDateTime) Collection(java.util.Collection) SlackProvider(org.opentripplanner.routing.algorithm.raptor.transit.SlackProvider) Optimization(org.opentripplanner.transit.raptor.api.request.Optimization) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) Collectors(java.util.stream.Collectors) SlackProvider(org.opentripplanner.routing.algorithm.raptor.transit.SlackProvider) RaptorTransfer(org.opentripplanner.transit.raptor.api.transit.RaptorTransfer) TripSchedule(org.opentripplanner.routing.algorithm.raptor.transit.TripSchedule) RaptorRequestBuilder(org.opentripplanner.transit.raptor.api.request.RaptorRequestBuilder)

Example 24 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class StreetTransitLink method traverse.

public State traverse(State s0) {
    // if they are for the same stop.
    if (s0.backEdge instanceof StreetTransitLink && ((StreetTransitLink) s0.backEdge).stopVertex == this.stopVertex) {
        return null;
    }
    RoutingRequest req = s0.getOptions();
    if (s0.getOptions().wheelchairAccessible && !wheelchairAccessible) {
        return null;
    }
    if (s0.getOptions().bikeParkAndRide && !s0.isBikeParked()) {
        // Forbid taking your own bike in the station if bike P+R activated.
        return null;
    }
    if (s0.isBikeRenting()) {
        // TODO Check this condition, does this always make sense?
        return null;
    }
    // Do not check here whether any transit modes are selected. A check for the presence of
    // transit modes will instead be done in the following PreBoard edge.
    // This allows searching for nearby transit stops using walk-only options.
    StateEditor s1 = s0.edit(this);
    /* Note that in arriveBy searches this is double-traversing link edges to fork the state into both WALK and CAR mode. This is an insane hack. */
    if (s0.getNonTransitMode() == TraverseMode.CAR) {
        if (req.carPickup && !s0.isCarParked()) {
            s1.setCarParked(true);
        } else {
            return null;
        }
    }
    int streetToStopTime = stopVertex.hasPathways() ? 0 : stopVertex.getStreetToStopTime();
    // We do not increase the time here, so that searching from the stop coordinates instead of
    // the stop id catch transit departing at that exact search time.
    s1.incrementTimeInSeconds(streetToStopTime);
    s1.incrementWeight(STL_TRAVERSE_COST + streetToStopTime);
    return s1.makeState();
}
Also used : StateEditor(org.opentripplanner.routing.core.StateEditor) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest)

Example 25 with RoutingRequest

use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.

the class TimetableTest method testUpdate.

@Test
public void testUpdate() {
    TripUpdate tripUpdate;
    TripUpdate.Builder tripUpdateBuilder;
    TripDescriptor.Builder tripDescriptorBuilder;
    StopTimeUpdate.Builder stopTimeUpdateBuilder;
    StopTimeEvent.Builder stopTimeEventBuilder;
    String feedId = graph.getFeedIds().iterator().next();
    int trip_1_1_index = timetable.getTripIndex(new FeedScopedId("agency", "1.1"));
    Vertex stop_a = graph.getVertex(feedId + ":A");
    Vertex stop_c = graph.getVertex(feedId + ":C");
    RoutingRequest options = new RoutingRequest();
    ShortestPathTree spt;
    GraphPath path;
    // non-existing trip
    tripDescriptorBuilder = TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("b");
    tripDescriptorBuilder.setScheduleRelationship(TripDescriptor.ScheduleRelationship.CANCELED);
    tripUpdateBuilder = TripUpdate.newBuilder();
    tripUpdateBuilder.setTrip(tripDescriptorBuilder);
    tripUpdate = tripUpdateBuilder.build();
    TripTimes updatedTripTimes = timetable.createUpdatedTripTimes(tripUpdate, timeZone, serviceDate);
    assertNull(updatedTripTimes);
    // update trip with bad data
    tripDescriptorBuilder = TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1.1");
    tripDescriptorBuilder.setScheduleRelationship(TripDescriptor.ScheduleRelationship.SCHEDULED);
    tripUpdateBuilder = TripUpdate.newBuilder();
    tripUpdateBuilder.setTrip(tripDescriptorBuilder);
    stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(0);
    stopTimeUpdateBuilder.setStopSequence(0);
    stopTimeUpdateBuilder.setScheduleRelationship(StopTimeUpdate.ScheduleRelationship.SKIPPED);
    tripUpdate = tripUpdateBuilder.build();
    updatedTripTimes = timetable.createUpdatedTripTimes(tripUpdate, timeZone, serviceDate);
    assertNull(updatedTripTimes);
    // update trip with non-increasing data
    tripDescriptorBuilder = TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1.1");
    tripDescriptorBuilder.setScheduleRelationship(TripDescriptor.ScheduleRelationship.SCHEDULED);
    tripUpdateBuilder = TripUpdate.newBuilder();
    tripUpdateBuilder.setTrip(tripDescriptorBuilder);
    stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(0);
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setScheduleRelationship(StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeEventBuilder = stopTimeUpdateBuilder.getArrivalBuilder();
    stopTimeEventBuilder.setTime(TestUtils.dateInSeconds("America/New_York", 2009, AUGUST, 7, 0, 10, 1));
    stopTimeEventBuilder = stopTimeUpdateBuilder.getDepartureBuilder();
    stopTimeEventBuilder.setTime(TestUtils.dateInSeconds("America/New_York", 2009, AUGUST, 7, 0, 10, 0));
    tripUpdate = tripUpdateBuilder.build();
    updatedTripTimes = timetable.createUpdatedTripTimes(tripUpdate, timeZone, serviceDate);
    assertNull(updatedTripTimes);
    // ---
    long startTime = TestUtils.dateInSeconds("America/New_York", 2009, AUGUST, 7, 0, 0, 0);
    long endTime;
    options.dateTime = startTime;
    // ---
    options.setRoutingContext(graph, stop_a, stop_c);
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(stop_c, false);
    assertNotNull(path);
    endTime = startTime + 20 * 60;
    assertEquals(endTime, path.getEndTime());
    // update trip
    tripDescriptorBuilder = TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1.1");
    tripDescriptorBuilder.setScheduleRelationship(TripDescriptor.ScheduleRelationship.SCHEDULED);
    tripUpdateBuilder = TripUpdate.newBuilder();
    tripUpdateBuilder.setTrip(tripDescriptorBuilder);
    stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(0);
    stopTimeUpdateBuilder.setStopSequence(1);
    stopTimeUpdateBuilder.setScheduleRelationship(StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeEventBuilder = stopTimeUpdateBuilder.getArrivalBuilder();
    stopTimeEventBuilder.setTime(TestUtils.dateInSeconds("America/New_York", 2009, AUGUST, 7, 0, 2, 0));
    stopTimeEventBuilder = stopTimeUpdateBuilder.getDepartureBuilder();
    stopTimeEventBuilder.setTime(TestUtils.dateInSeconds("America/New_York", 2009, AUGUST, 7, 0, 2, 0));
    tripUpdate = tripUpdateBuilder.build();
    assertEquals(20 * 60, timetable.getTripTimes(trip_1_1_index).getArrivalTime(2));
    updatedTripTimes = timetable.createUpdatedTripTimes(tripUpdate, timeZone, serviceDate);
    assertNotNull(updatedTripTimes);
    timetable.setTripTimes(trip_1_1_index, updatedTripTimes);
    assertEquals(20 * 60 + 120, timetable.getTripTimes(trip_1_1_index).getArrivalTime(2));
    // ---
    options.setRoutingContext(graph, stop_a, stop_c);
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(stop_c, false);
    assertNotNull(path);
    endTime = startTime + 20 * 60 + 120;
    assertEquals(endTime, path.getEndTime());
    // cancel trip
    tripDescriptorBuilder = TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1.1");
    tripDescriptorBuilder.setScheduleRelationship(TripDescriptor.ScheduleRelationship.CANCELED);
    tripUpdateBuilder = TripUpdate.newBuilder();
    tripUpdateBuilder.setTrip(tripDescriptorBuilder);
    tripUpdate = tripUpdateBuilder.build();
    updatedTripTimes = timetable.createUpdatedTripTimes(tripUpdate, timeZone, serviceDate);
    assertNotNull(updatedTripTimes);
    timetable.setTripTimes(trip_1_1_index, updatedTripTimes);
    TripTimes tripTimes = timetable.getTripTimes(trip_1_1_index);
    for (int i = 0; i < tripTimes.getNumStops(); i++) {
        assertEquals(TripTimes.UNAVAILABLE, tripTimes.getDepartureTime(i));
        assertEquals(TripTimes.UNAVAILABLE, tripTimes.getArrivalTime(i));
    }
    // ---
    options.setRoutingContext(graph, stop_a, stop_c);
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(stop_c, false);
    assertNotNull(path);
    endTime = startTime + 40 * 60;
    assertEquals(endTime, path.getEndTime());
    // update trip arrival time incorrectly
    tripDescriptorBuilder = TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1.1");
    tripDescriptorBuilder.setScheduleRelationship(TripDescriptor.ScheduleRelationship.SCHEDULED);
    tripUpdateBuilder = TripUpdate.newBuilder();
    tripUpdateBuilder.setTrip(tripDescriptorBuilder);
    stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(0);
    stopTimeUpdateBuilder.setStopSequence(1);
    stopTimeUpdateBuilder.setScheduleRelationship(StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeEventBuilder = stopTimeUpdateBuilder.getArrivalBuilder();
    stopTimeEventBuilder.setDelay(0);
    tripUpdate = tripUpdateBuilder.build();
    updatedTripTimes = timetable.createUpdatedTripTimes(tripUpdate, timeZone, serviceDate);
    assertNotNull(updatedTripTimes);
    timetable.setTripTimes(trip_1_1_index, updatedTripTimes);
    // update trip arrival time only
    tripDescriptorBuilder = TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1.1");
    tripDescriptorBuilder.setScheduleRelationship(TripDescriptor.ScheduleRelationship.SCHEDULED);
    tripUpdateBuilder = TripUpdate.newBuilder();
    tripUpdateBuilder.setTrip(tripDescriptorBuilder);
    stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(0);
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setScheduleRelationship(StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeEventBuilder = stopTimeUpdateBuilder.getArrivalBuilder();
    stopTimeEventBuilder.setDelay(1);
    tripUpdate = tripUpdateBuilder.build();
    updatedTripTimes = timetable.createUpdatedTripTimes(tripUpdate, timeZone, serviceDate);
    assertNotNull(updatedTripTimes);
    timetable.setTripTimes(trip_1_1_index, updatedTripTimes);
    // update trip departure time only
    tripDescriptorBuilder = TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1.1");
    tripDescriptorBuilder.setScheduleRelationship(TripDescriptor.ScheduleRelationship.SCHEDULED);
    tripUpdateBuilder = TripUpdate.newBuilder();
    tripUpdateBuilder.setTrip(tripDescriptorBuilder);
    stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(0);
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setScheduleRelationship(StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeEventBuilder = stopTimeUpdateBuilder.getDepartureBuilder();
    stopTimeEventBuilder.setDelay(-1);
    tripUpdate = tripUpdateBuilder.build();
    updatedTripTimes = timetable.createUpdatedTripTimes(tripUpdate, timeZone, serviceDate);
    assertNotNull(updatedTripTimes);
    timetable.setTripTimes(trip_1_1_index, updatedTripTimes);
    // update trip using stop id
    tripDescriptorBuilder = TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1.1");
    tripDescriptorBuilder.setScheduleRelationship(TripDescriptor.ScheduleRelationship.SCHEDULED);
    tripUpdateBuilder = TripUpdate.newBuilder();
    tripUpdateBuilder.setTrip(tripDescriptorBuilder);
    stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(0);
    stopTimeUpdateBuilder.setStopId("B");
    stopTimeUpdateBuilder.setScheduleRelationship(StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeEventBuilder = stopTimeUpdateBuilder.getDepartureBuilder();
    stopTimeEventBuilder.setDelay(-1);
    tripUpdate = tripUpdateBuilder.build();
    updatedTripTimes = timetable.createUpdatedTripTimes(tripUpdate, timeZone, serviceDate);
    assertNotNull(updatedTripTimes);
    timetable.setTripTimes(trip_1_1_index, updatedTripTimes);
    // update trip arrival time at first stop and make departure time incoherent at second stop
    tripDescriptorBuilder = TripDescriptor.newBuilder();
    tripDescriptorBuilder.setTripId("1.1");
    tripDescriptorBuilder.setScheduleRelationship(TripDescriptor.ScheduleRelationship.SCHEDULED);
    tripUpdateBuilder = TripUpdate.newBuilder();
    tripUpdateBuilder.setTrip(tripDescriptorBuilder);
    stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(0);
    stopTimeUpdateBuilder.setStopSequence(1);
    stopTimeUpdateBuilder.setScheduleRelationship(StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeEventBuilder = stopTimeUpdateBuilder.getArrivalBuilder();
    stopTimeEventBuilder.setDelay(0);
    stopTimeUpdateBuilder = tripUpdateBuilder.addStopTimeUpdateBuilder(1);
    stopTimeUpdateBuilder.setStopSequence(2);
    stopTimeUpdateBuilder.setScheduleRelationship(StopTimeUpdate.ScheduleRelationship.SCHEDULED);
    stopTimeEventBuilder = stopTimeUpdateBuilder.getDepartureBuilder();
    stopTimeEventBuilder.setDelay(-1);
    tripUpdate = tripUpdateBuilder.build();
    updatedTripTimes = timetable.createUpdatedTripTimes(tripUpdate, timeZone, serviceDate);
    assertNull(updatedTripTimes);
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) TripUpdate(com.google.transit.realtime.GtfsRealtime.TripUpdate) GraphPath(org.opentripplanner.routing.spt.GraphPath) StopTimeEvent(com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeEvent) TripDescriptor(com.google.transit.realtime.GtfsRealtime.TripDescriptor) ShortestPathTree(org.opentripplanner.routing.spt.ShortestPathTree) StopTimeUpdate(com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate) TripTimes(org.opentripplanner.routing.trippattern.TripTimes) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) Test(org.junit.Test)

Aggregations

RoutingRequest (org.opentripplanner.routing.api.request.RoutingRequest)102 GraphPath (org.opentripplanner.routing.spt.GraphPath)50 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)42 Test (org.junit.Test)37 State (org.opentripplanner.routing.core.State)33 Vertex (org.opentripplanner.routing.graph.Vertex)31 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)18 Edge (org.opentripplanner.routing.graph.Edge)17 TransitStopVertex (org.opentripplanner.routing.vertextype.TransitStopVertex)17 AStar (org.opentripplanner.routing.algorithm.astar.AStar)16 Graph (org.opentripplanner.routing.graph.Graph)15 StateEditor (org.opentripplanner.routing.core.StateEditor)13 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)13 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)11 NonLocalizedString (org.opentripplanner.util.NonLocalizedString)10 HashSet (java.util.HashSet)9 TemporaryStreetLocation (org.opentripplanner.routing.location.TemporaryStreetLocation)9 TraverseMode (org.opentripplanner.routing.core.TraverseMode)7 ArrayList (java.util.ArrayList)6 Coordinate (org.locationtech.jts.geom.Coordinate)6