changeset 4798:39885bdfc6fc

Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse". This is done by figuring out the WST columns that imfold the data and then do simple "gleichwertige" calculations from the start of the interval. This is too much because only the Qs are needed for the "Umhuellende".
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 13 Jan 2013 16:18:28 +0100
parents 43e69af28b3c
children e3532c7850b9
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java
diffstat 1 files changed, 55 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java	Sun Jan 13 14:18:04 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java	Sun Jan 13 16:18:28 2013 +0100
@@ -11,6 +11,7 @@
 
 import de.intevation.flys.utils.DoubleUtil;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -228,9 +229,63 @@
             results[i].setName(createName(i));
         }
 
+        // Generate the "Umhuellende".
+        results = generateInfolding(table, results, from, to, step);
+
         return new CalculationResult(results, this);
     }
 
+    protected WQKms [] generateInfolding(
+        WstValueTable wst,
+        WQKms []      results,
+        double        from,
+        double        to,
+        double        step
+    ) {
+        WstValueTable.Column [] columns = wst.getColumns();
+
+        InfoldingColumns ic = new InfoldingColumns(columns);
+        ic.markInfoldingColumns(results);
+
+        List<WQKms> infoldings = new ArrayList<WQKms>();
+
+        boolean [] infoldingColumns = ic.getInfoldingColumns();
+        for (int i = 0; i < infoldingColumns.length; ++i) {
+            if (infoldingColumns[i]) {
+                continue;
+            }
+            double q = columns[i].getQRangeTree().findQ(from);
+            if (Double.isNaN(q)) {
+                addProblem(from, "cannot.find.q");
+                continue;
+            }
+            double [] kms = DoubleUtil.explode(from, to, step);
+            double [] oqs = new double[kms.length];
+            double [] ows = new double[kms.length];
+            boolean success =
+                wst.interpolate(q, from, kms, ows, oqs, this) != null;
+
+            if (success) {
+                // TODO: generate a better name. I18N.
+                String name = "Umh\u00fcllende " + columns[i].getName();
+                WQKms wqkms = new WQKms(kms, oqs, ows, name);
+                infoldings.add(wqkms);
+            }
+        }
+
+        int N = infoldings.size();
+        if (N > 0) {
+            WQKms [] newResults = new WQKms[results.length + N];
+            System.arraycopy(results, 0, newResults, 0, results.length);
+            for (int i = 0; i < N; ++i) {
+                newResults[i+results.length] = infoldings.get(i);
+            }
+            results = newResults;
+        }
+
+        return results;
+    }
+
     protected String createName(int index) {
         // TODO: i18n
         StringBuilder sb = new StringBuilder(isQ ? "Q" : "W");

http://dive4elements.wald.intevation.org