diff gnv-artifacts/src/main/java/de/intevation/gnv/math/AreaInterpolation.java @ 517:96a1e92e7ed2

If the number of data points to generate a "Horizontalschnitt" is above a given threshold, they are culled against an 5% extented bounding box of the interpolation area. gnv-artifacts/trunk@611 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 23 Jan 2010 17:42:04 +0000
parents d9d933e06875
children 44415ae01ddb
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/AreaInterpolation.java	Sat Jan 23 14:03:26 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/AreaInterpolation.java	Sat Jan 23 17:42:04 2010 +0000
@@ -22,6 +22,9 @@
 {
     private static Logger log = Logger.getLogger(AreaInterpolation.class);
 
+    public static final int CULL_POINT_THRESHOLD = Integer.getInteger(
+        "gnv.areainterpolation.cull.point.threshold", 1000);
+
     protected double [] raster;
 
     protected int width;
@@ -58,7 +61,17 @@
             return false;
         }
 
-        List<GridCell> cells = GridCell.pointsToGridCells(points);
+        Envelope relevantArea = null;
+        
+        if (points.size() > CULL_POINT_THRESHOLD) {
+            relevantArea = new Envelope(boundingBox);
+            relevantArea.expandBy(
+                0.05d*boundingBox.getWidth(),
+                0.05d*boundingBox.getHeight());
+        }
+
+        List<GridCell> cells = GridCell.pointsToGridCells(
+            points, relevantArea);
 
         if (cells.isEmpty()) {
             log.warn("no cells to interpolate");
@@ -98,11 +111,13 @@
 
         long startTime = System.currentTimeMillis();
 
-        int row = 0;
-        for (int j = 0; j < H; ++j, row += W) {
+        int pos = 0;
+        for (int j = 0; j < H; ++j) {
+
             double y = j*cellHeight + 0.5d*cellHeight + minY;
             double x = 0.5d*cellWidth + minX;
-            for (int i = 0; i < W; ++i, x += cellWidth) {
+
+            for (int end = pos + W; pos < end; ++pos, x += cellWidth) {
 
                 queryBuffer.init(x - EPS, x + EPS, y - EPS, y + EPS);
                 center.x = x; center.y = y;
@@ -111,7 +126,7 @@
 
                 GridCell found = finder.found;
 
-                if (found == null) {
+                if (found == null || depth.depth(center) > 0d) {
                     continue;
                 }
 
@@ -131,7 +146,7 @@
                     found.p3.x, found.p3.y,
                     found.p4.x, found.p4.y,
                     center.x);
-                raster[row+i] = Interpolation2D.interpolate(
+                raster[pos] = Interpolation2D.interpolate(
                     y1, z1,
                     y2, z2,
                     center.y);

http://dive4elements.wald.intevation.org