RouteGraph rg = new RouteGraph();
// Default capacity should be enough for common cases.
- Set<EdgeResource> links = new THashSet<EdgeResource>();
- Map<Object, RouteNode> nodeByData = new THashMap<Object, RouteNode>();
+ Set<EdgeResource> links = new THashSet<>();
+ Map<Object, RouteNode> nodeByData = new THashMap<>();
// Load all route graph interior RouteNodes: route lines and points
for (Resource interiorNode : graph.getObjects(connection, DIA.HasInteriorRouteNode)) {
if (graph.isInstanceOf(interiorNode, DIA.RouteLine)) {
+ Collection<Resource> areConnected = graph.getObjects(interiorNode, DIA.AreConnected);
+ if (areConnected.size() < 2) {
+ // Degenerated route line encountered, most likely due to a bug somewhere else.
+ // Ignoring them because adding them to the RouteGraph structure would cause
+ // problems during rendering.
+ LOGGER.warn("Stray RouteLine found: " + NameUtils.getSafeName(graph, interiorNode));
+ continue;
+ }
+
Boolean isHorizontal = graph.getRelatedValue(interiorNode, DIA.IsHorizontal, Bindings.BOOLEAN);
Double position = graph.getRelatedValue(interiorNode, DIA.HasPosition, Bindings.DOUBLE);
RouteLine line = rg.addLine(isHorizontal, position);
nodeByData.put( interiorNode, line );
- for (Resource connectedTo : graph.getObjects(interiorNode, DIA.AreConnected)) {
+ for (Resource connectedTo : areConnected) {
links.add( new EdgeResource(interiorNode, connectedTo) );
}
} else if (graph.isInstanceOf(interiorNode, DIA.RoutePoint)) {