changeset 8127:8c5eb9edc3f3

Another fix for find stations in sediment load.
author Sascha L. Teichmann <teichmann@intevation.de>
date Mon, 25 Aug 2014 17:14:49 +0200
parents 353f93d5d9f7
children 65a938e4d92f
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java
diffstat 1 files changed, 14 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Mon Aug 25 16:04:35 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Mon Aug 25 17:14:49 2014 +0200
@@ -391,19 +391,20 @@
         int lo, int hi,
         Visitor visitor
     ) {
-        while (lo <= hi) {
-            int mid = (lo+hi)/2;
-            Station st = stations[mid];
-            double station = st.getStation();
-            if (station < a) {
-                hi = mid-1;
-            } else if (station > b) {
-                lo = mid+1;
-            } else {
-                recursiveFindStations(a, b, lo, mid-1, visitor);
-                visitor.visit(st);
-                lo = mid+1;
-            }
+        if (lo > hi) {
+            return;
+        }
+        int mid = (lo+hi)/2;
+        Station st = stations[mid];
+        double station = st.getStation();
+        if (station < a) {
+            recursiveFindStations(a, b, mid+1, hi)
+        } else if (station > b) {
+            recursiveFindStations(a, b, lo, mid-1)
+        } else {
+            recursiveFindStations(a, b, lo, mid-1, visitor);
+            visitor.visit(st);
+            recursiveFindStations(a, b, mid+1, hi, visitor);
         }
     }
 

http://dive4elements.wald.intevation.org