Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Replace connected nodes edges #55

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
8 changes: 4 additions & 4 deletions orm_importer/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ def run(self, polygon):
if node_a and node_b and self._should_add_edge(node_a, node_b, path):
self.paths[(node_a, node_b)].append(path)
current_edge = model.Edge(node_a, node_b)
node_a.connected_nodes.append(node_b)
node_b.connected_nodes.append(node_a)
node_a.connected_edges.append(current_edge)
node_b.connected_edges.append(current_edge)
self.topology.add_edge(current_edge)
self._add_geo_nodes(path, current_edge)
current_edge.update_length()
Expand Down Expand Up @@ -237,8 +237,8 @@ def run(self, polygon):
).to_dbref()
new_edge = Edge(node, new_node)
new_edge.update_length()
node.connected_nodes.append(new_node)
new_node.connected_nodes.append(node)
node.connected_edges.append(new_edge)
new_edge.connected_edges.append(new_edge)
nodes_to_add.append(new_node)
self.topology.add_edge(new_edge)
break
Expand Down
8 changes: 4 additions & 4 deletions orm_importer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ def merge_edges(e1: model.Edge, e2: model.Edge, node_to_remove: model.Node):
print(str(e2.node_a.uuid) + " " + str(e2.node_b.uuid))
first_node = e1.node_a if e1.node_b == node_to_remove else e1.node_b
second_node = e2.node_a if e2.node_b == node_to_remove else e2.node_b
first_node.connected_nodes.remove(node_to_remove)
first_node.connected_nodes.append(second_node)
second_node.connected_nodes.remove(node_to_remove)
second_node.connected_nodes.append(first_node)
first_node.remove_edge_to_node(node_to_remove)
second_node.remove_edge_to_node(node_to_remove)
edge = Edge(first_node, second_node)
first_node.connected_edges(edge)
second_node.connected_edges(edge)
antonykamp marked this conversation as resolved.
Show resolved Hide resolved
edge.signals = e1.signals + e2.signals
edge.intermediate_geo_nodes = e1.intermediate_geo_nodes + e2.intermediate_geo_nodes
edge.update_length()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ zipp = "3.8.1"
six = "^1.16.0"
lxml = "^4.9.0"
haversine = "^2.7.0"
yaramo = {git = "https://github.com/simulate-digital-rail/yaramo"}
yaramo = {git = "https://github.com/antonykamp/yaramo", branch="refactor/replace-connected-nodes-with-edges"}



Expand Down
2 changes: 1 addition & 1 deletion tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def test_query_griebnitzsee(mock_converter):

assert len(res.nodes) == 10
assert len(res.edges) == 9
assert len(res.signals) == 9
assert len(res.signals) == 14
antonykamp marked this conversation as resolved.
Show resolved Hide resolved