changeset 5252:aebe1a12e8b9 new-fwa

If looking at sections/stretches the bottleneck with the lowest class determines the class of the whole construct.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 13 May 2020 09:29:55 +0200
parents 1fce0fd81f46
children 878d52d95e37
files pkg/controllers/fwa.go
diffstat 1 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/controllers/fwa.go	Wed May 13 09:13:42 2020 +0200
+++ b/pkg/controllers/fwa.go	Wed May 13 09:29:55 2020 +0200
@@ -347,7 +347,7 @@
 
 		// Assume that a bottleneck is over LDC.
 		overLDC := true
-		highest := -1
+		lowest := len(counters) - 1
 
 		var hasValid bool
 
@@ -385,8 +385,8 @@
 				chooseBreaks[vs.limiting],
 				limitingAccess[vs.limiting]),
 				12*time.Hour,
-			); min > highest {
-				highest = min
+			); min < lowest {
+				lowest = min
 			}
 		}
 
@@ -394,9 +394,7 @@
 			if overLDC {
 				overLDCDays++
 			}
-			if highest > -1 {
-				counters[highest]++
-			}
+			counters[lowest]++
 		} else { // assume that all is in best conditions
 			overLDCDays++
 			counters[len(counters)-1]++
@@ -446,7 +444,7 @@
 			return i
 		}
 	}
-	return -1
+	return len(classes) - 1
 }
 
 func dusk(t time.Time) time.Time {