Package org.opentripplanner.routing.edgetype

Examples of org.opentripplanner.routing.edgetype.TimetableResolver


     * Apply an update to a table trip pattern and check whether the update was applied correctly
     */
    private void applyUpdateToTripPattern(TripPattern pattern, String tripId, String stopId,
            int stopSeq, int arrive, int depart, ScheduleRelationship scheduleRelationship,
            int timestamp, ServiceDate serviceDate) throws ParseException {
        TimetableResolver snapshot = graph.timetableSnapshotSource.getTimetableSnapshot();
        Timetable timetable = snapshot.resolve(pattern, serviceDate);
        TimeZone timeZone = new SimpleTimeZone(-7, "PST");
        long today = serviceDate.getAsDate(timeZone).getTime() / 1000;
        TripDescriptor.Builder tripDescriptorBuilder = TripDescriptor.newBuilder();

        tripDescriptorBuilder.setTripId(tripId);
View Full Code Here


       
        Vertex from = new TransitStop(graph, stop1);
        Vertex to = new TransitStop(graph, stop2);
       
        // Create dummy TimetableResolver
        TimetableResolver resolver = new TimetableResolver();
       
        // Mock TimetableSnapshotSource to return dummy TimetableResolver
        TimetableSnapshotSource source = mock(TimetableSnapshotSource.class);
        when(source.getTimetableSnapshot()).thenReturn(resolver);
        graph.timetableSnapshotSource = (source);
View Full Code Here

        // Add simple transfer to make transfer possible between U-V and I-J
        createSimpleTransfer("agency:V", "agency:I", 100);

        // Create dummy TimetableResolver
        TimetableResolver resolver = new TimetableResolver();

        // Mock TimetableSnapshotSource to return dummy TimetableResolver
        TimetableSnapshotSource timetableSnapshotSource = mock(TimetableSnapshotSource.class);

        when(timetableSnapshotSource.getTimetableSnapshot()).thenReturn(resolver);
View Full Code Here

     */
    private void applyUpdateToTripPattern(TripPattern pattern, String tripId, String stopId,
            int stopSeq, int arrive, int depart, ScheduleRelationship scheduleRelationship,
            int timestamp, ServiceDate serviceDate) throws ParseException {
        Graph graph = Context.getInstance().graph;
        TimetableResolver snapshot = graph.timetableSnapshotSource.getTimetableSnapshot();
        Timetable timetable = snapshot.resolve(pattern, serviceDate);
        TimeZone timeZone = new SimpleTimeZone(-7, "PST");
        long today = serviceDate.getAsDate(timeZone).getTime() / 1000;
        TripDescriptor.Builder tripDescriptorBuilder = TripDescriptor.newBuilder();

        tripDescriptorBuilder.setTripId(tripId);
View Full Code Here

        // to make test results more deterministic, only find the single best path
        // If this is really needed, it should be set in the RoutingRequest in individual tests
        //((GenericAStar) otpServer.sptService).nPaths = (1);

        // Create dummy TimetableResolver
        TimetableResolver resolver = new TimetableResolver();

        // Mock TimetableSnapshotSource to return dummy TimetableResolver
        TimetableSnapshotSource timetableSnapshotSource = mock(TimetableSnapshotSource.class);

        when(timetableSnapshotSource.getTimetableSnapshot()).thenReturn(resolver);
View Full Code Here

        int tripIndex = pattern.scheduledTimetable.getTripIndex(tripId);
        int tripIndex2 = pattern.scheduledTimetable.getTripIndex(tripId2);

        updater.applyTripUpdates(Arrays.asList(TripUpdate.parseFrom(cancellation)), "agency");

        TimetableResolver resolver = updater.getTimetableSnapshot();
        Timetable forToday = resolver.resolve(pattern, serviceDate);
        Timetable schedule = resolver.resolve(pattern, null);
        assertNotSame(forToday, schedule);
        assertNotSame(forToday.getTripTimes(tripIndex), schedule.getTripTimes(tripIndex));
        assertSame(forToday.getTripTimes(tripIndex2), schedule.getTripTimes(tripIndex2));

        TripTimes tripTimes = forToday.getTripTimes(tripIndex);
View Full Code Here

        TripUpdate tripUpdate = tripUpdateBuilder.build();

        updater.applyTripUpdates(Arrays.asList(tripUpdate), "agency");

        TimetableResolver resolver = updater.getTimetableSnapshot();
        Timetable forToday = resolver.resolve(pattern, serviceDate);
        Timetable schedule = resolver.resolve(pattern, null);
        assertNotSame(forToday, schedule);
        assertNotSame(forToday.getTripTimes(tripIndex), schedule.getTripTimes(tripIndex));
        assertSame(forToday.getTripTimes(tripIndex2), schedule.getTripTimes(tripIndex2));
        assertEquals(1, forToday.getTripTimes(tripIndex).getArrivalDelay(1));
        assertEquals(1, forToday.getTripTimes(tripIndex).getDepartureDelay(1));
View Full Code Here

        updater.maxSnapshotFrequency = (0);
        updater.purgeExpiredData = (false);

        updater.applyTripUpdates(Arrays.asList(TripUpdate.parseFrom(cancellation)), "agency");
        TimetableResolver resolverA = updater.getTimetableSnapshot();

        updater.purgeExpiredData = (true);

        TripDescriptor.Builder tripDescriptorBuilder = TripDescriptor.newBuilder();

        tripDescriptorBuilder.setTripId("1.1");
        tripDescriptorBuilder.setScheduleRelationship(TripDescriptor.ScheduleRelationship.CANCELED);
        tripDescriptorBuilder.setStartDate(previously.getAsString());

        TripUpdate.Builder tripUpdateBuilder = TripUpdate.newBuilder();

        tripUpdateBuilder.setTrip(tripDescriptorBuilder);

        TripUpdate tripUpdate = tripUpdateBuilder.build();

        updater.applyTripUpdates(Arrays.asList(tripUpdate), "agency");
        TimetableResolver resolverB = updater.getTimetableSnapshot();

        assertNotSame(resolverA, resolverB);

        assertSame   (resolverA.resolve(pattern, null ), resolverB.resolve(pattern, null ));
        assertSame   (resolverA.resolve(pattern, serviceDate),
                resolverB.resolve(pattern, serviceDate));
        assertNotSame(resolverA.resolve(pattern, null ), resolverA.resolve(pattern, serviceDate));
        assertSame   (resolverB.resolve(pattern, null ), resolverB.resolve(pattern, previously));

        // TODO: write test for added trips
    }
View Full Code Here

    @Test
    public void testGetSnapshot() throws InvalidProtocolBufferException {
        updater.applyTripUpdates(Arrays.asList(TripUpdate.parseFrom(cancellation)), "agency");

        TimetableResolver resolver = updater.getTimetableSnapshot();
        assertNotNull(resolver);
        assertSame(resolver, updater.getTimetableSnapshot());

        updater.applyTripUpdates(Arrays.asList(TripUpdate.parseFrom(cancellation)), "agency");
        assertSame(resolver, updater.getTimetableSnapshot());

        updater.maxSnapshotFrequency = (-1);
        TimetableResolver newResolver = updater.getTimetableSnapshot();
        assertNotNull(newResolver);
        assertNotSame(resolver, newResolver);
    }
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.edgetype.TimetableResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.