From d43b03f9da084bdb194bf013c8fc1f2ad9abeb20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois?= <francois.grand@irstea.fr>
Date: Fri, 13 Jul 2018 14:37:58 +0200
Subject: [PATCH] =?UTF-8?q?=20#28=20StructureProperties.findCompatibleLoiD?=
 =?UTF-8?q?ebit()=20:=20ajout=20d'un=20argument=20pour=20limiter=20les=20r?=
 =?UTF-8?q?=C3=A9sultats=20possibles?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/structure/structure_props.ts | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/structure/structure_props.ts b/src/structure/structure_props.ts
index 4fcd468b..0988e11f 100644
--- a/src/structure/structure_props.ts
+++ b/src/structure/structure_props.ts
@@ -77,10 +77,20 @@ export class StructureProperties {
     }
 
     /**
-     * @return la 1ère valeur de LoiDebit compatible avec le type de structure
+     * trouve la 1ère valeur de LoiDebit compatible avec le type de structure
+     * @param struct type de structure avec laquelle la loi de débit doit être compatible
+     * @param subset si non vide, recherche la loi de débit compatible dans ce tableau; sinon prend la 1ere
      */
-    public static findCompatibleLoiDebit(struct: StructureType): LoiDebit {
+    public static findCompatibleLoiDebit(struct: StructureType, subset: LoiDebit[]): LoiDebit {
         const sst: string = StructureType[struct];
-        return loiAdmissibles[sst][0];
+
+        if (subset.length === 0)
+            return loiAdmissibles[sst][0];
+
+        for (const ld of loiAdmissibles[sst])
+            if (subset.includes(ld))
+                return ld;
+
+        return undefined;
     }
 }
-- 
GitLab