Support EPANET3 [CURVES] out

This commit is contained in:
WQY\qiong
2023-03-03 19:01:50 +08:00
parent 7d47dcd1b6
commit e9fa51cd4e

View File

@@ -134,7 +134,7 @@ def inp_in_curve(section: list[str]) -> ChangeSet:
count = len(section)
for i in range(0, count):
if section[i].startswith(';'):
# this is description
# ;type: desc
type_plus_desc = section[i].removeprefix(';')
type_plus_desc_tokens = type_plus_desc.split(':')
next = i + 1
@@ -182,21 +182,11 @@ def inp_out_curve(name: str) -> list[str]:
#--------------------------------------------------------------
def inp_in_curve_v3(section: list[str]) -> ChangeSet:
types = {}
descs = {}
curves: dict[str, list[dict[str, float]]] = {}
count = len(section)
for i in range(0, count):
if section[i].startswith(';'):
# this is description
type_plus_desc = section[i].removeprefix(';')
type_plus_desc_tokens = type_plus_desc.split(':')
next = i + 1
if next < count and section[next].startswith(';') == False:
next_tokens = section[next].split()
types[next_tokens[0]] = type_plus_desc_tokens[0].strip().upper()
if len(type_plus_desc_tokens) > 1:
descs[next_tokens[0]] = type_plus_desc_tokens[1].strip()
continue
tokens = section[i].split()
@@ -220,4 +210,16 @@ def inp_in_curve_v3(section: list[str]) -> ChangeSet:
def inp_out_curve_v3(name: str) -> list[str]:
return []
lines = []
types = read_all(name, f"select * from _curve")
for type in types:
id = type['id']
# id type
lines.append(f"{id} {type['type']}")
objs = read_all(name, f"select * from curves where id = '{id}' order by _order")
for obj in objs:
id = obj['id']
x = obj['x']
y = obj['y']
lines.append(f'{id} {x} {y}')
return lines