Package org.opentripplanner.routing.graph

Examples of org.opentripplanner.routing.graph.Vertex$ValidEdgeTypes


            if (!(gv instanceof StreetVertex)) {
                continue;
            }
            State s0 = new State(gv, options);
            for (Edge e : gv.getOutgoing()) {
                Vertex in = gv;
                if (!(e instanceof StreetEdge || e instanceof StreetTransitLink ||
                      e instanceof ElevatorEdge || e instanceof FreeEdge)) {
                    continue;
                }
                State s1 = e.traverse(s0);
                if (s1 == null) {
                    continue;
                }
                Vertex out = s1.getVertex();

                ArrayList<Vertex> vertexList = neighborsForVertex.get(in);
                if (vertexList == null) {
                    vertexList = new ArrayList<Vertex>();
                    neighborsForVertex.put(in, vertexList);
                }
                vertexList.add(out);

                vertexList = neighborsForVertex.get(out);
                if (vertexList == null) {
                    vertexList = new ArrayList<Vertex>();
                    neighborsForVertex.put(out, vertexList);
                }
                vertexList.add(in);
            }
        }

        ArrayList<Subgraph> islands = new ArrayList<Subgraph>();
        /* associate each node with a subgraph */
        for (Vertex gv : graph.getVertices()) {
            if (!(gv instanceof StreetVertex)) {
                continue;
            }
            Vertex vertex = gv;
            if (subgraphs.containsKey(vertex)) {
                continue;
            }
            if (!neighborsForVertex.containsKey(vertex)) {
                continue;
            }
            Subgraph subgraph = computeConnectedSubgraph(neighborsForVertex, vertex);
            if (subgraph != null){
                for (Iterator<Vertex> vIter = subgraph.streetIterator(); vIter.hasNext();) {
                    Vertex subnode = vIter.next();
                    subgraphs.put(subnode, subgraph);
                }
                islands.add(subgraph);
            }
        }
View Full Code Here


    }

    private static void depedestrianizeOrRemove(Graph graph, Subgraph island) {
        //iterate over the street vertex of the subgraph
        for (Iterator<Vertex> vIter = island.streetIterator(); vIter.hasNext();) {
            Vertex v = vIter.next();
            Collection<Edge> outgoing = new ArrayList<Edge>(v.getOutgoing());
            for (Edge e : outgoing) {
                if (e instanceof StreetEdge) {
                    StreetEdge pse = (StreetEdge) e;
                    StreetTraversalPermission permission = pse.getPermission();
                    permission = permission.remove(StreetTraversalPermission.PEDESTRIAN);
                    permission = permission.remove(StreetTraversalPermission.BICYCLE);
                    if (permission == StreetTraversalPermission.NONE) {
                        // TODO Shouldn't we have a graph.removeEdge()?
                        graph.streetNotesService.removeStaticNotes(pse);
                        pse.detach(graph);
                    } else {
                        pse.setPermission(permission);
                    }
                }
            }
        }

        for (Iterator<Vertex> vIter = island.streetIterator(); vIter.hasNext();) {
            Vertex v = vIter.next();
            if (v.getDegreeOut() + v.getDegreeIn() == 0) {
                graph.remove(v);
            }
        }
        //remove street conncetion form
        for (Iterator<Vertex> vIter = island.stopIterator(); vIter.hasNext();) {
            Vertex v = vIter.next();
            Collection<Edge> edges = new ArrayList<Edge>(v.getOutgoing());
            edges.addAll(v.getIncoming());
            for (Edge e : edges) {
                if (e instanceof StreetTransitLink) {
                    e.detach(graph);
                }
            }
View Full Code Here

            Map<Vertex, ArrayList<Vertex>> neighborsForVertex, Vertex startVertex) {
        Subgraph subgraph = new Subgraph();
        Queue<Vertex> q = new LinkedList<Vertex>();
        q.add(startVertex);
        while (!q.isEmpty()) {
            Vertex vertex = q.poll();
            for (Vertex neighbor : neighborsForVertex.get(vertex)) {
                if (!subgraph.contains(neighbor)) {
                    subgraph.addVertex(neighbor);
                    q.add(neighbor);
                }
View Full Code Here

            } // end loop over segments
        } // end loop over linestrings

        // if at least one vertex was found make a sample
        if (best.edge != null) {
            Vertex v0 = best.edge.getFromVertex();
            Vertex v1 = best.edge.getToVertex();
            double d = best.distanceTo(pt);
            if (d > searchRadiusM)
                return null;
            double d0 = d + best.distanceAlong();
            int t0 = (int) (d0 / 1.33);
View Full Code Here

        return s0.getActiveTime() < s1.getActiveTime();
    }
   
    @Override
    public boolean add(State state) {
        Vertex here = state.getVertex();
        State existing = states.get(here);
        if (existing == null || earlier (state, existing)) {
            states.put(here, state);
            return true;
        } else {
View Full Code Here

      this.routerId = routerId;
        long t0 = System.currentTimeMillis();
        times = new int[Vertex.getMaxIndex()]; // memory leak due to temp vertices?
        Arrays.fill(times, UNREACHABLE);
        for (State state : spt.getAllStates()) {
            Vertex vertex = state.getVertex();
            if (vertex instanceof StreetVertex || vertex instanceof TransitStop) {
                int i = vertex.getIndex();
                int t = (int) state.getActiveTime();
                if (times[i] == UNREACHABLE || times[i] > t) {
                    times[i] = t;
                }
            }
View Full Code Here

        // Replace the transfer table with an empty table
        TransferTable table = new TransferTable();
        when(graph.getTransferTable()).thenReturn(table);

        // Compute a normal path between two stops
        Vertex origin = graph.getVertex("agency:N");
        Vertex destination = graph.getVertex("agency:H");

        // Set options like time and routing context
        RoutingRequest options = new RoutingRequest();
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 7, 11, 11, 11, 0);
        options.setRoutingContext(graph, origin, destination);
View Full Code Here

        // Replace the transfer table with an empty table
        TransferTable table = new TransferTable();
        when(graph.getTransferTable()).thenReturn(table);

        // Compute a normal path between two stops
        Vertex origin = graph.getVertex("agency:N");
        Vertex destination = graph.getVertex("agency:H");

        // Set options like time and routing context
        RoutingRequest options = new RoutingRequest();
        options.setArriveBy(true);
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 7, 12, 1, 0, 0);
View Full Code Here

        // Replace the transfer table with an empty table
        TransferTable table = new TransferTable();
        when(graph.getTransferTable()).thenReturn(table);

        // Compute a normal path between two stops
        Vertex origin = graph.getVertex("agency:O");
        Vertex destination = graph.getVertex("agency:V");

        // Set options like time and routing context
        RoutingRequest options = new RoutingRequest();
        options.dateTime = TestUtils.dateInSeconds("America/New_York", 2009, 7, 11, 13, 11, 0);
        options.setRoutingContext(graph, origin, destination);
View Full Code Here

        // Replace the transfer table with an empty table
        TransferTable table = new TransferTable();
        when(graph.getTransferTable()).thenReturn(table);

        // Compute a normal path between two stops
        @SuppressWarnings("deprecation")
        Vertex origin = graph.getVertex("agency:U");
        @SuppressWarnings("deprecation")
        Vertex destination = graph.getVertex("agency:J");

        // Set options like time and routing context
        RoutingRequest options = new RoutingRequest();
        options.setArriveBy(true);
View Full Code Here

TOP

Related Classes of org.opentripplanner.routing.graph.Vertex$ValidEdgeTypes

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.