Package org.opentripplanner.routing.spt

Examples of org.opentripplanner.routing.spt.ShortestPathTree


    public void testForwardAsPedestrian() {
        RoutingRequest options = new RoutingRequest(TraverseMode.WALK);
        options.walkSpeed = 1.0;
       
        options.setRoutingContext(_graph, topRight, bottomLeft);
        ShortestPathTree tree = new GenericAStar().getShortestPathTree(options);

        GraphPath path = tree.getPath(bottomLeft, false);
        assertNotNull(path);

        // Since there are no turn restrictions applied to the default modes (walking + transit)
        // the shortest path is 1st to Main, Main to 2nd, 2nd to Broad and Broad until the
        // corner of Broad and 3rd.
View Full Code Here


    public void testForwardAsCar() {
        RoutingRequest options = new RoutingRequest(TraverseMode.CAR);
        options.carSpeed = 1.0;

        options.setRoutingContext(_graph, topRight, bottomLeft);
        ShortestPathTree tree = new GenericAStar().getShortestPathTree(options);

        GraphPath path = tree.getPath(bottomLeft, false);
        assertNotNull(path);

        // If not for turn restrictions, the shortest path would be to take 1st to Main,
        // Main to 2nd, 2nd to Broad and Broad until the corner of Broad and 3rd.
        // However, most of these turns are not allowed. Instead, the shortest allowed
View Full Code Here

    public void testForwardAsCustomMotorVehicle() {
        RoutingRequest options = new RoutingRequest(TraverseMode.CUSTOM_MOTOR_VEHICLE);
        options.carSpeed = 1.0;

        options.setRoutingContext(_graph, topRight, bottomLeft);
        ShortestPathTree tree = new GenericAStar().getShortestPathTree(options);

        GraphPath path = tree.getPath(bottomLeft, false);
        assertNotNull(path);

        // If not for turn restrictions, the shortest path would be to take 1st to Main,
        // Main to 2nd, 2nd to Broad and Broad until the corner of Broad and 3rd.
        // However, most of these turns are not allowed. Instead, the shortest allowed
View Full Code Here

        Vertex stop_a = graph.getVertex("agency:A");
        Vertex stop_c = graph.getVertex("agency:C");
        Vertex stop_e = graph.getVertex("agency:E");

        ShortestPathTree spt;
        GraphPath path;

        RoutingRequest options = new RoutingRequest();
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 0, 0);
        options.setRoutingContext(graph, stop_a.getLabel(), stop_e.getLabel());
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(stop_e, false); /* do not optimize yet, since we are testing optimization */
        assertNotNull(path);

        // Check that the resulting path visits the stops in the right order.
        List<Vertex> stopvs = Lists.newArrayList();
        for (State state : path.states) {
            if (state.getVertex() instanceof TransitStop) {
                stopvs.add(state.getVertex());
            }
        }
        assertTrue(stopvs.get(0) == stop_a);
        assertTrue(stopvs.get(1) == stop_c);
        assertTrue(stopvs.get(2) == stop_e);

        long bestStart = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 20, 0);
        assertNotSame(bestStart, path.getStartTime());

        path = spt.getPath(stop_e, true); /* optimize */
        assertEquals(bestStart, path.getStartTime());
    }
View Full Code Here

        gg.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
        RoutingRequest options = new RoutingRequest();
        long startTime = TestUtils.dateInSeconds("America/Los_Angeles", 2009, 8, 7, 12, 0, 0);
        options.dateTime = startTime;
        options.setRoutingContext(gg, "Caltrain:Millbrae Caltrain", "Caltrain:Mountain View Caltrain");
        ShortestPathTree spt;
        GraphPath path = null;
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(gg.getVertex("Caltrain:Mountain View Caltrain"), true);

        FareService fareService = gg.getService(FareService.class);
       
        Fare cost = fareService.getCost(path);
        assertEquals(cost.getFare(FareType.regular), new Money(new WrappedCurrency("USD"), 425));
