From 51ce85d45371646462fe54759e968b3bcbb22e0f Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Fri, 27 Sep 2024 14:35:28 +0200
Subject: [PATCH] Geometry: Fix ST import.

---
 src/Model/Geometry/Reach.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/Model/Geometry/Reach.py b/src/Model/Geometry/Reach.py
index f33eb5de..c10b56fc 100644
--- a/src/Model/Geometry/Reach.py
+++ b/src/Model/Geometry/Reach.py
@@ -632,8 +632,8 @@ class Reach(SQLSubModel):
 
         try:
             list_profile, list_header = self.read_file_st(str(file_path_name))
-            profile_header = ["num", "code1",
-                              "code2", "nb_point", "rk", "name"]
+            profile_header = ["num", "code1", "code2",
+                              "nb_point", "rk", "name"]
 
             if list_profile and list_header:
                 for ind, profile in enumerate(list_profile):
@@ -707,6 +707,15 @@ class Reach(SQLSubModel):
                                 line_is_header = True
                             else:
                                 list_point_profile.append(line)
+                        elif len(line) > 4:
+                            x, y, z = line[:3]
+                            if stop_code in x and stop_code in y:
+                                line_is_header = True
+                                list_profile.append(list_point_profile)
+                                list_point_profile = []
+                            else:
+                                line.append("")
+                                list_point_profile.append(line[:3])
                         else:
                             pass
 
-- 
GitLab