Add API to get all node properties

This commit is contained in:
DingZQ
2025-03-29 17:08:31 +08:00
parent d1687b8464
commit 0431f4d82e
6 changed files with 91 additions and 3 deletions

View File

@@ -42,6 +42,30 @@ def get_tank(name: str, id: str) -> dict[str, Any]:
d['links'] = get_node_links(name, id)
return d
# DingZQ, 2025-03-29
def get_all_tanks(name: str) -> list[dict[str, Any]]:
rows = read_all(name, f"select * from tanks")
if rows == None:
return []
result = []
for row in rows:
d = {}
d['id'] = str(row['id'])
d['x'] = float(row['x'])
d['y'] = float(row['y'])
d['elevation'] = float(row['elevation'])
d['init_level'] = float(row['init_level'])
d['min_level'] = float(row['min_level'])
d['max_level'] = float(row['max_level'])
d['diameter'] = float(row['diameter'])
d['min_vol'] = float(row['min_vol'])
d['vol_curve'] = str(row['vol_curve']) if row['vol_curve'] != None else None
d['overflow'] = str(row['overflow']) if row['overflow'] != None else None
d['links'] = get_node_links(name, row['id'])
result.append(d)
return result
class Tank(object):
def __init__(self, input: dict[str, Any]) -> None: