diff gnv-artifacts/src/main/java/de/intevation/gnv/math/XYColumn.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 eb2ac62e853a
children 3cb2bea50456
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/XYColumn.java	Wed Dec 30 10:35:19 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/XYColumn.java	Wed Dec 30 23:02:10 2009 +0000
@@ -65,7 +65,12 @@
 
     public boolean prepare(XYDepth xyDepth) {
         int N = values.size();
-        if (curve == null && N > 0) {
+        if (curve == null) {
+            if (N == 0) {
+                log.error("no points for interpolation");
+                return false;
+            }
+
             if (N == 1) {
                 // only one value -> constant function
                 curve = new ConstantFunction(values.get(0).v);
@@ -78,12 +83,14 @@
                 HeightValue first = values.get(0);
                 if (first.z < 0d) {
                     values.add(0, new HeightValue(0d, first.z, first.k-1));
+                    ++N;
                 }
 
                 // if there is no value at depth repeat last value
                 HeightValue last = values.get(N-1);
                 if (last.z > depth) {
                     values.add(new HeightValue(depth, last.z, last.k+1));
+                    ++N;
                 }
                 N = values.size();
                 if (N < 3) { // interpolate linear
@@ -97,7 +104,7 @@
                     double [] z = new double[N];
                     double [] v = new double[N];
                     for (int i = 0; i < N; ++i) {
-                        HeightValue h = values.get(i);
+                        HeightValue h = values.get(N-1-i);
                         z[i] = h.z;
                         v[i] = h.v;
                     }
@@ -111,10 +118,6 @@
                 }
             }
         }
-        else {
-            log.error("no points for interpolation");
-            return false;
-        }
         return true;
     }
 

http://dive4elements.wald.intevation.org