[Dive4elements-commits] [PATCH] Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse"

Wald Commits scm-commit at wald.intevation.org
Sun Jan 13 16:18:42 CET 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1358090308 -3600
# Node ID 39885bdfc6fc26fca8ccfad2728d5e29a06aa953
# Parent  43e69af28b3cdf1b25bcf620fa8bc9344c77b222
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".

diff -r 43e69af28b3c -r 39885bdfc6fc flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java
--- 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");


More information about the Dive4elements-commits mailing list