changeset 2559:407bbc74fe0b

WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given km or a range. flys-artifacts/trunk@4085 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 17 Feb 2012 14:04:54 +0000
parents 33e4481933e2
children 0d8c97374dc9
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java
diffstat 2 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Feb 17 11:59:30 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Feb 17 14:04:54 2012 +0000
@@ -1,3 +1,9 @@
+2012-02-17  Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java(getMinMaxQ):
+	  Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
+	  km or a range. The range method is maybe a bit slow.
+
 2012-02-17  Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java(getMinMaxW):
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java	Fri Feb 17 11:59:30 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java	Fri Feb 17 14:04:54 2012 +0000
@@ -607,6 +607,32 @@
         return ws;
     }
 
+    public double [] getMinMaxQ(double km) {
+        return getMinMaxQ(km, new double [2]);
+    }
+
+    public double [] getMinMaxQ(double km, double [] result) {
+        double minQ =  Double.MAX_VALUE;
+        double maxQ = -Double.MAX_VALUE;
+
+        for (int i = 0; i < columns.length; ++i) {
+            double q = columns[i].getQRangeTree().findQ(km);
+            if (!Double.isNaN(q)) {
+                if (q < minQ) minQ = q;
+                if (q > maxQ) maxQ = q;
+            }
+        }
+
+        if (minQ < Double.MAX_VALUE) {
+            result[0] = minQ;
+            result[1] = maxQ;
+            return result;
+        }
+
+        return null;
+    }
+
+
     public double [] getMinMaxW(double km) {
         return getMinMaxW(km, new double [2]);
 

http://dive4elements.wald.intevation.org