changeset 3596:6aea625190da

Handle former W calculations in fixA W/Q out. flys-artifacts/trunk@5218 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 16 Aug 2012 09:49:21 +0000
parents 3837a4e6db46
children deeda39ef01b
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java
diffstat 3 files changed, 64 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Aug 16 09:41:53 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Aug 16 09:49:21 2012 +0000
@@ -1,3 +1,11 @@
+2012-08-16	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java:
+	  Interpolate and reduce WQKms if currentKm found in context.
+
+	* src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java:
+	  Handle WQKms in WQOuts.
+
 2012-08-16	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* doc/conf/artifacts/fixanalysis.xml: Add longitudinal section
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Thu Aug 16 09:41:53 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Thu Aug 16 09:49:21 2012 +0000
@@ -8,6 +8,7 @@
 import de.intevation.flys.artifacts.FLYSArtifact;
 
 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+import de.intevation.flys.artifacts.math.Linear;
 
 import org.apache.log4j.Logger;
 
@@ -67,6 +68,38 @@
         }
 
         WQKms [] wqkms = getWQKms(res);
+        if (context.getContextValue("currentKm") != null) {
+            logger.debug("interpolate at given km");
+            // TODO handle exact match.
+
+            WQKms wqkmsI = wqkms[index];
+            double km = ((Double)context.getContextValue("currentKm")).doubleValue();
+
+            // TODO employ DataUtils interface to TDoubleArraList
+            int size = wqkmsI.size();
+            boolean kmIncreasing = (wqkmsI.getKm(0) < wqkmsI.getKm(wqkmsI.size()-1))
+                                 ? true : false;
+            int mod = kmIncreasing ? +1 : -1;
+            int idx = 0;
+            if (!kmIncreasing) {
+                while (idx < size && wqkmsI.getKm(idx) < km) {
+                    idx++;
+                }
+            }
+            else {
+                idx = size-1;
+                while (idx > 0 && wqkmsI.getKm(idx) > km) {
+                    idx--;
+                }
+            }
+            WQKms resultWQKms = new WQKms();
+            if (idx != -1 && idx < size) {
+                double inW = Linear.linear(km, wqkmsI.getKm(idx), wqkmsI.getKm(idx-mod), wqkmsI.getW(idx), wqkmsI.getW(idx-mod));
+                double inQ = Linear.linear(km, wqkmsI.getKm(idx),wqkmsI.getKm(idx-mod), wqkmsI.getQ(idx), wqkmsI.getQ(idx-mod));
+                resultWQKms.add(inW, inQ, km);
+            }
+            return resultWQKms;
+        }
 
         return wqkms != null ? wqkms[index] : null;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Thu Aug 16 09:41:53 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Thu Aug 16 09:49:21 2012 +0000
@@ -132,7 +132,7 @@
                     doc,
                     visible);
         }
-        else if(STATIC_WQ.equals(name)) {
+        if (LONGITUDINAL_W.equals(name) || STATIC_WQ.equals(name)) {
             doWQOut(aaf.getData(context), aaf, doc, visible);
         }
         else if (name.equals(DISCHARGE_CURVE)) {
@@ -274,7 +274,8 @@
         }
     }
 
-   /**
+
+    /**
      * Add W-Annotations to plot.
      * @param wqkms actual data (double[][]).
      * @param theme theme to use.
@@ -303,7 +304,8 @@
             // Assume its WKms.
             logger.debug("Got WKms");
             WKms data = (WKms) wqkms;
-            Double ckm = (Double) context.getContextValue("currentKm");
+
+            Double ckm = (Double) context.getContextValue(CURRENT_KM);
             double location = (ckm != null)
                               ? ckm.doubleValue()
                               : getRange()[0];
@@ -353,6 +355,7 @@
         addAxisSeries(series, YAXIS.W.idx, visible);
     }
 
+
     /**
      * Add WQ Data to plot.
      * @param wqkms data as double[][]
@@ -364,14 +367,27 @@
         boolean          visible
     ) {
         logger.debug("FixWQCurveGenerator: doWQOut");
-        double [][] data = (double [][]) wqkms;
+        if (wqkms instanceof WQKms) {
+            WQKms data = (WQKms) wqkms;
 
-        XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
-        StyledSeriesBuilder.addPoints(series, data, true);
+            XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
+            Double ckm = (Double) context.getContextValue(CURRENT_KM);
 
-        addAxisSeries(series, YAXIS.W.idx, visible);
+            StyledSeriesBuilder.addPointsQW(series, data);
+
+            addAxisSeries(series, YAXIS.W.idx, visible);
+        }
+        else {
+            double [][] data = (double [][]) wqkms;
+
+            XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
+            StyledSeriesBuilder.addPoints(series, data, true);
+
+            addAxisSeries(series, YAXIS.W.idx, visible);
+        }
     }
 
+
     protected void addQWSeries(QW[] qws, ArtifactAndFacet aaf, Document theme, boolean visible) {
          if(qws != null) {
             XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);

http://dive4elements.wald.intevation.org