Search in sources :

Example 1 with GraphConnectivity

use of org.opentripplanner.graph_builder.issues.GraphConnectivity in project OpenTripPlanner by opentripplanner.

the class StreetUtils method depedestrianizeOrRemove.

private static void depedestrianizeOrRemove(Graph graph, Subgraph island, DataImportIssueStore issueStore) {
    // 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) {
                    graph.removeEdge(pse);
                } 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 instanceof TransitEntranceLink) {
                graph.removeEdge(e);
            }
        }
    }
    issueStore.add(new GraphConnectivity(island.getRepresentativeVertex(), island.streetSize()));
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) GraphConnectivity(org.opentripplanner.graph_builder.issues.GraphConnectivity) ArrayList(java.util.ArrayList) TransitEntranceLink(org.opentripplanner.routing.edgetype.TransitEntranceLink) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) StreetTraversalPermission(org.opentripplanner.routing.edgetype.StreetTraversalPermission) StreetTransitLink(org.opentripplanner.routing.edgetype.StreetTransitLink) ElevatorEdge(org.opentripplanner.routing.edgetype.ElevatorEdge) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) Edge(org.opentripplanner.routing.graph.Edge)

Aggregations

ArrayList (java.util.ArrayList)1 GraphConnectivity (org.opentripplanner.graph_builder.issues.GraphConnectivity)1 ElevatorEdge (org.opentripplanner.routing.edgetype.ElevatorEdge)1 FreeEdge (org.opentripplanner.routing.edgetype.FreeEdge)1 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)1 StreetTransitLink (org.opentripplanner.routing.edgetype.StreetTransitLink)1 StreetTraversalPermission (org.opentripplanner.routing.edgetype.StreetTraversalPermission)1 TransitEntranceLink (org.opentripplanner.routing.edgetype.TransitEntranceLink)1 Edge (org.opentripplanner.routing.graph.Edge)1 Vertex (org.opentripplanner.routing.graph.Vertex)1 StreetVertex (org.opentripplanner.routing.vertextype.StreetVertex)1