From a4fcfc750ce450ba09572f519a9a959ce840b285 Mon Sep 17 00:00:00 2001 From: Arne Boockmeyer Date: Wed, 22 May 2024 16:08:25 +0200 Subject: [PATCH] Fix is_switch by also checking the graph degree --- orm_importer/importer.py | 2 +- orm_importer/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/orm_importer/importer.py b/orm_importer/importer.py index 0beb2db..4a4cefa 100644 --- a/orm_importer/importer.py +++ b/orm_importer/importer.py @@ -149,7 +149,7 @@ def run(self, polygon): # Only nodes with max 1 edge or that are a switch can be top nodes for node_id in self.graph.nodes: node = self.node_data[node_id] - if is_end_node(node, self.graph) or is_switch(node): + if is_end_node(node, self.graph) or is_switch(node, self.graph): self.top_nodes.append(node) for node in self.top_nodes: diff --git a/orm_importer/utils.py b/orm_importer/utils.py index c837da9..1c37227 100644 --- a/orm_importer/utils.py +++ b/orm_importer/utils.py @@ -45,8 +45,8 @@ def is_signal(node): return "railway:signal:direction" in node.tags.keys() -def is_switch(node): - return is_x(node, "switch") +def is_switch(node, graph): + return is_x(node, "switch") and graph.degree(node.id) == 3 def is_x(node, x: str):