Add API to get both nodes and links
This commit is contained in:
15
main.py
15
main.py
@@ -1409,6 +1409,21 @@ async def fastapi_get_network_coords(network: str) -> list[str] | None:
|
|||||||
result.append(f"{node_id}:{coord['type']}:{coord['x']}:{coord['y']}")
|
result.append(f"{node_id}:{coord['type']}:{coord['x']}:{coord['y']}")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
# DingZQ, 2025-01-27, get all node coord/links
|
||||||
|
# nodes: id:type:x:y
|
||||||
|
# links: id:type:node1:node2
|
||||||
|
# node type: junction, reservoir, tank
|
||||||
|
# link type: pipe, pump, valve
|
||||||
|
@app.get("/getnetworkgeometries/")
|
||||||
|
async def fastapi_get_network_geometries(network: str) -> dict[str, Any] | None:
|
||||||
|
coords = get_network_node_coords(network)
|
||||||
|
nodes = []
|
||||||
|
for node_id, coord in coords.items():
|
||||||
|
nodes.append(f"{node_id}:{coord['type']}:{coord['x']}:{coord['y']}")
|
||||||
|
links = get_network_link_nodes(network)
|
||||||
|
|
||||||
|
return { 'nodes': nodes, 'links': links }
|
||||||
|
|
||||||
# DingZQ, 2024-12-31, get major node coord
|
# DingZQ, 2024-12-31, get major node coord
|
||||||
# id:type:x:y
|
# id:type:x:y
|
||||||
# type: junction, reservoir, tank
|
# type: junction, reservoir, tank
|
||||||
|
|||||||
Reference in New Issue
Block a user