Refine method get_network_node_coords

This commit is contained in:
DingZQ
2024-12-26 22:37:06 +08:00
parent 147f88debd
commit 0e44625f00
3 changed files with 23 additions and 16 deletions

View File

@@ -832,23 +832,12 @@ def get_node_coord(name: str, node_id: str) -> dict[str, float]:
# DingZQ, 2024-12-08, get all node coord
# id, x, y, type
def get_network_coords(name: str) -> dict[str, dict[str, float]]:
node_ids = api.get_nodes(name)
junctions = api.get_junctions(name)
reservoirs = api.get_reservoirs(name)
tanks = api.get_tanks(name)
def get_network_node_coords(name: str) -> dict[str, dict[str, float]]:
nodes_id_and_type = api.get_nodes_id_and_type(name)
result = {}
for node_id in node_ids:
#result[node_id] = api.get_node_coord(name, node_id)
for node_id, node_type in nodes_id_and_type.items():
coord = api.get_node_coord(name, node_id)
if node_id in junctions:
coord['type'] = 'junction'
elif node_id in reservoirs:
coord['type'] = 'reservoir'
elif node_id in tanks:
coord['type'] = 'tank'
else:
coord['type'] = 'node'
coord['type'] = node_type
result[node_id] = coord
return result