Package org.opentripplanner.routing.spt

Examples of org.opentripplanner.routing.spt.GraphPath


        long startTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 0, 0);
        options.dateTime = startTime;

        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(6, path.states.size());

        // A to C
        options.setRoutingContext(graph, stop_a, stop_c);
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(stop_c, false);
        assertNotNull(path);
        assertEquals(8, path.states.size());

        // A to D (change at C)
        options.setRoutingContext(graph, stop_a, stop_d);
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(stop_d, false);
        assertNotNull(path);
        // there are two paths of different lengths
        // both arrive at 40 minutes after midnight
        List<TransitStop> stops = extractStopVertices(path);
        assertEquals(stops.size(), 3);
        assertEquals(stops.get(1), stop_c);
        long endTime = startTime + 40 * 60;
        assertEquals(endTime, path.getEndTime());

        //A to E (change at C)
        options.setRoutingContext(graph, stop_a, stop_e);
        spt = aStar.getShortestPathTree(options);
        path = spt.getPath(stop_e, false);
        assertNotNull(path);
        stops = extractStopVertices(path);
        assertEquals(stops.size(), 3);
        assertEquals(stops.get(1), stop_c);
        endTime = startTime + 70 * 60;
        assertEquals(endTime, path.getEndTime());
    }
View Full Code Here


        // this route only runs on weekdays
        Vertex stop_g = graph.getVertex("agency:G_depart");
        Vertex stop_h = graph.getVertex("agency:H_arrive");

        ShortestPathTree spt;
        GraphPath path;
        RoutingRequest options = new RoutingRequest();

        // Friday evening
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 18, 23, 20, 0);
        options.setRoutingContext(graph, stop_g, stop_h);
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(stop_h, false);
        assertNotNull(path);
        assertEquals(4, path.states.size());

        // Saturday morning
        long startTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 19, 0, 5, 0);
        options.dateTime = startTime;
        options.setRoutingContext(graph, stop_g.getLabel(), stop_h.getLabel());
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(stop_h, false);
        assertNotNull(path);
        assertEquals(4, path.states.size());
        long endTime = path.getEndTime();
        assertTrue(endTime < startTime + 60 * 60);
    }
View Full Code Here

        long startTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 19, 12, 0, 0);
        RoutingRequest options = new RoutingRequest();
        options.dateTime = startTime;
        options.setRoutingContext(graph, stop_o, stop_p);
        ShortestPathTree spt = aStar.getShortestPathTree(options);
        GraphPath path = spt.getPath(stop_p, false);
        assertNotNull(path);
        long endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 19, 12, 10, 0);
        assertEquals(endTime, path.getEndTime());

        startTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 19, 12, 0, 1);
        options.dateTime = startTime;
        options.setRoutingContext(graph, stop_o, stop_p);
        spt = aStar.getShortestPathTree(options);
        path = spt.getPath(stop_p, false);
        assertNotNull(path);
        endTime =  TestUtils.dateInSeconds("America/New_York", 2009, 8, 19, 15, 10, 0);
        assertEquals(endTime, path.getEndTime());
    }
View Full Code Here

        RoutingRequest options = new RoutingRequest();
        options.dateTime = startTime;
        options.setRoutingContext(graph, stop_b, stop_g);
        ShortestPathTree spt = aStar.getShortestPathTree(options);
       
        GraphPath path = spt.getPath(stop_g, false);
        assertNotNull(path);
       
        assertTrue("expected to use much later trip due to min transfer time", path.getEndTime() - startTime > 4.5 * 60 * 60);
       
        /* cleanup */
        e_arrive.removeOutgoing(edge);
        f_depart.removeIncoming(edge);
    }
View Full Code Here

        RoutingRequest options = new RoutingRequest();
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 1, 10, 0, 0);
        options.setRoutingContext(graph, stop_d, stop_c);
        ShortestPathTree spt = aStar.getShortestPathTree(options);

        GraphPath path = spt.getPath(stop_c, false);
        assertNotNull(path);
        assertEquals(TestUtils.dateInSeconds("America/New_York", 2009, 8, 1, 11, 0, 0), path.getEndTime());
    }
