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

View File

@@ -107,7 +107,18 @@ def get_nodes_id_and_type(name: str) -> dict[str, str]:
nodes_id_and_type[record['id']] = record['type']
return nodes_id_and_type
# DingZQ
# DingZQ 2024-12-31
def get_major_nodes(name: str) -> list[str]:
major_nodes_set = set()
with conn[name].cursor(row_factory=dict_row) as cur:
cur.execute(f"select node1, node2 from pipes where diameter > 800")
for record in cur:
major_nodes_set.add(record['node1'])
major_nodes_set.add(record['node2'])
return list(major_nodes_set)
# DingZQs
def get_junctions(name: str) -> list[str]:
return _get_nodes_by_type(name, JUNCTION)
@@ -141,6 +152,16 @@ def get_links_id_and_type(name: str) -> dict[str, str]:
links_id_and_type[record['id']] = record['type']
return links_id_and_type
# DingZQ 2024-12-31
# 获取直径大于800的管道
def get_major_pipes(name: str) -> list[str]:
major_pipe_ids: list[str] = []
with conn[name].cursor(row_factory=dict_row) as cur:
cur.execute(f"select id from pipes where diameter > 800 order by id")
for record in cur:
major_pipe_ids.append(record['id'])
return major_pipe_ids
# DingZQ
def get_pipes(name: str) -> list[str]:
return _get_links_by_type(name, PIPE)