diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/QRangeTree.java @ 5423:f4fd64a4d502

Fix Wstcalculation for non monotonous values. Patch written and provided by Sascha Teichmann
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 26 Mar 2013 11:39:03 +0100
parents 14db045d6368
children
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/QRangeTree.java	Tue Mar 26 11:29:25 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/QRangeTree.java	Tue Mar 26 11:39:03 2013 +0100
@@ -269,6 +269,26 @@
         return parent;
     }
 
+    public double averageQ() {
+        double sum = 0d;
+        int n = 0;
+        for (Node node = head(); node != null; node = node.next) {
+            sum += node.q;
+            ++n;
+        }
+        return sum/n;
+    }
+
+    public double maxQ() {
+        double max = -Double.MAX_VALUE;
+        for (Node node = head(); node != null; node = node.next) {
+            if (node.q > max) {
+                max = node.q;
+            }
+        }
+        return max;
+    }
+
     public double findQ(double pos) {
         return root != null ? root.findQ(pos) : Double.NaN;
     }

http://dive4elements.wald.intevation.org