mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Friction, Reservoir, Geometry: Some fixes and minor change.
This commit is contained in:
1 parent
7bb0c9d57e
commit
6ec677a047
6 files changed
+32
-27
No files matched your search
@@ -30,6 +30,7 @@ logger = logging.getLogger()
|
||||
|
||||
class Friction(SQLSubModel):
|
||||
def __init__(self, id: int = -1,
|
||||
reach=None,
|
||||
status=None,
|
||||
owner_scenario=-1):
|
||||
super(Friction, self).__init__(
|
||||
@@ -37,7 +38,7 @@ class Friction(SQLSubModel):
|
||||
owner_scenario=owner_scenario
|
||||
)
|
||||
|
||||
self._reach = None
|
||||
self._reach = reach
|
||||
self._begin_rk = 0.0
|
||||
self._end_rk = 0.0
|
||||
self._begin_strickler = None
|
||||
@@ -64,7 +65,7 @@ class Friction(SQLSubModel):
|
||||
)
|
||||
""")
|
||||
|
||||
if ext == "_tmp":
|
||||
if ext != "":
|
||||
return True
|
||||
|
||||
return cls._create_submodel(execute)
|
||||
@@ -217,7 +218,7 @@ class Friction(SQLSubModel):
|
||||
|
||||
return (
|
||||
self._begin_strickler._owner_scenario == ssi
|
||||
or self._end_strickler._owner_scenario == ssi
|
||||
# or self._end_strickler._owner_scenario == ssi
|
||||
or super(Friction, self).must_be_saved()
|
||||
)
|
||||
|
||||
|
||||
@@ -86,19 +86,12 @@ class FrictionList(PamhyrModelList):
|
||||
)
|
||||
)
|
||||
|
||||
@property
|
||||
def lst(self):
|
||||
if not isinstance(self._lst, list):
|
||||
self._lst = self._get_frictions_list()
|
||||
|
||||
return self._lst
|
||||
|
||||
@property
|
||||
def frictions(self):
|
||||
return self.lst
|
||||
|
||||
def new(self, index):
|
||||
n = Friction(status=self._status)
|
||||
def new(self, reach, index):
|
||||
n = Friction(reach=reach, status=self._status)
|
||||
self._lst.insert(index, n)
|
||||
self._status.modified()
|
||||
return n
|
||||
@@ -540,7 +540,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
"""
|
||||
x, y, z = (0., 0., 0.)
|
||||
|
||||
if len(self._points) >= index:
|
||||
if 0 < len(self._points) >= index:
|
||||
x, y, z = self._points[index - 1].get_coordinate()
|
||||
|
||||
point = PointXYZ(x=x, y=y, z=z, profile=self, status=self._status)
|
||||
|
||||
@@ -83,9 +83,6 @@ class Reach(SQLSubModel):
|
||||
return new
|
||||
|
||||
def _db_save(self, execute, data=None):
|
||||
if not self.must_be_saved():
|
||||
return True
|
||||
|
||||
ok = True
|
||||
|
||||
execute(
|
||||
|
||||
@@ -28,13 +28,15 @@ class Data(SQLSubModel):
|
||||
_sub_classes = []
|
||||
|
||||
def __init__(self, id: int = -1,
|
||||
elevation: float = 0.,
|
||||
surface: float = 0.,
|
||||
status=None, owner_scenario=-1):
|
||||
super(Data, self).__init__(
|
||||
id=id, status=status,
|
||||
owner_scenario=owner_scenario
|
||||
)
|
||||
|
||||
self._data = []
|
||||
self._data = [elevation, surface]
|
||||
|
||||
@classmethod
|
||||
def _db_create(cls, execute, ext=""):
|
||||
@@ -335,12 +337,12 @@ class Reservoir(SQLSubModel):
|
||||
|
||||
execute(
|
||||
"DELETE FROM reservoir " +
|
||||
f"WHERE pamhyr_id = {self.pamhyr_id}" +
|
||||
f"WHERE pamhyr_id = {self.pamhyr_id} " +
|
||||
f"AND scenario = {self._status.scenario_id}"
|
||||
)
|
||||
execute(
|
||||
"DELETE FROM reservoir_data " +
|
||||
f"WHERE reservoir = {self.pamhyr_id}" +
|
||||
f"WHERE reservoir = {self.pamhyr_id} " +
|
||||
f"AND scenario = {self._status.scenario_id}"
|
||||
)
|
||||
|
||||
@@ -428,12 +430,23 @@ class Reservoir(SQLSubModel):
|
||||
return (new_0, new_1)
|
||||
|
||||
def add(self, index: int):
|
||||
value = (self._default_elevation, self._default_surface)
|
||||
self._data.insert(index, value)
|
||||
data = Data(
|
||||
elevation = self._default_elevation,
|
||||
surface = self._default_surface,
|
||||
status = self._status,
|
||||
)
|
||||
|
||||
self._data.insert(index, data)
|
||||
self.modified()
|
||||
return value
|
||||
return data
|
||||
|
||||
def insert(self, index: int, value):
|
||||
if type(value) is tuple or type(value) is list:
|
||||
value = Data(
|
||||
elevation = value[0],
|
||||
surface = value[1]
|
||||
)
|
||||
|
||||
self._data.insert(index, value)
|
||||
self.modified()
|
||||
|
||||
@@ -482,12 +495,11 @@ class Reservoir(SQLSubModel):
|
||||
lst = []
|
||||
for r in _range:
|
||||
lst.append(r)
|
||||
|
||||
return lst
|
||||
|
||||
def _set_i_c_v(self, index, column, value):
|
||||
v = list(self._data[index])
|
||||
v[column] = value
|
||||
self._data[index] = tuple(v)
|
||||
self._data[index][column] = value
|
||||
self.modified()
|
||||
|
||||
def set_i_elevation(self, index: int, value):
|
||||
|
||||
Reference in new issue
Block a user