Package org.opentripplanner.routing.core

Examples of org.opentripplanner.routing.core.RoutingRequest


                filter(turns, StreetEdge.class),
                new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()));

        // The alert should be preserved
        // traverse the FreeEdge from the StreetLocation to the new IntersectionVertex
        RoutingRequest req = new RoutingRequest();
        req.setMaxWalkDistance(Double.MAX_VALUE);
        State traversedOne = new State((Vertex) start, req);
        State currentState;
        for (Edge e : start.getOutgoing()) {
            currentState = e.traverse(traversedOne);
            if (currentState != null) {
                traversedOne = currentState;
                break;
            }
        }

        assertEquals(alerts, graph.streetNotesService.getNotes(traversedOne));
        assertNotSame(left, traversedOne.getBackEdge().getFromVertex());
        assertNotSame(leftBack, traversedOne.getBackEdge().getFromVertex());

        // now, make sure wheelchair alerts are preserved
        Alert wheelchairAlert = Alert.createSimpleAlerts("This is the wheelchair alert");
        Set<Alert> wheelchairAlerts = new HashSet<>();
        wheelchairAlerts.add(wheelchairAlert);

        graph.streetNotesService.removeStaticNotes(left);
        graph.streetNotesService.removeStaticNotes(leftBack);
        graph.streetNotesService.addStaticNote(left, wheelchairAlert,
                StreetNotesService.WHEELCHAIR_MATCHER);
        graph.streetNotesService.addStaticNote(leftBack, wheelchairAlert,
                StreetNotesService.WHEELCHAIR_MATCHER);

        req.setWheelchairAccessible(true);

        start = StreetLocation.createStreetLocation(graph, "start", "start",
                filter(turns, StreetEdge.class),
                new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()));
View Full Code Here


                start.isWheelchairAccessible());

        List<Edge> extras = start.getExtra();
        assertEquals(4, extras.size());

        RoutingRequest biking = new RoutingRequest(new TraverseModeSet(TraverseMode.BICYCLE));
        StreetLocation end = (StreetLocation) finder.getVertexForLocation(new GenericLocation(
                40.008, -74.0), biking);
        assertNotNull(end);

        extras = end.getExtra();
        assertEquals(4, extras.size());

        // test that the closest vertex finder also adds an edge to transit
        // stops (if you are really close to the transit stop relative to the
        // street)
        StreetLocation location = (StreetLocation) finder.getVertexForLocation(new GenericLocation(
                40.00999, -74.004999), new RoutingRequest());
        assertTrue(location.isWheelchairAccessible());
        boolean found = false;
        for (Edge extra : location.getExtra()) {
            if (extra instanceof FreeEdge && ((FreeEdge) extra).getToVertex().equals(station1)) {
                found = true;
            }
        }
        assertTrue(found);

        // test that it is possible to travel between two splits on the same street
        RoutingRequest walking = new RoutingRequest(TraverseMode.WALK);
        start = (StreetLocation) finder.getVertexForLocation(new GenericLocation(40.004, -74.0),
                walking);
        end = (StreetLocation) finder.getVertexForLocation(new GenericLocation(40.008, -74.0),
                walking);
        assertNotNull(end);
        // The visibility for temp edges for start and end is set in the setRoutingContext call
        walking.setRoutingContext(graph, start, end);
        ShortestPathTree spt = aStar.getShortestPathTree(walking);
        GraphPath path = spt.getPath(end, false);
        for (State s : path.states) {
            assertFalse(s.getBackEdge() == top);
        }
View Full Code Here

        // Hold onto some vertices for the tests
        topRight = maple1;
        bottomLeft = broad3;
       
        // Make a prototype routing request.
        proto = new RoutingRequest();
        proto.carSpeed = 1.0;
        proto.walkSpeed = 1.0;
        proto.bikeSpeed = 1.0;
        proto.turnReluctance = (1.0);
        proto.setWalkReluctance(1.0);
View Full Code Here

        return path;
    }
   
    @Test
    public void testForwardDefaultNoTurnCosts() {
        RoutingRequest options = proto.clone();
        options.setRoutingContext(_graph, topRight, bottomLeft);
       
        // Without turn costs, this path costs 2x100 + 2x50 = 300.
        checkForwardRouteDuration(options, 300);
    }
