diff gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation3D.java @ 521:1bf058f1a2d1

Generate seabed polygon to "Profilschnitte". gnv-artifacts/trunk@615 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 24 Jan 2010 20:24:03 +0000
parents 4e347624ee7c
children 44415ae01ddb
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation3D.java	Sun Jan 24 12:10:50 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation3D.java	Sun Jan 24 20:24:03 2010 +0000
@@ -33,6 +33,9 @@
     protected int width;
     protected int height;
 
+    protected double cellWidth;
+    protected double cellHeight;
+
     protected double [] raster;
     protected double [] depths;
 
@@ -57,6 +60,14 @@
         return width;
     }
 
+    public double getCellWidth() {
+        return cellWidth;
+    }
+
+    public double getCellHeight() {
+        return cellHeight;
+    }
+
     public double [] getRaster() {
         return raster;
     }
@@ -160,7 +171,7 @@
         i = 0;
         for (double p = cellWidth*0.5; i < depths.length; ++i, p += cellWidth) {
             double depth = depths[i];
-            if (Double.isNaN(depth)) {
+            if (Double.isNaN(depth) || depth >= 0d) {
                 continue;
             }
             linearToMap.locate(p, center);
@@ -196,8 +207,8 @@
                     n2.x, n2.y,
                     n3.x, n3.y,
                     center.x);
-                int j = i;
-                for (double z = -cellHeight*0.5; 
+                double z = -cellHeight*0.5;
+                for (int j = i;
                     j < raster.length && z >= depth;
                     z -= cellHeight, j += width) {
 
@@ -220,11 +231,16 @@
                         center.y);
                     raster[j] = value;
                 }
+                // XXX: Adjusted depth to create no gap 
+                // between last value and ground.
+                depths[i] = z+0.5d*cellHeight; 
             } // down the x/y column
         } // all along the track
 
-        this.depths = depths;
-        this.raster = raster;
+        this.depths     = depths;
+        this.raster     = raster;
+        this.cellWidth  = cellWidth;
+        this.cellHeight = cellHeight;
 
         return true;
     }

http://dive4elements.wald.intevation.org