From b085e4b4de9bed39885bec04fd013b4103136712 Mon Sep 17 00:00:00 2001 From: DingZQ Date: Sat, 19 Apr 2025 12:24:08 +0800 Subject: [PATCH] Refine --- api/s41_pipe_risk_probability.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/api/s41_pipe_risk_probability.py b/api/s41_pipe_risk_probability.py index 73464d6..e3ecd51 100644 --- a/api/s41_pipe_risk_probability.py +++ b/api/s41_pipe_risk_probability.py @@ -57,12 +57,17 @@ def get_pipes_risk_probability(name: str, pipe_ids: list[str]) -> list[dict[str, def get_pipe_risk_probability_geometries(name: str) -> dict[str, Any]: pipe_risk_probability_geometries = {} + key_pipeId = '编码' + key_startnode = '上游节点' + key_endnode = '下游节点' + key_geometry = 'geometry' + with conn[name].cursor(row_factory=dict_row) as cur: - cur.execute(f"select '编码' AS Id, '上游节点' AS startnode, '下游节点' AS endnode, ST_AsGeoJSON(geometry) AS geometry from gis_pipe") + cur.execute(f"select {key_pipeId}, {key_startnode}, {key_endnode}, ST_AsGeoJSON(geometry) AS {key_geometry} from gis_pipe") for record in cur: - print(record['Id']) - print(record['startnode']) - print(record['endnode']) - print(record['geometry']) + print(record[key_pipeId]) + print(record[key_startnode]) + print(record[key_endnode]) + print(record[key_geometry]) return pipe_risk_probability_geometries \ No newline at end of file