changeset 3924:5fced192b95c

Towards fix of issue863 (gaps in middle heigh bed data). flys-artifacts/trunk@5613 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 27 Sep 2012 11:12:38 +0000
parents 9fac337192c9
children 36147ddb2c32
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightData.java flys-artifacts/src/main/java/de/intevation/flys/exports/MiddleBedHeightGenerator.java
diffstat 4 files changed, 84 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Sep 27 08:53:59 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Sep 27 11:12:38 2012 +0000
@@ -1,3 +1,20 @@
+2012-09-27	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Towards fix issue863 (gaps in middle height bed data).
+
+	* src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightData.java
+	  (addAll): Do not expose single add*-Methods, instead always add a full
+	  set of data.
+	  Added new isEmpty-data and query it before exporting data as
+	  double[][] to e.g. ChartGenerator.
+	  
+	* src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightCalculation.java:
+	  Do not use single add()*-Methods, instead call new addAll method.
+	  Find out whether a gap-value is present.
+	  
+	* src/main/java/de/intevation/flys/exports/MiddleBedHeightGenerator.java:
+	  Prevent skipping of NaNs (gaps).
+
 2012-09-27	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/map/WMSLayerFacet.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightCalculation.java	Thu Sep 27 08:53:59 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightCalculation.java	Thu Sep 27 11:12:38 2012 +0000
@@ -63,7 +63,7 @@
                 singles.add(s);
             }
             else {
-                logger.warn("Cannot find Sngle by id: " + id);
+                logger.warn("Cannot find Single by id: " + id);
                 // TODO ADD WARNING
             }
         }
@@ -146,12 +146,24 @@
             single.getDescription());
 
         for (BedHeightSingleValue value: values) {
-            data.addKM(value.getStation().doubleValue());
-            data.addMiddleHeight(value.getHeight().doubleValue());
-            data.addUncertainty(value.getUncertainty().doubleValue());
-            data.addSoundingWidth(value.getSoundingWidth().doubleValue());
-            data.addDataGap(value.getDataGap().doubleValue());
-            data.addWidth(value.getWidth().doubleValue());
+            if (value.getHeight() != null) {
+                data.addAll(value.getStation().doubleValue(),
+                    value.getHeight().doubleValue(),
+                    value.getUncertainty().doubleValue(),
+                    value.getSoundingWidth().doubleValue(),
+                    value.getDataGap().doubleValue(),
+                    value.getWidth().doubleValue(),
+                    false);
+             }
+            else {
+                data.addAll(value.getStation().doubleValue(),
+                    0,
+                    0,
+                    0,
+                    0,
+                    0,
+                    true);
+            }
         }
 
         logger.debug("Single contains " + values.size() + " values");
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightData.java	Thu Sep 27 08:53:59 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightData.java	Thu Sep 27 11:12:38 2012 +0000
@@ -2,15 +2,22 @@
 
 import java.io.Serializable;
 
+import java.util.ArrayList;
+
 import gnu.trove.TDoubleArrayList;
 
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.artifacts.resources.Resources;
 
+import org.apache.log4j.Logger;
+
 
 public class MiddleBedHeightData implements Serializable {
 
+    /** Very private logger. */
+    private static final Logger logger = Logger.getLogger(MiddleBedHeightData.class);
+
     public static final String I18N_SINGLE_NAME = "facet.bedheight_middle.single";
     public static final String I18N_EPOCH_NAME  = "facet.bedheight_middle.epoch";
 
@@ -25,6 +32,7 @@
     private TDoubleArrayList soundingWidth;
     private TDoubleArrayList dataGap;
     private TDoubleArrayList width;
+    private ArrayList empty;
 
 
     protected MiddleBedHeightData(int start, int end, String eval, String desc) {
@@ -39,6 +47,18 @@
         this.soundingWidth = new TDoubleArrayList();
         this.dataGap       = new TDoubleArrayList();
         this.width         = new TDoubleArrayList();
+        this.empty         = new ArrayList();
+    }
+
+    public void addAll(double station, double height, double uncertainty,
+        double soundingWidth, double dataGap, double width, boolean isEmpty) {
+        addKM(station);
+        addMiddleHeight(height);
+        addUncertainty(uncertainty);
+        addSoundingWidth(soundingWidth);
+        addDataGap(dataGap);
+        addWidth(width);
+        addIsEmpty(isEmpty);
     }
 
 
@@ -59,7 +79,7 @@
     }
 
 
-    public void addKM(double km) {
+    protected void addKM(double km) {
         this.km.add(km);
     }
 
@@ -67,7 +87,7 @@
         return km.get(idx);
     }
 
-    public void addMiddleHeight(double middleHeight) {
+    protected void addMiddleHeight(double middleHeight) {
         this.middleHeight.add(middleHeight);
     }
 
@@ -75,7 +95,7 @@
         return middleHeight.get(idx);
     }
 
-    public void addUncertainty(double uncertainty) {
+    protected void addUncertainty(double uncertainty) {
         this.uncertainty.add(uncertainty);
     }
 
@@ -83,7 +103,7 @@
         return uncertainty.get(idx);
     }
 
-    public void addSoundingWidth(double soundingWidth) {
+    protected void addSoundingWidth(double soundingWidth) {
         this.soundingWidth.add(soundingWidth);
     }
 
@@ -91,7 +111,7 @@
         return soundingWidth.get(idx);
     }
 
-    public void addDataGap(double gap) {
+    protected void addDataGap(double gap) {
         this.dataGap.add(gap);
     }
 
@@ -99,7 +119,16 @@
         return dataGap.get(idx);
     }
 
-    public void addWidth(double width) {
+    protected void addIsEmpty(boolean empty) {
+        this.empty.add(empty);
+    }
+
+    public boolean isEmpty(int idx) {
+        return (Boolean) empty.get(idx);
+    }
+
+
+    protected void addWidth(double width) {
         this.width.add(width);
     }
 
@@ -112,12 +141,22 @@
     }
 
 
+    /**
+     * Get the points, ready to be drawn
+     * @return [[km1, km2,...],[height1,height2,...]]
+     */
     public double[][] getMiddleHeightsPoints() {
         double[][] points = new double[2][size()];
 
         for (int i = 0, n = size(); i < n; i++) {
-            points[0][i] = getKM(i);
-            points[1][i] = getMiddleHeight(i);
+            if (isEmpty(i)) {
+                points[0][i] = getKM(i);
+                points[1][i] = Double.NaN;
+            }
+            else {
+                points[0][i] = getKM(i);
+                points[1][i] = getMiddleHeight(i);
+            }
         }
 
         return points;
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/MiddleBedHeightGenerator.java	Thu Sep 27 08:53:59 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/MiddleBedHeightGenerator.java	Thu Sep 27 11:12:38 2012 +0000
@@ -212,7 +212,7 @@
 
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
 
-        StyledSeriesBuilder.addPoints(series, data.getMiddleHeightsPoints(), true);
+        StyledSeriesBuilder.addPoints(series, data.getMiddleHeightsPoints(), false);
 
         addAxisSeries(series, YAXIS.H.idx, visible);
     }

http://dive4elements.wald.intevation.org