changeset 637:f0c1250d1e7b

Make "Berechnungsart 4" work independent of flow direction. Commented out back jump correction temporarily. flys-artifacts/trunk@2013 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 26 May 2011 16:54:16 +0000
parents 58276db49b16
children 9c565eb46f06
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/LinearRemap.java
diffstat 4 files changed, 64 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu May 26 15:55:48 2011 +0000
+++ b/flys-artifacts/ChangeLog	Thu May 26 16:54:16 2011 +0000
@@ -1,3 +1,14 @@
+2011-05-26	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/math/LinearRemap.java:
+	  Made it work independent of from/to order.
+
+	* src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java:
+	  Added method to extract the ranges correctly from data.
+
+	* src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java:
+	  Use the correct ranges. Comment out backjump detection temporarily.
+
 2011-05-26	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/states/WQAdapted.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Thu May 26 15:55:48 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java	Thu May 26 16:54:16 2011 +0000
@@ -1,5 +1,6 @@
 package de.intevation.flys.artifacts;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -773,6 +774,41 @@
         return qs;
     }
 
+    protected double [][] getRanges() {
+        logger.debug("getRanges");
+
+        StateData data = getData("wq_values");
+
+        if (data == null) {
+            logger.warn("Missing wq values!");
+            return new double [0][0];
+        }
+
+        String  dataString = (String)data.getValue();
+        String []   ranges = dataString.split(":");
+
+        ArrayList<double []> rs = new ArrayList<double []>();
+
+        for (String range: ranges) {
+            String [] parts = range.split(";");
+
+            if (parts.length < 2) {
+                logger.warn("invalid number of parts in range line");
+                continue;
+            }
+            try {
+                double from = Double.parseDouble(parts[0]);
+                double to   = Double.parseDouble(parts[1]);
+                rs.add(new double [] { from, to });
+            }
+            catch (NumberFormatException nfe) {
+                logger.warn("invalid double values in range line");
+            }
+        }
+
+        return rs.toArray(new double [rs.size()][]);
+    }
+
 
     /**
      * This method returns the given W or Q values for a specific range
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Thu May 26 15:55:48 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java	Thu May 26 16:54:16 2011 +0000
@@ -521,7 +521,15 @@
             return new WQKms[0];
         }
 
-        double [][] segments = getSplittedDistance();
+        double [][] segments = getRanges();
+
+        if (logger.isDebugEnabled()) {
+            logger.debug("segments ----------------- enter");
+            for (double [] segment: segments) {
+                logger.debug("  " + joinDoubles(segment));
+            }
+            logger.debug("segments ----------------- leave");
+        }
 
         if (segments.length < 1) {
             logger.warn("no segments given");
@@ -617,12 +625,14 @@
 
         ArrayList<WQKms> results = new ArrayList<WQKms>();
 
+        int referenceIndex = kmUp ?  0 : boundKms.length-1;
+
         for (int i = 0; i < iqs.length; ++i) {
             double [] iqsi = iqs[i];
 
             QPosition qPosition = wst.interpolate(
                 iqsi[0],
-                kmUp ? 0 : boundKms.length-1,
+                referenceIndex,
                 boundKms, boundWs, boundQs);
 
             if (qPosition == null) {
@@ -644,14 +654,16 @@
 
             wst.interpolate(okms, ows, oqs, qPosition, remap);
 
+            /*
             BackJumpCorrector bjc = new BackJumpCorrector();
             if (bjc.doCorrection(okms, ows)) {
                 logger.debug("Discharge longitudinal section has backjumps.");
                 results.add(new WQCKms(okms, oqs, ows, bjc.getCorrected()));
             }
             else {
+            */
                 results.add(new WQKms(okms, oqs, ows));
-            }
+            //}
         }
 
         WQKms [] wqkms = results.toArray(new WQKms[results.size()]);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/LinearRemap.java	Thu May 26 15:55:48 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/LinearRemap.java	Thu May 26 16:54:16 2011 +0000
@@ -61,6 +61,8 @@
             b = y1 - m*x1;
         }
 
+        if (from > to) { double t = from; from = to; to = t; }
+
         head = new Segment(from, to, m, b, head);
 
         if (logger.isDebugEnabled()) {

http://dive4elements.wald.intevation.org