diff --git a/api/s24_coordinates.py b/api/s24_coordinates.py index 9e73651..09a30d5 100644 --- a/api/s24_coordinates.py +++ b/api/s24_coordinates.py @@ -15,7 +15,7 @@ def sql_delete_coord(node: str) -> str: return f"delete from coordinates where node = '{node}';" -def _to_client_point(coord: str) -> dict[str, float]: +def from_postgis_point(coord: str) -> dict[str, float]: xy = coord.lower().removeprefix('point(').removesuffix(')').split(' ') return { 'x': float(xy[0]), 'y': float(xy[1]) } @@ -25,7 +25,7 @@ def get_node_coord(name: str, node: str) -> dict[str, float]: if row == None: write(name, sql_insert_coord(node, 0.0, 0.0)) return {'x': 0.0, 'y': 0.0} - return _to_client_point(row['coord_geom']) + return from_postgis_point(row['coord_geom']) #-------------------------------------------------------------- @@ -47,7 +47,7 @@ def inp_out_coord(name: str) -> list[str]: objs = read_all(name, 'select node, st_astext(coord) as coord_geom from coordinates') for obj in objs: node = obj['node'] - coord = _to_client_point(obj['coord_geom']) + coord = from_postgis_point(obj['coord_geom']) x = coord['x'] y = coord['y'] lines.append(f'{node} {x} {y}')