changeset 2560:0d8c97374dc9

WstValueTable: Forget to check in the range method of getMinMaxQ(). flys-artifacts/trunk@4086 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 17 Feb 2012 14:16:50 +0000
parents 407bbc74fe0b
children b3f6d49cdc80
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java
diffstat 2 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Feb 17 14:04:54 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Feb 17 14:16:50 2012 +0000
@@ -1,3 +1,8 @@
+2012-02-17  Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java(getMinMaxQ):
+	  Argh! Forget to check in the range method.
+
 2012-02-17  Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java(getMinMaxQ):
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java	Fri Feb 17 14:04:54 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java	Fri Feb 17 14:16:50 2012 +0000
@@ -632,6 +632,39 @@
         return null;
     }
 
+    public double [] getMinMaxQ(double from, double to, double step) {
+        double [] result = new double[2];
+
+        double minQ =  Double.MAX_VALUE;
+        double maxQ = -Double.MAX_VALUE;
+
+        if (from > to) {
+            double tmp = from;
+            from = to;
+            to = tmp;
+        }
+
+        step = Math.max(Math.abs(step), 0.0001);
+
+        double d = from;
+        for (; d <= to; d += step) {
+            if (getMinMaxQ(d, result) != null) {
+                if (result[0] < minQ) minQ = result[0];
+                if (result[1] > maxQ) maxQ = result[1];
+            }
+        }
+
+        if (d != to) {
+            if (getMinMaxQ(to, result) != null) {
+                if (result[0] < minQ) minQ = result[0];
+                if (result[1] > maxQ) maxQ = result[1];
+            }
+        }
+
+        return minQ < Double.MAX_VALUE
+            ? new double [] { minQ, maxQ }
+            : null;
+    }
 
     public double [] getMinMaxW(double km) {
         return getMinMaxW(km, new double [2]);

http://dive4elements.wald.intevation.org