Need insert since it requires update later
This commit is contained in:
@@ -9,7 +9,8 @@ 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 = try_read(name, f"select * from coordinates where node = '{id}'")
|
row = try_read(name, f"select * from coordinates where node = '{id}'")
|
||||||
if row == None:
|
if row == None:
|
||||||
return {}
|
write(name, f"insert into coordinates (node, coord) values ('{id}', '(0.0,0.0)');")
|
||||||
|
return {'x': 0.0, 'y': 0.0}
|
||||||
return _to_client_point(row['coord'])
|
return _to_client_point(row['coord'])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ def get_junction(name: str, id: str) -> dict[str, Any]:
|
|||||||
if j == None:
|
if j == None:
|
||||||
return {}
|
return {}
|
||||||
xy = get_node_coord(name, id)
|
xy = get_node_coord(name, id)
|
||||||
if xy == {}:
|
|
||||||
xy = {'x': 0.0, 'y': 0.0}
|
|
||||||
d = {}
|
d = {}
|
||||||
d['id'] = str(j['id'])
|
d['id'] = str(j['id'])
|
||||||
d['x'] = float(xy['x'])
|
d['x'] = float(xy['x'])
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ def get_reservoir(name: str, id: str) -> dict[str, Any]:
|
|||||||
if r == None:
|
if r == None:
|
||||||
return {}
|
return {}
|
||||||
xy = get_node_coord(name, id)
|
xy = get_node_coord(name, id)
|
||||||
if xy == {}:
|
|
||||||
xy = {'x': 0.0, 'y': 0.0}
|
|
||||||
d = {}
|
d = {}
|
||||||
d['id'] = str(r['id'])
|
d['id'] = str(r['id'])
|
||||||
d['x'] = float(xy['x'])
|
d['x'] = float(xy['x'])
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ def get_tank(name: str, id: str) -> dict[str, Any]:
|
|||||||
if t == None:
|
if t == None:
|
||||||
return {}
|
return {}
|
||||||
xy = get_node_coord(name, id)
|
xy = get_node_coord(name, id)
|
||||||
if xy == {}:
|
|
||||||
xy = {'x': 0.0, 'y': 0.0}
|
|
||||||
d = {}
|
d = {}
|
||||||
d['id'] = str(t['id'])
|
d['id'] = str(t['id'])
|
||||||
d['x'] = float(xy['x'])
|
d['x'] = float(xy['x'])
|
||||||
|
|||||||
Reference in New Issue
Block a user