changeset 416:04a242c67fe6

Added support of gap detection in horizontalcrossprofile charts. gnv-artifacts/trunk@464 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 21 Dec 2009 13:49:49 +0000
parents b3ad3cb94855
children 9697675ede21
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalProfileChart.java gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation2D.java gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java
diffstat 5 files changed, 39 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Thu Dec 17 18:56:03 2009 +0000
+++ b/gnv-artifacts/ChangeLog	Mon Dec 21 13:49:49 2009 +0000
@@ -1,3 +1,13 @@
+2009-12-21  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java,
+	  src/main/java/de/intevation/gnv/math/Interpolation2D.java: Add 'null'
+	  values for gap detection to result collection instead of omitting them.
+	  
+	* src/main/java/de/intevation/gnv/chart/VerticalProfileChart.java,
+	  src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.jav:
+	  Handle null values - don't throw an exception.
+
 2009-12-17	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	RELEASE 0.3
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalProfileChart.java	Thu Dec 17 18:56:03 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalProfileChart.java	Mon Dec 21 13:49:49 2009 +0000
@@ -116,7 +116,9 @@
             }
 
             addValue(row, series);
-            storeMaxRange(row.getDouble("YORDINATE"), parameter);
+            Double value = row.getDouble("YORDINATE");
+            if (value != null)
+                storeMaxRange(value, parameter);
             endPos++;
         }
 
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation2D.java	Thu Dec 17 18:56:03 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation2D.java	Mon Dec 21 13:49:49 2009 +0000
@@ -20,7 +20,7 @@
     private static Logger log = Logger.getLogger(Interpolation2D.class);
 
     public interface Consumer {
-        void interpolated(Coordinate point);
+        void interpolated(Coordinate point, boolean success);
     } // interface Consumer
 
     private Interpolation2D() {
@@ -38,8 +38,10 @@
         int N = path.size();
         int M = points.size();
 
-        log.debug("Size of path: " + N);
-        log.debug("Size of points: " + M);
+        if (log.isDebugEnabled()) {
+            log.debug("Size of path: " + N);
+            log.debug("Size of points: " + M);
+        }
 
         if (M < 1 || N < 2) { // nothing to do
             return;
@@ -70,7 +72,7 @@
             }
         }
 
-        dxMax = dxMax + 1e-5d;
+        dxMax += 1e-5d;
 
         map.clear();
 
@@ -97,11 +99,13 @@
             }
         }
 
-        dyMax = dyMax + 1e-5d;
+        dyMax += 1e-5d;
 
         map = null;
 
-        log.debug("buffer size: " + dxMax + " / " + dyMax);
+        if (log.isDebugEnabled()) {
+            log.debug("buffer size: " + dxMax + " / " + dyMax);
+        }
 
         // put into spatial index to speed up finding neighbors.
         Quadtree spatialIndex = new Quadtree();
@@ -187,15 +191,19 @@
                     y1, z1,
                     y2, z2,
                     center.y);
-                consumer.interpolated(center);
+                consumer.interpolated(center, true);
                 ++interpolations;
             }
             else {
+                consumer.interpolated(center, false);
                 ++missedInterpolations;
             }
         }
 
-        log.debug("interpolations: " + interpolations + " / " + missedInterpolations);
+        if (log.isDebugEnabled()) {
+            log.debug("interpolations: " + 
+                interpolations + " / " + missedInterpolations);
+        }
     }
 
     public static final double interpolate(
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java	Thu Dec 17 18:56:03 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java	Mon Dec 21 13:49:49 2009 +0000
@@ -395,7 +395,7 @@
             points.add(p);
         }
 
-        public void interpolated(Coordinate coordinate) {
+        public void interpolated(Coordinate coordinate, boolean success) {
             DefaultResult result = new DefaultResult(descriptor);
             ResultDescriptor pd = prototyp.getResultDescriptor();
 
@@ -409,7 +409,9 @@
                     result.addColumnValue(j, toWKT(coordinate));
                 }
                 else if (colname.equals("YORDINATE")) {
-                    result.addColumnValue(j, Double.valueOf(coordinate.z));
+                    result.addColumnValue(j, success 
+                        ? Double.valueOf(coordinate.z)
+                        : null);
                 }
                 else {
                     result.addColumnValue(j, prototyp.getObject(i));
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java	Thu Dec 17 18:56:03 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java	Mon Dec 21 13:49:49 2009 +0000
@@ -112,9 +112,12 @@
                         lSeries++;
                     } else {
 
-                        lStatistics.addValue(row.getDouble("YORDINATE"));
-                        Double x = this.calculateXOrdinateValue(previousRow, row);
-                        lRegression.addData(x, row.getDouble("YORDINATE"));
+                        Double value = row.getDouble("YORDINATE");
+                        if (value != null) {
+                            lStatistics.addValue(value.doubleValue());
+                            Double x = calculateXOrdinateValue(previousRow,row);
+                            lRegression.addData(x, value.doubleValue());
+                        }
                         previousRow = row;
                         row = resultIterator.next();
                     }

http://dive4elements.wald.intevation.org