From a698d461441eee1df2ac48805b77e11ac6c68185 Mon Sep 17 00:00:00 2001
From: Theophile Terraz <theophile.terraz@inrae.fr>
Date: Mon, 5 Aug 2024 11:10:43 +0200
Subject: [PATCH] debug water limits

---
 src/Model/Geometry/ProfileXYZ.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/Model/Geometry/ProfileXYZ.py b/src/Model/Geometry/ProfileXYZ.py
index 54626bb3..d3e98097 100644
--- a/src/Model/Geometry/ProfileXYZ.py
+++ b/src/Model/Geometry/ProfileXYZ.py
@@ -565,18 +565,18 @@ class ProfileXYZ(Profile, SQLSubModel):
                 start.append(y)
 
         end = []
+        if points[-1].z <= z:
+            end.append(station[-1])
+
         for i in reversed(range(self.number_points-1)):
-            if zz[i-1] <= z and zz[i] > z:
+            if zz[i] <= z and zz[i+1] > z:
                 y = np.interp(
                     z,
-                    [zz[i-1], zz[i]],
-                    [station[i-1], station[i]]
+                    [zz[i], zz[i+1]],
+                    [station[i], station[i+1]]
                 )
                 end.append(y)
 
-        if points[-1].z <= z:
-            end.append(station[-1])
-
         if len(start) != len(end):
             logger.error(f"ERROR in get_all_water_limits_ac")
             return [], []
-- 
GitLab