Parse [COORDINATES]
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from .operation import read
|
from .operation import *
|
||||||
|
|
||||||
|
|
||||||
def _to_client_point(coord: str) -> dict[str, float]:
|
def _to_client_point(coord: str) -> dict[str, float]:
|
||||||
@@ -9,3 +9,26 @@ def _to_client_point(coord: str) -> dict[str, float]:
|
|||||||
def get_node_coord(name: str, id: str) -> dict[str, float]:
|
def get_node_coord(name: str, id: str) -> dict[str, float]:
|
||||||
row = read(name, f"select * from coordinates where node = '{id}'")
|
row = read(name, f"select * from coordinates where node = '{id}'")
|
||||||
return _to_client_point(row['coord'])
|
return _to_client_point(row['coord'])
|
||||||
|
|
||||||
|
# exception ! need merge to node change set !
|
||||||
|
def inp_in_coord(section: list[str]) -> dict[str, dict[str, float]]:
|
||||||
|
coords = {}
|
||||||
|
for s in section:
|
||||||
|
# skip comment
|
||||||
|
if s.startswith(';'):
|
||||||
|
continue
|
||||||
|
tokens = s.split()
|
||||||
|
coords[tokens[0]] = { 'x': tokens[1], 'y': tokens[2] }
|
||||||
|
return coords
|
||||||
|
|
||||||
|
|
||||||
|
def inp_out_junction(name: str) -> list[str]:
|
||||||
|
lines = []
|
||||||
|
objs = read_all(name, 'select * from coordinates')
|
||||||
|
for obj in objs:
|
||||||
|
node = obj['node']
|
||||||
|
coord = _to_client_point(obj['coord'])
|
||||||
|
x = coord['x']
|
||||||
|
y = coord['y']
|
||||||
|
lines.append(f'{node} {x} {y}')
|
||||||
|
return lines
|
||||||
|
|||||||
Reference in New Issue
Block a user