From c971f9c55ce3835533ec4c34752e3ff36cc6ae33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Artelt?= Date: Sat, 8 Jun 2024 11:00:37 +0200 Subject: [PATCH] #8 Add node coordinates to NetworkTopology --- epyt_flow/simulation/scenario_simulator.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/epyt_flow/simulation/scenario_simulator.py b/epyt_flow/simulation/scenario_simulator.py index 3a2b621..e3e9533 100644 --- a/epyt_flow/simulation/scenario_simulator.py +++ b/epyt_flow/simulation/scenario_simulator.py @@ -761,6 +761,8 @@ def get_topology(self) -> NetworkTopology: nodes_id = self.epanet_api.getNodeNameID() nodes_elevation = self.epanet_api.getNodeElevations() nodes_type = [self.epanet_api.TYPENODE[i] for i in self.epanet_api.getNodeTypeIndex()] + nodes_coord = [self.epanet_api.api.ENgetcoord(node_idx) + for node_idx in self.epanet_api.getNodeIndex()] node_tank_names = self.epanet_api.getNodeTankNameID() links_id = self.epanet_api.getLinkNameID() @@ -774,8 +776,11 @@ def get_topology(self) -> NetworkTopology: # Build graph describing the topology nodes = [] - for node_id, node_elevation, node_type in zip(nodes_id, nodes_elevation, nodes_type): - node_info = {"elevation": node_elevation, "type": node_type} + for node_id, node_elevation, node_type, node_coord in zip(nodes_id, nodes_elevation, + nodes_type, nodes_coord): + node_info = {"elevation": node_elevation, + "coord": node_coord, + "type": node_type} if node_type == "TANK": node_tank_idx = node_tank_names.index(node_id) + 1 node_info["diameter"] = float(self.epanet_api.getNodeTankDiameter(node_tank_idx))