diff gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation3D.java @ 445:f42ed4f10b79

Fixed some bugs and create "Profilschnitt" polygons via configuration. gnv-artifacts/trunk@493 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 30 Dec 2009 23:02:10 +0000
parents 0eed5749fd63
children f5a041000357
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation3D.java	Wed Dec 30 10:35:19 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/Interpolation3D.java	Wed Dec 30 23:02:10 2009 +0000
@@ -2,8 +2,13 @@
 
 import java.util.List;
 import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.Collections;
 
+import java.io.Serializable;
+
+import java.awt.Dimension;
+
 import com.vividsolutions.jts.geom.Coordinate;
 import com.vividsolutions.jts.geom.Envelope;
 
@@ -11,7 +16,11 @@
 
 import org.apache.log4j.Logger;
 
+/**
+ * @author Sascha L. Teichmann (sascha.teichmann@intevation.de)
+ */
 public class Interpolation3D
+implements   Serializable
 {
     private static Logger log = Logger.getLogger(Interpolation3D.class);
 
@@ -28,6 +37,10 @@
         this(DEFAULT_WIDTH, DEFAULT_HEIGHT);
     }
 
+    public Interpolation3D(Dimension size) {
+        this(size.width, size.height);
+    }
+
     public Interpolation3D(int width, int height) {
         this.width  = width;
         this.height = height;
@@ -49,6 +62,16 @@
         return depths;
     }
 
+    public double getMaxDepth() {
+        double maxDepth = Double.MAX_VALUE;
+        for (int i = depths!=null?depths.length-1:0; i >= 0; --i) {
+            if (!Double.isNaN(depths[i]) && depths[i] < maxDepth) {
+                maxDepth = depths[i];
+            }
+        }
+        return maxDepth;
+    }
+
     public boolean interpolate(
         List<? extends Coordinate> path,
         List<? extends XYColumn>   points,
@@ -114,13 +137,10 @@
             return false;
         }
 
-        if (debug) {
-            log.debug("max depth found: " + maxDepth);
-        }
-
         double cellHeight = Math.abs(maxDepth)/height;
 
         if (debug) {
+            log.debug("max depth found: " + maxDepth);
             log.debug("cell size: " + cellWidth + " x " + cellHeight);
         }
 

http://dive4elements.wald.intevation.org