Add API to get major nodes and major pipes

This commit is contained in:
DingZQ
2025-01-01 00:34:02 +08:00
parent 69978c9868
commit 1d09d41935
4 changed files with 63 additions and 2 deletions

19
main.py
View File

@@ -1403,12 +1403,29 @@ async def fastapi_get_network_coords(network: str) -> list[str] | None:
result.append(f"{node_id}:{coord['type']}:{coord['x']}:{coord['y']}")
return result
# DingZQ, 2024-12-08, get all links' start and end node
# DingZQ, 2024-12-31, get major node coord
# id:type:x:y
# type: junction, reservoir, tank
@app.get("/getmajornodecoords/")
async def fastapi_get_major_node_coords(network: str) -> list[str] | None:
coords = get_major_node_coords(network)
result = []
for node_id, coord in coords.items():
result.append(f"{node_id}:{coord['type']}:{coord['x']}:{coord['y']}")
return result
# DingZQ, 2024-12-08, get all links' start and end node
# link_id:link_type:node_id1:node_id2
@app.get("/getnetworklinknodes/")
async def fastapi_get_network_link_nodes(network: str) -> list[str] | None:
return get_network_link_nodes(network)
# DingZQ 2024-12-31
# 获取直径大于800的管道
@app.get("/getmajorpipenodes/")
async def fastapi_get_major_pipe_nodes(network: str) -> list[str] | None:
return get_major_pipe_nodes(network)
############################################################
# vertex 25.[VERTICES]
############################################################