Package org.opentripplanner.routing.core

Examples of org.opentripplanner.routing.core.TraverseModeSet


                -77.0492, 38.858), "S. Crystal Dr", 87, StreetTraversalPermission.BICYCLE, false);

        GenericAStar aStar = new GenericAStar();

        // it is impossible to get from v1 to v3 by walking
        RoutingRequest options = new RoutingRequest(new TraverseModeSet("WALK,TRANSIT"));
        options.setRoutingContext(graph, v1, v3);
        ShortestPathTree tree = aStar.getShortestPathTree(options);

        GraphPath path = tree.getPath(v3, false);
        assertNull(path);

        // or biking + walking (assuming walking bikes is disallowed)
        options = new RoutingRequest(new TraverseModeSet("WALK,BICYCLE,TRANSIT"));
        options.freezeTraverseMode();
        options.setRoutingContext(graph, v1, v3);
        tree = aStar.getShortestPathTree(options);

        path = tree.getPath(v3, false);
        assertNull(path);

        // so we add a bike share
        BikeRentalStation station = new BikeRentalStation();
        station.id = "id";
        station.name = "station";
        station.x = -77.049;
        station.y = 36.856;
        station.bikesAvailable = 5;
        station.spacesAvailable = 5;
        BikeRentalStationVertex stationVertex = new BikeRentalStationVertex(graph, station);
        new StreetBikeRentalLink(stationVertex, v2);
        new StreetBikeRentalLink(v2, stationVertex);
        Set<String> networks = new HashSet<String>(Arrays.asList("default"));
        new RentABikeOnEdge(stationVertex, stationVertex, networks);
        new RentABikeOffEdge(stationVertex, stationVertex, networks);

        // but we can't get off the bike at v3, so we still fail
        options = new RoutingRequest(new TraverseModeSet("WALK,BICYCLE,TRANSIT"));
        options.freezeTraverseMode();
        options.setRoutingContext(graph, v1, v3);
        tree = aStar.getShortestPathTree(options);

        path = tree.getPath(v3, false);
View Full Code Here


   
    @Test
    public void testModeSetCanTraverse() {
        StreetEdge e = edge(v1, v2, 1.0, StreetTraversalPermission.ALL);
       
        TraverseModeSet modes = TraverseModeSet.allModes();
        assertTrue(e.canTraverse(modes));
       
        modes = new TraverseModeSet(TraverseMode.BICYCLE, TraverseMode.WALK);
        assertTrue(e.canTraverse(modes));
       
        e = edge(v1, v2, 1.0, StreetTraversalPermission.ALL_DRIVING);
        assertFalse(e.canTraverse(modes));
       
        modes = new TraverseModeSet(TraverseMode.CAR, TraverseMode.WALK);
        assertTrue(e.canTraverse(modes));
    }
View Full Code Here

    @Test
    public void testAllowsTraverseModeSet() {
        StreetTraversalPermission perm1 = StreetTraversalPermission.ALL_DRIVING;
        assertTrue(perm1.allows(TraverseModeSet.allModes()));
        assertTrue(perm1.allows(new TraverseModeSet(TraverseMode.CAR, TraverseMode.BICYCLE)));
        assertTrue(perm1.allows(new TraverseModeSet(TraverseMode.CUSTOM_MOTOR_VEHICLE,
                TraverseMode.TRAINISH, TraverseMode.FERRY)));

        // This one has no driving modes.
        assertFalse(perm1.allows(new TraverseModeSet(TraverseMode.BICYCLE, TraverseMode.TRAINISH,
                TraverseMode.FERRY)));
    }
View Full Code Here

        Vertex stop_b = graph.getVertex("agency:B_arrive");

        ShortestPathTree spt;

        RoutingRequest options = new RoutingRequest();
        options.setModes(new TraverseModeSet("TRAINISH"));
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 0, 0, 0, 0);
        options.setRoutingContext(graph, stop_a, stop_b);
        spt = aStar.getShortestPathTree(options );

        //a to b is bus only
        assertNull(spt.getPath(stop_b, false));
       
        options.setModes(new TraverseModeSet("TRAINISH,BUSISH"));
        spt = aStar.getShortestPathTree(options);

        assertNotNull(spt.getPath(stop_b, false));
    }
