Skip to content

Commit

Permalink
Merge pull request #60 from simulate-digital-rail/fix-is-switch
Browse files Browse the repository at this point in the history
Fix is_switch by also checking the degree of the node in the graph
  • Loading branch information
lpirl authored May 22, 2024
2 parents 8c55dfa + a4fcfc7 commit 38c9859
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion orm_importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions orm_importer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 38c9859

Please sign in to comment.