changeset 7000:7a7cb22395b4

Fix for flys/issue1018: Sort the pairs of (q, w) in q before creating a spline also in case of non interpolation.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 12 Sep 2013 18:04:48 +0200
parents 3e93f29281bc
children 5fe8c64b48d4
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java	Thu Sep 12 16:35:07 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java	Thu Sep 12 18:04:48 2013 +0200
@@ -265,6 +265,7 @@
             }
 
             double [] splineQs = new double[W];
+            double [] splineWs = new double[W];
 
             for (int i = 0; i < W; ++i) {
                 double sq = table.getQIndex(i, km);
@@ -273,12 +274,15 @@
                         km, "no.q.found.in.column", (i+1));
                 }
                 splineQs[i] = sq;
+                splineWs[i] = ws[i];
             }
 
+            DoubleUtil.sortByFirst(splineQs, splineWs);
+
             try {
                 SplineInterpolator interpolator = new SplineInterpolator();
                 PolynomialSplineFunction spline =
-                    interpolator.interpolate(splineQs, ws);
+                    interpolator.interpolate(splineQs, splineWs);
 
                 return new SplineFunction(spline, splineQs, ws);
             }

http://dive4elements.wald.intevation.org