Add API get network coords
This commit is contained in:
4
main.py
4
main.py
@@ -1391,6 +1391,10 @@ async def fastapi_set_option_properties(network: str, req: Request) -> ChangeSet
|
|||||||
async def fastapi_get_node_coord(network: str, node: str) -> dict[str, float] | None:
|
async def fastapi_get_node_coord(network: str, node: str) -> dict[str, float] | None:
|
||||||
return get_node_coord(network, node)
|
return get_node_coord(network, node)
|
||||||
|
|
||||||
|
@app.get("/getnetworkcoords/")
|
||||||
|
async def fastapi_get_network_coords(network: str) -> dict[str, dict[str, float]] | None:
|
||||||
|
return get_network_coords(network)
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# vertex 25.[VERTICES]
|
# vertex 25.[VERTICES]
|
||||||
############################################################
|
############################################################
|
||||||
|
|||||||
@@ -830,6 +830,14 @@ def set_option_v3(name: str, cs: ChangeSet) -> ChangeSet:
|
|||||||
def get_node_coord(name: str, node_id: str) -> dict[str, float]:
|
def get_node_coord(name: str, node_id: str) -> dict[str, float]:
|
||||||
return api.get_node_coord(name, node_id)
|
return api.get_node_coord(name, node_id)
|
||||||
|
|
||||||
|
# DingZQ, 2024-12-08, get all node coord
|
||||||
|
# id, x, y
|
||||||
|
def get_network_coords(name: str) -> dict[str, dict[str, float]]:
|
||||||
|
node_ids = api.get_all_node_ids(name)
|
||||||
|
result = {}
|
||||||
|
for node_id in node_ids:
|
||||||
|
result[node_id] = api.get_node_coord(name, node_id)
|
||||||
|
return result
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# vertex 25.[VERTICES]
|
# vertex 25.[VERTICES]
|
||||||
|
|||||||
Reference in New Issue
Block a user