diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MiddleBedHeightData.java @ 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 4bd3d8bbb60c
children
line wrap: on
line diff
--- 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;

http://dive4elements.wald.intevation.org