From 20834509d44e17cea44b01fa245454fc731176e2 Mon Sep 17 00:00:00 2001 From: "francois.grand" <francois.grand@irstea.fr> Date: Wed, 25 Apr 2018 16:39:37 +0200 Subject: [PATCH] =?UTF-8?q?=20#46=20courbes=20de=20remous=20:=20calcul=20d?= =?UTF-8?q?e=20la=20variable=20suppl=C3=A9mentaire=20=C3=A0=20partir=20de?= =?UTF-8?q?=20la=20ligne=20d'eau=20(max=20fluvial,torrentirl)=20et=20non?= =?UTF-8?q?=20plus=20en=20excluant=20le=20ressaut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/remous.ts | 56 ++++++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/src/remous.ts b/src/remous.ts index 3e02d648..6c3ff39a 100644 --- a/src/remous.ts +++ b/src/remous.ts @@ -432,42 +432,8 @@ export class CourbeRemous extends Nub { this.debug("abscisses "); this.logArray(trX); - // Calcul de la variable à calculer - - const tRes: { [key: number]: number } = {}; - if (val_a_cal !== undefined && (nFlu !== 0 || nTor !== 0)) { - for (const rX of trX) { - let rY: number; - const hasFlu: boolean = crbFlu[rX] !== undefined; - const hasTor: boolean = crbTor[rX] !== undefined; - - if (hasFlu && !hasTor) { - rY = crbFlu[rX]; - } - - if (hasTor) { - if (!hasFlu || (hasFlu && crbFlu[rX] === crbTor[rX])) { - rY = crbTor[rX]; - } - } - - if (rY !== undefined) { - // tRes[+rX] = this.Sn.Calc(val_a_cal, rY); - const rVar = this.Sn.Calc(val_a_cal, rY); - if (!rVar.ok) { - res.addLog(rVar.log); - return res; - } - tRes[rX] = rVar.vCalc; - this.debug("X=" + rX + " Calc(" + val_a_cal + ", Y=" + rY + ")=" + tRes[rX]); - } - } + // compilation des résultats - this.debug("extra param " + val_a_cal); - this.logObject(tRes); - } - - const hasRes = Object.keys(tRes).length > 0; for (const x of trX) { let ligneDeau; @@ -488,13 +454,25 @@ export class CourbeRemous extends Nub { re.addExtraResult("tor", crbTor[x]); } - if (hasRes && tRes[x]) { - re.addExtraResult("tRes", tRes[x]); - } - res.addResultElement(re); } + // Calcul de la variable à calculer + + const tRes: { [key: number]: number } = {}; + if (val_a_cal) { + for (const re of res.resultElements) { + const rY = re.vCalc; + if (rY !== undefined) { + const rVar = this.Sn.Calc(val_a_cal, rY); + if (!rVar.ok) + res.addLog(rVar.log); + else + re.addExtraResult("tRes", rVar.vCalc); + } + } + } + return res; } -- GitLab