changeset 5739:9950cbb7dba3

FixWQCurveGenerator: issue1149, show calculated wq as points.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 17 Apr 2013 08:54:05 +0200
parents 54077c9c9305
children 0516c1f8f674
files flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java
diffstat 1 files changed, 26 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Tue Apr 16 18:55:52 2013 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Wed Apr 17 08:54:05 2013 +0200
@@ -83,6 +83,8 @@
     public static final String I18N_YAXIS_LABEL_DEFAULT  =
             "W [NN + m]";
 
+    public static final double EPSILON = 0.001d;
+
     public static enum YAXIS {
         W(0),
         Q(1);
@@ -253,9 +255,13 @@
         XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc);
         Double ckm = (Double) context.getContextValue(CURRENT_KM);
         WQKms wqkms = (WQKms) aaf.getData(context);
+        if (wqkms == null || wqkms.getKms().length == 0 || ckm == null) {
+            logger.info("doEventsOut: No event data to show.");
+            return;
+        }
         double[] kms = wqkms.getKms();
         for (int i = 0 ; i< kms.length; i++) {
-            if (Math.abs(kms[i] - ckm) <= 0.01d) {
+            if (Math.abs(kms[i] - ckm) <= EPSILON) {
                 series.add(wqkms.getQ(i), wqkms.getW(i));
                 addAxisSeries(series, YAXIS.W.idx, visible);
                 return;
@@ -453,12 +459,27 @@
             ) {
         logger.debug("FixWQCurveGenerator: doWQOut");
         if (wqkms instanceof WQKms) {
-            WQKms data = (WQKms) wqkms;
+            // TODO As in doEventsOut, the value-searching should
+            // be delivered by the facet already (instead of in the Generator).
+            logger.debug("FixWQCurveGenerator: doWQOut: WQKms");
 
             XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme);
-            StyledSeriesBuilder.addPointsQW(series, data);
-
-            addAxisSeries(series, YAXIS.W.idx, visible);
+            WQKms data = (WQKms) wqkms;
+            Double ckm = (Double) context.getContextValue(CURRENT_KM);
+            if (data == null || data.getKms().length == 0 || ckm == null) {
+                logger.info("doWQOut: No event data to show.");
+                return;
+            }
+            // Search for a close match.
+            double[] kms = data.getKms();
+            for (int i = 0 ; i< kms.length; i++) {
+                if (Math.abs(kms[i] - ckm) <= EPSILON) {
+                    series.add(data.getQ(i), data.getW(i));
+                    addAxisSeries(series, YAXIS.W.idx, visible);
+                    return;
+                }
+            }
+            logger.info("doWQOut: No W/Q data for this km " + ckm);
         }
         else {
             double [][] data = (double [][]) wqkms;

http://dive4elements.wald.intevation.org