mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Frictions: Split frictions list at reach split.
This commit is contained in:
1 parent
d222842313
commit
2a926a8d73
3 files changed
+40
-2
No files matched your search
@@ -213,6 +213,17 @@ class Friction(SQLSubModel):
|
||||
|
||||
return new
|
||||
|
||||
def cloned_for(self, reach):
|
||||
new = Friction(reach=reach, status=self._status)
|
||||
|
||||
new.reach = reach
|
||||
new.begin_rk = self._begin_rk
|
||||
new.end_rk = self._end_rk
|
||||
new.begin_strickler = self._begin_strickler
|
||||
new.end_strickler = self._begin_strickler
|
||||
|
||||
return new
|
||||
|
||||
def must_be_saved(self):
|
||||
ssi = self._status.scenario_id
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import logging
|
||||
|
||||
from copy import copy
|
||||
from tools import trace, timer
|
||||
from functools import reduce
|
||||
|
||||
from Model.Tools.PamhyrDB import SQLSubModel
|
||||
from Model.Tools.PamhyrListExt import PamhyrModelList
|
||||
@@ -95,3 +96,29 @@ class FrictionList(PamhyrModelList):
|
||||
self._lst.insert(index, n)
|
||||
self._status.modified()
|
||||
return n
|
||||
|
||||
def _splited_for(self, reach):
|
||||
new = FrictionList(status=self._status)
|
||||
|
||||
rk_min, rk_max = reduce(
|
||||
lambda mm, p: (
|
||||
min(mm[0], p.rk),
|
||||
max(mm[1], p.rk)
|
||||
),
|
||||
reach.reach.profiles,
|
||||
((999 ** 100), -(999 ** 100))
|
||||
)
|
||||
|
||||
frictions = list(
|
||||
filter(
|
||||
lambda f: ((rk_min <= f.begin_rk <= rk_max) or
|
||||
(rk_min <= f.end_rk <= rk_max)),
|
||||
self._lst))
|
||||
|
||||
for ind, friction in enumerate(frictions):
|
||||
n = friction.cloned_for(reach)
|
||||
|
||||
new._lst.insert(ind, n)
|
||||
new._status.modified()
|
||||
|
||||
return new
|
||||
+2
-2
@@ -437,10 +437,10 @@ class RiverReach(Edge):
|
||||
nr1, nr2 = self._reach._split(profile, new_reach1, new_reach2)
|
||||
|
||||
new_reach1._reach = nr1
|
||||
new_reach1._frictions = self._frictions
|
||||
new_reach1._frictions = self._frictions._splited_for(new_reach1)
|
||||
|
||||
new_reach2._reach = nr2
|
||||
new_reach2._frictions = self._frictions
|
||||
new_reach2._frictions = self._frictions._splited_for(new_reach2)
|
||||
|
||||
self.disable()
|
||||
|
||||
|
||||
Reference in new issue
Block a user