Skip to content

Commit

Permalink
chore: tune logging and remove transit unlinking which crashes OTP
Browse files Browse the repository at this point in the history
  • Loading branch information
vesameskanen committed Sep 14, 2021
1 parent 7101a35 commit f6c425a
Showing 1 changed file with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.opentripplanner.routing.edgetype.StreetTransitStopLink;
import org.opentripplanner.routing.edgetype.StreetTraversalPermission;
import org.opentripplanner.routing.edgetype.StreetTransitEntranceLink;
import org.opentripplanner.routing.edgetype.StreetTransitEntityLink;
import org.opentripplanner.routing.graph.Edge;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.graph.Vertex;
Expand Down Expand Up @@ -103,11 +104,12 @@ public void buildGraph(
issueStore, TraverseMode.CAR
);
if (transitToStreetNetwork == null) {
LOG.debug(
"TransitToStreetNetworkGraphBuilder was not provided to PruneFloatingIslands. Not attempting to reconnect stops.");
LOG.info("StreetLinkerModule not provided, not attempting to reconnect stops.");
}
else {
//reconnect stops on small islands (that removed)
// reconnect stops on small islands (that removed)
// this currently does not work!
LOG.info("Reconnecting stops with StreetLinkerModule");
transitToStreetNetwork.buildGraph(graph, extra, issueStore);
}
LOG.debug("Done pruning nothru islands");
Expand Down Expand Up @@ -151,7 +153,7 @@ private static void pruneNoThruIslands(
}
}
if (islandLog != null) {
islandLog.printf("%s\t%s\t%s\t%s\n", "id", "streets", "changed", "node");
islandLog.printf("%s\t%s\t%s\t%s\n", "id", "streets", "stops", "changed", "node");
}
Map<Vertex, Subgraph> subgraphs = new HashMap<Vertex, Subgraph>();
Map<Vertex, Subgraph> extgraphs = new HashMap<Vertex, Subgraph>();
Expand Down Expand Up @@ -230,10 +232,12 @@ private static int processIslands(
stats.put("restricted", 0);

int count = 0;
int islandsWithStops = 0;
for (Subgraph island : islands) {
boolean changed = false;
if (island.stopSize() > 0) {
//for islands with stops
islandsWithStops++;
if (island.streetSize() < islandWithStopMaxSize) {
restrictOrRemove(graph, island, isolated, stats, markIsolated, traverseMode);
changed = true;
Expand All @@ -256,6 +260,7 @@ private static int processIslands(
LOG.info("Detected {} isolated edges", stats.get("isolated"));
}
else {
LOG.info("Number of islands with stops: {}", islandsWithStops);
LOG.info("Removed {} edges", stats.get("removed"));
LOG.info("Removed traversal mode from {} edges", stats.get("restricted"));
LOG.info("Converted {} edges to noThruTraffic", stats.get("noThru"));
Expand All @@ -282,7 +287,7 @@ private static void collectNeighbourVertices(
if (!(
e instanceof StreetEdge || e instanceof StreetTransitStopLink ||
e instanceof StreetTransitEntranceLink || e instanceof ElevatorEdge ||
e instanceof FreeEdge
e instanceof FreeEdge || e instanceof StreetTransitEntityLink
)
) {
continue;
Expand Down Expand Up @@ -418,17 +423,6 @@ private static void restrictOrRemove(
graph.remove(v);
}
}
//remove street connection 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 StreetTransitStopLink || e instanceof StreetTransitEntranceLink) {
graph.removeEdge(e);
}
}
}
}

private static Subgraph computeConnectedSubgraph(
Expand Down Expand Up @@ -472,7 +466,7 @@ private static void writeNodesInSubGraph(
String label = subgraph.getRepresentativeVertex().getLabel();

islandLog.printf(
"%d\t%d\t%b\t%s\n", islandCounter, subgraph.streetSize(), changed, label
"%d\t%d\t%d\t%b\t%s\n", islandCounter, subgraph.streetSize(), subgraph.stopSize(), changed, label
);
islandCounter++;
}
Expand Down

0 comments on commit f6c425a

Please sign in to comment.