From 90eb873ecf5fe7daab0e56f55782ab794eed211c Mon Sep 17 00:00:00 2001 From: DingZQ Date: Sat, 29 Mar 2025 17:24:49 +0800 Subject: [PATCH] Fixed node properties --- api/s2_junctions.py | 10 ++++++---- api/s3_reservoirs.py | 10 ++++++---- api/s4_tanks.py | 10 ++++++---- api/s6_pumps.py | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/api/s2_junctions.py b/api/s2_junctions.py index 539c7d0..9007229 100644 --- a/api/s2_junctions.py +++ b/api/s2_junctions.py @@ -33,11 +33,13 @@ def get_all_junctions(name: str) -> list[dict[str, Any]]: result = [] for row in rows: d = {} - d['id'] = str(row['id']) - d['x'] = float(row['x']) - d['y'] = float(row['y']) + id = str(row['id']) + xy = get_node_coord(name, id) + d['id'] = id + d['x'] = float(xy['x']) + d['y'] = float(xy['y']) d['elevation'] = float(row['elevation']) - d['links'] = get_node_links(name, row['id']) + d['links'] = get_node_links(name, id) result.append(d) return result diff --git a/api/s3_reservoirs.py b/api/s3_reservoirs.py index abd3c9e..181b707 100644 --- a/api/s3_reservoirs.py +++ b/api/s3_reservoirs.py @@ -35,12 +35,14 @@ def get_all_reservoirs(name: str) -> list[dict[str, Any]]: result = [] for row in rows: d = {} - d['id'] = str(row['id']) - d['x'] = float(row['x']) - d['y'] = float(row['y']) + id = str(row['id']) + xy = get_node_coord(name, id) + d['id'] = id + d['x'] = float(xy['x']) + d['y'] = float(xy['y']) d['head'] = float(row['head']) if row['head'] != None else None d['pattern'] = str(row['pattern']) if row['pattern'] != None else None - d['links'] = get_node_links(name, row['id']) + d['links'] = get_node_links(name, id) result.append(d) return result diff --git a/api/s4_tanks.py b/api/s4_tanks.py index 30f8d92..306c9d7 100644 --- a/api/s4_tanks.py +++ b/api/s4_tanks.py @@ -51,9 +51,11 @@ def get_all_tanks(name: str) -> list[dict[str, Any]]: result = [] for row in rows: d = {} - d['id'] = str(row['id']) - d['x'] = float(row['x']) - d['y'] = float(row['y']) + id = str(row['id']) + xy = get_node_coord(name, id) + d['id'] = id + d['x'] = float(xy['x']) + d['y'] = float(xy['y']) d['elevation'] = float(row['elevation']) d['init_level'] = float(row['init_level']) d['min_level'] = float(row['min_level']) @@ -62,7 +64,7 @@ def get_all_tanks(name: str) -> list[dict[str, Any]]: 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']) + d['links'] = get_node_links(name, id) result.append(d) return result diff --git a/api/s6_pumps.py b/api/s6_pumps.py index 3f10bd9..8ac4622 100644 --- a/api/s6_pumps.py +++ b/api/s6_pumps.py @@ -40,8 +40,8 @@ def get_all_pumps(name: str) -> list[dict[str, Any]]: d['node2'] = str(row['node2']) d['power'] = float(row['power']) if row['power'] != None else None d['head'] = str(row['head']) if row['head'] != None else None - d['speed'] = float(p['speed']) if p['speed'] != None else None - d['pattern'] = str(p['pattern']) if p['pattern'] != None else None + d['speed'] = float(row['speed']) if row['speed'] != None else None + d['pattern'] = str(row['pattern']) if row['pattern'] != None else None result.append(d) return result