Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java @ 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 | 254a3f3556ee |
children | a9ff696c2d18 |
comparison
equal
deleted
inserted
replaced
6999:3e93f29281bc | 7000:7a7cb22395b4 |
---|---|
263 } | 263 } |
264 return null; | 264 return null; |
265 } | 265 } |
266 | 266 |
267 double [] splineQs = new double[W]; | 267 double [] splineQs = new double[W]; |
268 double [] splineWs = new double[W]; | |
268 | 269 |
269 for (int i = 0; i < W; ++i) { | 270 for (int i = 0; i < W; ++i) { |
270 double sq = table.getQIndex(i, km); | 271 double sq = table.getQIndex(i, km); |
271 if (Double.isNaN(sq) && errors != null) { | 272 if (Double.isNaN(sq) && errors != null) { |
272 errors.addProblem( | 273 errors.addProblem( |
273 km, "no.q.found.in.column", (i+1)); | 274 km, "no.q.found.in.column", (i+1)); |
274 } | 275 } |
275 splineQs[i] = sq; | 276 splineQs[i] = sq; |
276 } | 277 splineWs[i] = ws[i]; |
278 } | |
279 | |
280 DoubleUtil.sortByFirst(splineQs, splineWs); | |
277 | 281 |
278 try { | 282 try { |
279 SplineInterpolator interpolator = new SplineInterpolator(); | 283 SplineInterpolator interpolator = new SplineInterpolator(); |
280 PolynomialSplineFunction spline = | 284 PolynomialSplineFunction spline = |
281 interpolator.interpolate(splineQs, ws); | 285 interpolator.interpolate(splineQs, splineWs); |
282 | 286 |
283 return new SplineFunction(spline, splineQs, ws); | 287 return new SplineFunction(spline, splineQs, ws); |
284 } | 288 } |
285 catch (MathIllegalArgumentException miae) { | 289 catch (MathIllegalArgumentException miae) { |
286 if (errors != null) { | 290 if (errors != null) { |