View Full Code Here

    public void testPortland() throws Exception {

        Graph gg = ConstantsForTests.getInstance().getPortlandGraph();
        RoutingRequest options = new RoutingRequest();
        ShortestPathTree spt;
        GraphPath path = null;
        long startTime = TestUtils.dateInSeconds("America/Los_Angeles", 2009, 11, 1, 12, 0, 0);
        options.dateTime = startTime;
        options.setRoutingContext(gg, "TriMet:10579", "TriMet:8371");
        // from zone 3 to zone 2
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(gg.getVertex("TriMet:8371"), true);
        assertNotNull(path);

        FareService fareService = gg.getService(FareService.class);
        Fare cost = fareService.getCost(path);
        assertEquals(new Money(new WrappedCurrency("USD"), 200), cost.getFare(FareType.regular));

        // long trip

        startTime = TestUtils.dateInSeconds("America/Los_Angeles", 2009, 11, 1, 14, 0, 0);
        options.dateTime = startTime;
        options.setRoutingContext(gg, "TriMet:8389", "TriMet:1252");
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(gg.getVertex("TriMet:1252"), true);
        assertNotNull(path);
        cost = fareService.getCost(path);
       
        //assertEquals(cost.getFare(FareType.regular), new Money(new WrappedCurrency("USD"), 460));
       
        // complex trip
        options.maxTransfers = 5;
        startTime = TestUtils.dateInSeconds("America/Los_Angeles", 2009, 11, 1, 14, 0, 0);
        options.dateTime = startTime;
        options.setRoutingContext(gg, "TriMet:10428", "TriMet:4231");
        spt = aStar.getShortestPathTree(options);

        path = spt.getPath(gg.getVertex("TriMet:4231"), true);
        assertNotNull(path);
        cost = fareService.getCost(path);
        //
        // this is commented out because portland's fares are, I think, broken in the gtfs. see
        // thread on gtfs-changes.
View Full Code Here

        GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
        factory.run(gg);
        gg.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
        RoutingRequest options = new RoutingRequest();
       
        ShortestPathTree spt;
        GraphPath path = null;

        options.dateTime = TestUtils.dateInSeconds("America/Los_Angeles", 2009, 8, 7, 12, 0, 0);
        options.setRoutingContext(gg, "Caltrain:Millbrae Caltrain", "Caltrain:Mountain View Caltrain");
        spt = aStar.getShortestPathTree(options);
        path = spt.getPath(gg.getVertex("Caltrain:Mountain View Caltrain"), true);

        long endTime = TestUtils.dateInSeconds("America/Los_Angeles", 2009, 8, 7, 13, 29, 0);

        assertEquals(path.getEndTime(), endTime);

        /* test backwards traversal */
        options.setArriveBy(true);
        options.dateTime = endTime;
        options.setRoutingContext(gg, "Caltrain:Millbrae Caltrain", "Caltrain:Mountain View Caltrain");
        spt = aStar.getShortestPathTree(options);
        path = spt.getPath(gg.getVertex("Caltrain:Millbrae Caltrain"), true);

        long expectedStartTime = TestUtils.dateInSeconds("America/Los_Angeles", 2009, 8, 7, 12, 39, 0);

        assertTrue(path.getStartTime() - expectedStartTime <= 1);

View Full Code Here

        options.dateTime = startTime;
        // one hour is more than enough time
        options.worstTime = startTime + 60 * 60;
        options.setRoutingContext(graph, start, end);

        ShortestPathTree spt = aStar.getShortestPathTree(options);
        GraphPath path = spt.getPath(end, true);
        assertNotNull(path);
       
        // but one minute is not enough
        options.worstTime = startTime + 60;
        spt = aStar.getShortestPathTree(options);
        path = spt.getPath(end, true);
        assertNull(path);       
    }
View Full Code Here

    @Test
    public void testForward() {
        RoutingRequest options = new RoutingRequest();
        options.walkSpeed = 1.0;
        options.setRoutingContext(_graph, _graph.getVertex("56th_24th"), _graph.getVertex("leary_20th"));
        ShortestPathTree tree = new GenericAStar().getShortestPathTree(options);

        GraphPath path = tree.getPath(_graph.getVertex("leary_20th"), false);

        List<State> states = path.states;

        assertEquals(7, states.size());
View Full Code Here

        RoutingRequest options = new RoutingRequest();
        options.walkSpeed = 1.0;
        options.setArriveBy(true);
        options.setRoutingContext(_graph, _graph.getVertex("56th_24th"),
                _graph.getVertex("leary_20th"));
        ShortestPathTree tree = new GenericAStar().getShortestPathTree(options);

        GraphPath path = tree.getPath(_graph.getVertex("56th_24th"), false);

        List<State> states = path.states;

        assertTrue(states.size() == 6 || states.size() == 7);
View Full Code Here

TOP

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

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.