Package org.opentripplanner.routing.graph

Examples of org.opentripplanner.routing.graph.Graph


    }

    @Test
    public void testGraphBuilder() throws Exception {

        Graph gg = new Graph();

        OpenStreetMapGraphBuilderImpl loader = new OpenStreetMapGraphBuilderImpl();
        loader.setDefaultWayPropertySetSource(new DefaultWayPropertySetSource());
        FileBasedOpenStreetMapProviderImpl provider = new FileBasedOpenStreetMapProviderImpl();

        File file = new File(URLDecoder.decode(getClass().getResource("map.osm.gz").getFile(), "UTF-8"));

        provider.setPath(file);
        loader.setProvider(provider);

        loader.buildGraph(gg, extra);

        // Kamiennogorska at south end of segment
        Vertex v1 = gg.getVertex("osm:node:280592578");

        // Kamiennogorska at Mariana Smoluchowskiego
        Vertex v2 = gg.getVertex("osm:node:288969929");

        // Mariana Smoluchowskiego, north end
        Vertex v3 = gg.getVertex("osm:node:280107802");

        // Mariana Smoluchowskiego, south end (of segment connected to v2)
        Vertex v4 = gg.getVertex("osm:node:288970952");

        assertNotNull(v1);
        assertNotNull(v2);
        assertNotNull(v3);
        assertNotNull(v4);
View Full Code Here


     * @throws Exception
     */
    @Test
    public void testBuildGraphDetailed() throws Exception {

        Graph gg = new Graph();

        OpenStreetMapGraphBuilderImpl loader = new OpenStreetMapGraphBuilderImpl();
        loader.setDefaultWayPropertySetSource(new DefaultWayPropertySetSource());
        FileBasedOpenStreetMapProviderImpl provider = new FileBasedOpenStreetMapProviderImpl();

        File file = new File(URLDecoder.decode(getClass().getResource("NYC_small.osm.gz").getFile(), "UTF-8"));

        provider.setPath(file);
        loader.setProvider(provider);

        loader.buildGraph(gg, extra);
       
        // These vertices are labeled in the OSM file as having traffic lights.
        IntersectionVertex iv1 = (IntersectionVertex) gg.getVertex("osm:node:1919595918");
        IntersectionVertex iv2 = (IntersectionVertex) gg.getVertex("osm:node:42442273");
        IntersectionVertex iv3 = (IntersectionVertex) gg.getVertex("osm:node:1919595927");
        IntersectionVertex iv4 = (IntersectionVertex) gg.getVertex("osm:node:42452026");
        assertTrue(iv1.trafficLight);
        assertTrue(iv2.trafficLight);
        assertTrue(iv3.trafficLight);
        assertTrue(iv4.trafficLight);
       
        // These are not.
        IntersectionVertex iv5 = (IntersectionVertex) gg.getVertex("osm:node:42435485");
        IntersectionVertex iv6 = (IntersectionVertex) gg.getVertex("osm:node:42439335");
        IntersectionVertex iv7 = (IntersectionVertex) gg.getVertex("osm:node:42436761");
        IntersectionVertex iv8 = (IntersectionVertex) gg.getVertex("osm:node:42442291");
        assertFalse(iv5.trafficLight);
        assertFalse(iv6.trafficLight);
        assertFalse(iv7.trafficLight);
        assertFalse(iv8.trafficLight);
       
        Set<P2<Integer>> edgeEndpoints = new HashSet<P2<Integer>>();
        for (StreetEdge se : gg.getStreetEdges()) {
            P2<Integer> endpoints = new P2<Integer>(se.getFromVertex().getIndex(),
                    se.getToVertex().getIndex());
           
            // Check that we don't get any duplicate edges on this small graph.
            if (edgeEndpoints.contains(endpoints)) {
                assertFalse(true);
            }
            edgeEndpoints.add(endpoints);
           
            StreetTraversalPermission perm = se.getPermission();
           
            // CAR and CUSTOM_MOTOR_VEHICLE should always have the same permissions.
            assertEquals(perm.allows(StreetTraversalPermission.CAR),
                    perm.allows(StreetTraversalPermission.CUSTOM_MOTOR_VEHICLE));

            // Check turn restriction consistency.
            // NOTE(flamholz): currently there don't appear to be any turn restrictions
            // in the OSM file we are loading.
            for (TurnRestriction tr : gg.getTurnRestrictions(se)) {
                // All turn restrictions should apply equally to
                // CAR and CUSTOM_MOTOR_VEHICLE.
                TraverseModeSet modes = tr.modes;
                assertEquals(modes.getCar(), modes.getCustomMotorVehicle());
            }
View Full Code Here

            throw new RuntimeException(e);
        }
    }
   
    public boolean canTurnOnto(Edge e, State state, TraverseMode mode) {
        Graph graph = state.getOptions().rctx.graph;
        for (TurnRestriction restriction : graph.getTurnRestrictions(this)) {
            /* FIXME: This is wrong for trips that end in the middle of restriction.to
             */

            // NOTE(flamholz): edge to be traversed decides equivalence. This is important since
            // it might be a temporary edge that is equivalent to some graph edge.
View Full Code Here

    public void findHull() {
        LOG.info("finding hull of graph...");
        LOG.debug("using only stops? {}", useOnlyStops);
        if (bufferMeters < prototypeRoutingRequest.maxWalkDistance)
            LOG.warn("geographic filter buffer is smaller than max walk distance, this will probably yield incorrect results.");
        Graph graph= graphService.getGraph(prototypeRoutingRequest.routerId);
        List<Geometry> geometries = new ArrayList<Geometry>();
        for (Vertex v : graph.getVertices()) {
            if (useOnlyStops && ! (v instanceof TransitStop))
                continue;
            Point pt = gf.createPoint(v.getCoordinate());
            Geometry geom = crudeProjectedBuffer(pt, bufferMeters);
            geometries.add(geom);
View Full Code Here

        originalTripTimes = new TripTimes(trip, stopTimes, new Deduplicator());
    }

    @Test
    public void testBikesAllowed() {
        Graph graph = new Graph();
        Trip trip = new Trip();
        Route route = new Route();
        trip.setRoute(route);
        List<StopTime> stopTimes = Arrays.asList(new StopTime(), new StopTime());
        TripTimes s = new TripTimes(trip, stopTimes, new Deduplicator());
View Full Code Here

     * virtual nodes at the place where the street intersects the P+R areas. See ticket #1562.
     */
    @Test
    public void testUnconnectedParkAndRide() throws Exception {

        Graph gg = new Graph();

        OpenStreetMapGraphBuilderImpl loader = new OpenStreetMapGraphBuilderImpl();
        loader.setDefaultWayPropertySetSource(new DefaultWayPropertySetSource());
        FileBasedOpenStreetMapProviderImpl provider = new FileBasedOpenStreetMapProviderImpl();
        File file = new File(getClass().getResource("P+R.osm.gz").getFile());
        provider.setPath(file);
        loader.setProvider(provider);
        loader.buildGraph(gg, new HashMap<Class<?>, Object>());

        assertEquals(1, gg.getBuilderAnnotations().size());

        int nParkAndRide = 0;
        int nParkAndRideLink = 0;
        for (Vertex v : gg.getVertices()) {
            if (v instanceof ParkAndRideVertex) {
                nParkAndRide++;
            }
        }
        for (Edge e : gg.getEdges()) {
            if (e instanceof ParkAndRideLinkEdge) {
                nParkAndRideLink++;
            }
        }
        assertEquals(2, nParkAndRide);
View Full Code Here

        GtfsBundle gtfsBundle = new GtfsBundle(gtfs);
        List<GtfsBundle> gtfsBundleList = Collections.singletonList(gtfsBundle);
        GtfsGraphBuilderImpl gtfsGraphBuilderImpl = new GtfsGraphBuilderImpl(gtfsBundleList);

        alertsUpdateHandler = new AlertsUpdateHandler();
        graph = new Graph();
        gtfsBundle.setTransfersTxtDefinesStationPaths(true);
        gtfsGraphBuilderImpl.buildGraph(graph, null);
        // Set the agency ID to be used for tests to the first one in the feed.
        agencyId = graph.getAgencyIds().iterator().next();
        System.out.printf("Set the agency ID for this test to %s\n", agencyId);
View Full Code Here

    }

    private void setupPortland() {
        try {
            portlandContext = GtfsLibrary.readGtfs(new File(ConstantsForTests.PORTLAND_GTFS));
            portlandGraph = new Graph();
            GTFSPatternHopFactory factory = new GTFSPatternHopFactory(portlandContext);
            factory.run(portlandGraph);
            TransferGraphLinker linker = new TransferGraphLinker(portlandGraph);
            linker.run();
            // TODO: eliminate GTFSContext
View Full Code Here

            context = GtfsLibrary.readGtfs(new File(path));
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
        Graph graph = new Graph();
        GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
        factory.run(graph);
        graph.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
        return graph;
    }
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.graph.Graph

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.