Refine method get_network_node_coords

This commit is contained in:
DingZQ
2024-12-26 22:37:06 +08:00
parent 147f88debd
commit 0e44625f00
3 changed files with 23 additions and 16 deletions

View File

@@ -98,6 +98,15 @@ def _get_nodes_by_type(name: str, type: str) -> list[str]:
ids.append(record['id'])
return ids
# DingZQ
def get_nodes_id_and_type(name: str) -> dict[str, str]:
nodes_id_and_type: dict[str, str] = {}
with conn[name].cursor(row_factory=dict_row) as cur:
cur.execute(f"select id, type from {_NODE} order by id")
for record in cur:
nodes_id_and_type[record['id']] = record['type']
return nodes_id_and_type
# DingZQ
def get_junctions(name: str) -> list[str]:
return _get_nodes_by_type(name, JUNCTION)
@@ -123,6 +132,15 @@ def _get_links_by_type(name: str, type: str) -> list[str]:
ids.append(record['id'])
return ids
# DingZQ
def get_links_id_and_type(name: str) -> dict[str, str]:
links_id_and_type: dict[str, str] = {}
with conn[name].cursor(row_factory=dict_row) as cur:
cur.execute(f"select id, type from {_LINK} order by id")
for record in cur:
links_id_and_type[record['id']] = record['type']
return links_id_and_type
# DingZQ
def get_pipes(name: str) -> list[str]:
return _get_links_by_type(name, PIPE)