Add API to get major nodes and major pipes
This commit is contained in:
22
tjnetwork.py
22
tjnetwork.py
@@ -844,6 +844,18 @@ def get_network_node_coords(name: str) -> dict[str, dict[str, float]]:
|
||||
result[node_id] = coord
|
||||
return result
|
||||
|
||||
# DingZQ 2024-12-31
|
||||
# id, x, y, type
|
||||
def get_major_node_coords(name: str) -> dict[str, dict[str, float]]:
|
||||
nodes_id_and_type = api.get_nodes_id_and_type(name)
|
||||
major_node_ids = api.get_major_nodes(name)
|
||||
result = {}
|
||||
for node_id in major_node_ids:
|
||||
coord = api.get_node_coord(name, node_id)
|
||||
coord['type'] = nodes_id_and_type[node_id]
|
||||
result[node_id] = coord
|
||||
return result
|
||||
|
||||
# DingZQ, 2024-12-08, get all links' start and end node
|
||||
# link_id:link_type:node_id1:node_id2
|
||||
def get_network_link_nodes(name: str) -> list[str]:
|
||||
@@ -854,6 +866,16 @@ def get_network_link_nodes(name: str) -> list[str]:
|
||||
result.append(f"{link_id}:{link_type}:{nodes[0]}:{nodes[1]}")
|
||||
return result
|
||||
|
||||
# DingZQ 2024-12-31
|
||||
# link_id:pipe:node_id1:node_id2
|
||||
def get_major_pipe_nodes(name: str) -> list[str]:
|
||||
major_pipe_ids = api.get_major_pipes(name)
|
||||
result = []
|
||||
for link_id in major_pipe_ids:
|
||||
nodes = api.get_link_nodes(name, link_id)
|
||||
result.append(f"{link_id}:pipe:{nodes[0]}:{nodes[1]}")
|
||||
return result
|
||||
|
||||
############################################################
|
||||
# vertex 25.[VERTICES]
|
||||
############################################################
|
||||
|
||||
Reference in New Issue
Block a user