Return type from getnetworkcoord

This commit is contained in:
DingZQ
2024-12-18 22:41:35 +08:00
parent f8ac46d80d
commit 70afb19184
4 changed files with 21 additions and 7 deletions

View File

@@ -831,12 +831,25 @@ def get_node_coord(name: str, node_id: str) -> dict[str, float]:
return api.get_node_coord(name, node_id)
# DingZQ, 2024-12-08, get all node coord
# id, x, y
# 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)
result = {}
for node_id in node_ids:
result[node_id] = api.get_node_coord(name, node_id)
#result[node_id] = api.get_node_coord(name, node_id)
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'
result[node_id] = coord
return result
# DingZQ, 2024-12-08, get all links' start and end node