[PATCH] Fix for flys/issue1018: Sort the pairs of (q, w) in q before creating a spline also in case of non interpolation

Wald Commits scm-commit at wald.intevation.org
Thu Sep 12 18:04:52 CEST 2013


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1379001888 -7200
# Node ID 7a7cb22395b46fac832e7efb5c14b2ce1ed81ceb
# Parent  3e93f29281bcf0b580d718855afca2ec72bf4739
Fix for flys/issue1018: Sort the pairs of (q, w) in q before creating a spline also in case of non interpolation.

diff -r 3e93f29281bc -r 7a7cb22395b4 artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java
--- 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);
             }


More information about the Dive4elements-commits mailing list