View Full Code Here

        options.modes.setTransit(true);
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 18, 0, 0, 0);
        options.setRoutingContext(graph, stop_a, stop_b);

        ShortestPathTree spt;
        GraphPath path;

        // route: bikes allowed, trip: no value
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(stop_b, false);
View Full Code Here

        RoutingRequest options = new RoutingRequest();
        options.wheelchairAccessible = true;
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 18, 0, 0, 0);

        ShortestPathTree spt;
        GraphPath path;

        // stop B is accessible, so there should be a path.
        options.setRoutingContext(graph, near_a, near_b);
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(near_b, false);
        assertNotNull(path);

        // stop C is not accessible, so there should be no path.
        options.setRoutingContext(graph, near_a, near_c);
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(near_c, false);
        assertNull(path);
       
        // stop E has no accessibility information, but we should still be able to route to it.
        options.setRoutingContext(graph, near_a, near_e);
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(near_e, false);
        assertNotNull(path);

        // from stop A to stop D would normally be trip 1.1 to trip 2.1, arriving at 00:30. But trip
        // 2 is not accessible, so we'll do 1.1 to 3.1, arriving at 01:00
        GregorianCalendar time = new GregorianCalendar(2009, 8, 18, 0, 0, 0);
        time.setTimeZone(TimeZone.getTimeZone("America/New_York"));
        options.dateTime = TestUtils.toSeconds(time);
        options.setRoutingContext(graph, near_a, split_d);
        spt = aStar.getShortestPathTree(options);
       
        time.add(Calendar.HOUR, 1);
        time.add(Calendar.SECOND, 1); //for the StreetTransitLink
        path = spt.getPath(split_d, false);
        assertNotNull(path);
        assertEquals(TestUtils.toSeconds(time), path.getEndTime());
    }
View Full Code Here

        GregorianCalendar startTime = new GregorianCalendar(2009, 11, 2, 8, 30, 0);
        startTime.setTimeZone(TimeZone.getTimeZone("America/New_York"));
        options.dateTime = TestUtils.toSeconds(startTime);
        options.setRoutingContext(graph, "agency:Q", destination.getLabel());
        ShortestPathTree spt = aStar.getShortestPathTree(options);
        GraphPath path = spt.getPath(destination, false);

        long endTime = path.getEndTime();
        Calendar c = new GregorianCalendar();
        c.setTimeInMillis(endTime * 1000L);
        assertTrue(endTime - TestUtils.toSeconds(startTime) < 7200);
    }
View Full Code Here

    public void testFrequencies() {
        Vertex stop_u = graph.getVertex("agency:U_depart");
        Vertex stop_v = graph.getVertex("agency:V_arrive");

        ShortestPathTree spt;
        GraphPath path;

        RoutingRequest options = new RoutingRequest();
        options.setModes(new TraverseModeSet("TRANSIT"));
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 0, 0);
        options.setRoutingContext(graph, stop_u, stop_v);
       
        // U to V - original stop times - shouldn't be used
        spt = aStar.getShortestPathTree(options);
        path = spt.getPath(stop_v, false);
        assertNotNull(path);
        assertEquals(4, path.states.size());
        long endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 6, 40, 0);
        assertEquals(endTime, path.getEndTime());

        // U to V - first frequency
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 7, 0, 0);
        options.setRoutingContext(graph, stop_u, stop_v);
        spt = aStar.getShortestPathTree(options);
        path = spt.getPath(stop_v, false);
        assertNotNull(path);
        assertEquals(4, path.states.size());
        endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 7, 40, 0);
        assertEquals(endTime, path.getEndTime());

        // U to V - second frequency
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 14, 0, 0);
        options.setRoutingContext(graph, stop_u, stop_v);
        spt = aStar.getShortestPathTree(options);
        path = spt.getPath(stop_v, false);
        assertNotNull(path);
        assertEquals(4, path.states.size());
        endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 14, 40, 0);
        assertEquals(endTime, path.getEndTime());
       
        // TODO more detailed testing of frequencies

    }
View Full Code Here

        options.setRoutingContext(graph, stop_c, stop_d)
               
        ShortestPathTree spt = aStar.getShortestPathTree(options);

        //when optimizing for speed, take the fast two-bus path
        GraphPath path = spt.getPath(stop_d, false);
        assertNotNull(path);
        assertEquals(TestUtils.dateInSeconds("America/New_York", 2009, 8, 1, 16, 20, 0), path.getEndTime());
       
        //when optimizing for fewest transfers, take the slow one-bus path
        options.transferPenalty = 1800;
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(stop_d, false);
        assertNotNull(path);
        assertEquals(TestUtils.dateInSeconds("America/New_York", 2009, 8, 1, 16, 50, 0), path.getEndTime());

    }
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.spt.GraphPath

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.