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()));
}
Aggregations