mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "fc7d732e0af0ca8a3bddf6e3586bc932cdac5f2d" and "e0cee0fbef4048e276ec1245a16345d9a3b24ab3" have entirely different histories.
fc7d732e0a
...
e0cee0fbef
|
|
@ -175,7 +175,7 @@ class PointXYZ(Point):
|
|||
return new
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, ind, deleted, " +
|
||||
"SELECT pamhyr_id, deleted, " +
|
||||
"name, x, y, z, sl, scenario " +
|
||||
"FROM geometry_pointXYZ " +
|
||||
f"WHERE profile = {profile.pamhyr_id} " +
|
||||
|
|
@ -188,7 +188,6 @@ class PointXYZ(Point):
|
|||
it = iter(row)
|
||||
|
||||
pid = next(it)
|
||||
ind = next(it)
|
||||
deleted = (next(it) == 1)
|
||||
name = next(it)
|
||||
x = next(it)
|
||||
|
|
@ -219,7 +218,7 @@ class PointXYZ(Point):
|
|||
)
|
||||
|
||||
loaded.add(pid)
|
||||
new.append((ind, point))
|
||||
new.append(point)
|
||||
|
||||
data["scenario"] = scenario.parent
|
||||
new += cls._db_load(execute, data)
|
||||
|
|
|
|||
|
|
@ -276,21 +276,8 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
None
|
||||
)
|
||||
|
||||
loaded_save = data['loaded_pid']
|
||||
data['loaded_pid'] = set()
|
||||
data["profile"] = profile
|
||||
|
||||
profile._points = list(
|
||||
map(
|
||||
lambda ip: ip[1],
|
||||
sorted(
|
||||
PointXYZ._db_load(execute, data.copy()),
|
||||
key=lambda ip: ip[0]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
data['loaded_pid'] = loaded_save
|
||||
profile._points = PointXYZ._db_load(execute, data.copy())
|
||||
|
||||
loaded.add(pid)
|
||||
new.append(profile)
|
||||
|
|
|
|||
|
|
@ -83,11 +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(
|
||||
"DELETE FROM geometry_profileXYZ " +
|
||||
f"WHERE reach = {self.pamhyr_id} " +
|
||||
|
|
@ -97,10 +92,10 @@ class Reach(SQLSubModel):
|
|||
ind = 0
|
||||
for profile in self._profiles:
|
||||
data["ind"] = ind
|
||||
ok &= profile._db_save(execute, data)
|
||||
profile._db_save(execute, data)
|
||||
ind += 1
|
||||
|
||||
return ok
|
||||
return True
|
||||
|
||||
def profile(self, i):
|
||||
"""Returns profile at index i
|
||||
|
|
@ -174,7 +169,7 @@ class Reach(SQLSubModel):
|
|||
"""
|
||||
profile = ProfileXYZ(reach=self, status=self._status)
|
||||
|
||||
self._profiles.insert(index, profile)
|
||||
self.profiles.insert(index, profile)
|
||||
|
||||
self.modified()
|
||||
|
||||
|
|
@ -192,7 +187,7 @@ class Reach(SQLSubModel):
|
|||
if profile in self._profiles:
|
||||
self.undelete([profile])
|
||||
else:
|
||||
self._profiles.insert(index, profile)
|
||||
self.profiles.insert(index, profile)
|
||||
|
||||
self.modified()
|
||||
|
||||
|
|
@ -210,7 +205,7 @@ class Reach(SQLSubModel):
|
|||
lambda p: p[1].set_as_deleted(),
|
||||
filter(
|
||||
lambda e: e[0] in indexes,
|
||||
enumerate(self._profiles)
|
||||
enumerate(self.profiles)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
@ -242,14 +237,13 @@ class Reach(SQLSubModel):
|
|||
def purge(self):
|
||||
for el in self._profiles:
|
||||
el.set_as_deleted()
|
||||
|
||||
self.modified()
|
||||
|
||||
def move_up_profile(self, index: int):
|
||||
if index < len(self.profiles):
|
||||
next = index - 1
|
||||
|
||||
p = self._profiles
|
||||
p = self.profiles
|
||||
p[index], p[next] = p[next], p[index]
|
||||
self.modified()
|
||||
|
||||
|
|
@ -257,7 +251,7 @@ class Reach(SQLSubModel):
|
|||
if index >= 0:
|
||||
prev = index + 1
|
||||
|
||||
p = self._profiles
|
||||
p = self.profiles
|
||||
p[index], p[prev] = p[prev], p[index]
|
||||
self.modified()
|
||||
|
||||
|
|
@ -528,8 +522,8 @@ class Reach(SQLSubModel):
|
|||
|
||||
@timer
|
||||
def sort(self, is_reversed: bool = False):
|
||||
self._profiles = sorted(
|
||||
self._profiles,
|
||||
self.profiles = sorted(
|
||||
self.profiles,
|
||||
key=lambda profile: profile.rk,
|
||||
reverse=is_reversed
|
||||
)
|
||||
|
|
@ -540,11 +534,11 @@ class Reach(SQLSubModel):
|
|||
if len(self.profiles) != len(indexes):
|
||||
logger.critical("Indexes list do not correspond to profile list")
|
||||
|
||||
self._profiles = list(
|
||||
self.profiles = list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
sorted(
|
||||
enumerate(self._profiles),
|
||||
enumerate(self.profiles),
|
||||
key=lambda x: indexes[x[0]]
|
||||
)
|
||||
)
|
||||
|
|
@ -605,7 +599,7 @@ class Reach(SQLSubModel):
|
|||
|
||||
profiles.append(prof)
|
||||
|
||||
self._profiles = profiles + self._profiles
|
||||
self.profiles = profiles + self.profiles
|
||||
self._recompute_rk()
|
||||
|
||||
return profiles
|
||||
|
|
@ -653,7 +647,7 @@ class Reach(SQLSubModel):
|
|||
logger.error(e)
|
||||
e.alert()
|
||||
finally:
|
||||
self._profiles = self._profiles + imported_profiles
|
||||
self.profiles = imported_profiles + self.profiles
|
||||
|
||||
return imported_profiles
|
||||
|
||||
|
|
|
|||
|
|
@ -489,6 +489,8 @@ class InitialConditions(SQLSubModel):
|
|||
def generate_growing_constant_depth(self, height: float,
|
||||
compute_discharge: bool):
|
||||
profiles = self._reach.reach.profiles.copy()
|
||||
profiles.reverse()
|
||||
|
||||
previous_elevation = -99999.99
|
||||
|
||||
data_discharge = {}
|
||||
|
|
@ -548,10 +550,13 @@ class InitialConditions(SQLSubModel):
|
|||
previous_elevation = elevation
|
||||
self._data.append(new)
|
||||
|
||||
self._data.reverse()
|
||||
|
||||
def generate_discharge(self, discharge: float, compute_height: bool):
|
||||
profiles = self._reach.reach.profiles.copy()
|
||||
if profiles is None:
|
||||
return None
|
||||
profiles.reverse()
|
||||
|
||||
previous_elevation = -99999.99
|
||||
|
||||
|
|
@ -609,6 +614,8 @@ class InitialConditions(SQLSubModel):
|
|||
previous_elevation = elevation
|
||||
self._data.append(new)
|
||||
|
||||
self._data.reverse()
|
||||
|
||||
def generate_height(self,
|
||||
elevation1: float,
|
||||
elevation2: float,
|
||||
|
|
|
|||
Loading…
Reference in New Issue