View Full Code Here

        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);
View Full Code Here

        if (from == -1 || to == -1 || via == -1) {
            LOG.warn(addBuilderAnnotation(new TurnRestrictionBad(relation.getId())));
            return;
        }

        TraverseModeSet modes = new TraverseModeSet(TraverseMode.BICYCLE, TraverseMode.CAR,
                TraverseMode.CUSTOM_MOTOR_VEHICLE);
        String exceptModes = relation.getTag("except");
        if (exceptModes != null) {
            for (String m : exceptModes.split(";")) {
                if (m.equals("motorcar")) {
                    modes.setDriving(false);
                } else if (m.equals("bicycle")) {
                    modes.setBicycle(false);
                    LOG.debug(addBuilderAnnotation(new TurnRestrictionException(via, from)));
                }
            }
        }

        TurnRestrictionTag tag;
        if (relation.isTag("restriction", "no_right_turn")) {
            tag = new TurnRestrictionTag(via, TurnRestrictionType.NO_TURN, Direction.RIGHT);
        } else if (relation.isTag("restriction", "no_left_turn")) {
            tag = new TurnRestrictionTag(via, TurnRestrictionType.NO_TURN, Direction.LEFT);
        } else if (relation.isTag("restriction", "no_straight_on")) {
            tag = new TurnRestrictionTag(via, TurnRestrictionType.NO_TURN, Direction.STRAIGHT);
        } else if (relation.isTag("restriction", "no_u_turn")) {
            tag = new TurnRestrictionTag(via, TurnRestrictionType.NO_TURN, Direction.U);
        } else if (relation.isTag("restriction", "only_straight_on")) {
            tag = new TurnRestrictionTag(via, TurnRestrictionType.ONLY_TURN, Direction.STRAIGHT);
        } else if (relation.isTag("restriction", "only_right_turn")) {
            tag = new TurnRestrictionTag(via, TurnRestrictionType.ONLY_TURN, Direction.RIGHT);
        } else if (relation.isTag("restriction", "only_left_turn")) {
            tag = new TurnRestrictionTag(via, TurnRestrictionType.ONLY_TURN, Direction.LEFT);
        } else if (relation.isTag("restriction", "only_u_turn")) {
            tag = new TurnRestrictionTag(via, TurnRestrictionType.ONLY_TURN, Direction.U);
        } else {
            LOG.warn(addBuilderAnnotation(new TurnRestrictionUnknown(relation.getTag("restriction"))));
            return;
        }
        tag.modes = modes.clone();

        // set the time periods for this restriction, if applicable
        if (relation.hasTag("day_on") && relation.hasTag("day_off") && relation.hasTag("hour_on")
                && relation.hasTag("hour_off")) {
View Full Code Here

        checkTriangleInequality();
    }
   
    @Test
    public void testTriangleInequalityWalkingOnly() {
        TraverseModeSet modes = new TraverseModeSet(TraverseMode.WALK);
        checkTriangleInequality(modes);
    }
View Full Code Here

        checkTriangleInequality(modes);
    }

    @Test
    public void testTriangleInequalityDrivingOnly() {
        TraverseModeSet modes = new TraverseModeSet(TraverseMode.CAR);
        checkTriangleInequality(modes);
    }
View Full Code Here

        checkTriangleInequality(modes);
    }
   
    @Test
    public void testTriangleInequalityWalkTransit() {
        TraverseModeSet modes = new TraverseModeSet(TraverseMode.WALK,
                TraverseMode.TRANSIT);
        checkTriangleInequality(modes);
    }
View Full Code Here

        checkTriangleInequality(modes);
    }
   
    @Test
    public void testTriangleInequalityWalkBike() {
        TraverseModeSet modes = new TraverseModeSet(TraverseMode.WALK,
                TraverseMode.BICYCLE);
        checkTriangleInequality(modes);
    }
View Full Code Here

TOP

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

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.