View Full Code Here

        checkForwardRouteDuration(options, 300);
    }
   
    @Test
    public void testForwardDefaultConstTurnCosts() {
        RoutingRequest options = proto.clone();
        options.traversalCostModel = (new ConstantIntersectionTraversalCostModel(10.0));
        options.setRoutingContext(_graph, topRight, bottomLeft);
       
        // Without turn costs, this path costs 2x100 + 2x50 = 300.
        // Since we traverse 3 intersections, the total cost should be 330.
        GraphPath path = checkForwardRouteDuration(options, 330);
       
View Full Code Here

        assertEquals(330, states.get(4).getElapsedTimeSeconds()); // broad2_3 = 100       
    }
       
    @Test
    public void testForwardCarNoTurnCosts() {
        RoutingRequest options = proto.clone();
        options.setMode(TraverseMode.CAR);
        options.setRoutingContext(_graph, topRight, bottomLeft);
       
        // Without turn costs, this path costs 3x100 + 1x50 = 300.
        GraphPath path = checkForwardRouteDuration(options, 350);
       
        List<State> states = path.states;
View Full Code Here

        assertEquals("broad_3rd", states.get(4).getVertex().getLabel());
    }
   
    @Test
    public void testForwardCarConstTurnCosts() {
        RoutingRequest options = proto.clone();
        options.traversalCostModel = (new ConstantIntersectionTraversalCostModel(10.0));
        options.setMode(TraverseMode.CAR);
        options.setRoutingContext(_graph, topRight, bottomLeft);
       
        // Without turn costs, this path costs 3x100 + 1x50 = 350.
        // Since there are 3 turns, the total cost should be 380.
        GraphPath path = checkForwardRouteDuration(options, 380);
       
View Full Code Here

    public void testCar() throws Exception {

        GenericAStar aStar = new GenericAStar();

        // It is impossible to get from A to C in WALK mode,
        RoutingRequest options = new RoutingRequest(new TraverseModeSet("WALK"));
        options.setRoutingContext(graph, A, C);
        ShortestPathTree tree = aStar.getShortestPathTree(options);
        GraphPath path = tree.getPath(C, false);
        assertNull(path);

        // or CAR+WALK (no P+R).
        options = new RoutingRequest("WALK,CAR");
        options.freezeTraverseMode();
        options.setRoutingContext(graph, A, C);
        tree = aStar.getShortestPathTree(options);
        path = tree.getPath(C, false);
        assertNull(path);

        // So we Add a P+R at B.
        ParkAndRideVertex PRB = new ParkAndRideVertex(graph, "P+R", "P+R.B", 0.001, 45.00001,
                "P+R B");
        new ParkAndRideEdge(PRB);
        new ParkAndRideLinkEdge(PRB, B);
        new ParkAndRideLinkEdge(B, PRB);

        // But it is still impossible to get from A to C by WALK only
        // (AB is CAR only).
        options = new RoutingRequest("WALK");
        options.freezeTraverseMode();
        options.setRoutingContext(graph, A, C);
        tree = aStar.getShortestPathTree(options);
        path = tree.getPath(C, false);
        assertNull(path);
       
        // Or CAR only (BC is WALK only).
        options = new RoutingRequest("CAR");
        options.freezeTraverseMode();
        options.setRoutingContext(graph, A, C);
        tree = aStar.getShortestPathTree(options);
        path = tree.getPath(C, false);
        assertNull(path);

        // But we can go from A to C with CAR+WALK mode using P+R.
        options = new RoutingRequest("WALK,CAR_PARK,TRANSIT");
        options.setRoutingContext(graph, A, C);
        tree = aStar.getShortestPathTree(options);
        path = tree.getPath(C, false);
        assertNotNull(path);
    }
View Full Code Here

    public void testBike() throws Exception {

        GenericAStar aStar = new GenericAStar();

        // Impossible to get from B to D in BIKE+WALK (no bike P+R).
        RoutingRequest options = new RoutingRequest("BICYCLE_PARK,TRANSIT");
        options.freezeTraverseMode();
        options.setRoutingContext(graph, B, D);
        ShortestPathTree tree = aStar.getShortestPathTree(options);
        GraphPath path = tree.getPath(D, false);
        assertNull(path);

        // So we add a bike P+R at C.
        BikePark bpc = new BikePark();
        bpc.id = "bpc";
        bpc.name = "Bike Park C";
        bpc.x = 0.002;
        bpc.y = 45.00001;
        bpc.spacesAvailable = 1;
        BikeParkVertex BPRC = new BikeParkVertex(graph, bpc);
        new BikeParkEdge(BPRC);
        new StreetBikeParkLink(BPRC, C);
        new StreetBikeParkLink(C, BPRC);

        // Still impossible from B to D by bike only (CD is WALK only).
        options = new RoutingRequest("BICYCLE");
        options.setRoutingContext(graph, B, D);
        tree = aStar.getShortestPathTree(options);
        path = tree.getPath(D, false);
        assertNotNull(path);
        State s = tree.getState(D);
        assertFalse(s.isBikeParked());
        // TODO backWalkingBike flag is broken
        // assertTrue(s.isBackWalkingBike());
        assertTrue(s.getBackMode() == TraverseMode.WALK);

        // But we can go from B to D with BICYCLE+WALK mode using bike P+R.
        options = new RoutingRequest("BICYCLE_PARK,WALK,TRANSIT");
        options.setRoutingContext(graph, B, D);
        tree = aStar.getShortestPathTree(options);
        path = tree.getPath(D, false);
        assertNotNull(path);
        s = tree.getState(D);
        assertTrue(s.isBikeParked());
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;
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.core.RoutingRequest

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.