Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java @ 678:19a3185822a4
Added error reporting to 'Wasserspiegellage' calculation.
flys-artifacts/trunk@2102 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 10 Jun 2011 15:59:47 +0000 |
parents | a95f34f1f39a |
children | eab5e5089d77 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java Fri Jun 10 14:24:15 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java Fri Jun 10 15:59:47 2011 +0000 @@ -494,28 +494,36 @@ } public QPosition interpolate( - double q, - double referenceKm, - double [] kms, - double [] ws, - double [] qs + double q, + double referenceKm, + double [] kms, + double [] ws, + double [] qs, + Calculation errors ) { - return interpolate(q, referenceKm, kms, ws, qs, 0, kms.length); + return interpolate( + q, referenceKm, kms, ws, qs, 0, kms.length, errors); } public QPosition interpolate( - double q, - double referenceKm, - double [] kms, - double [] ws, - double [] qs, - int startIndex, - int length + double q, + double referenceKm, + double [] kms, + double [] ws, + double [] qs, + int startIndex, + int length, + Calculation errors ) { QPosition qPosition = getQPosition(referenceKm, q); if (qPosition == null) { // we cannot locate q at km + Arrays.fill(ws, Double.NaN); + Arrays.fill(qs, Double.NaN); + if (errors != null) { + errors.addProblem(referenceKm, "cannot find q"); + } return null; } @@ -524,15 +532,24 @@ int R1 = rows.size()-1; for (int i = startIndex, end = startIndex+length; i < end; ++i) { - kmKey.km = kms[i]; + if (Double.isNaN(qs[i] = getQ(qPosition, kms[i]))) { + if (errors != null) { + errors.addProblem(kms[i], "cannot find q"); + } + ws[i] = Double.NaN; + continue; + } + + kmKey.km = kms[i]; int rowIndex = Collections.binarySearch(rows, kmKey); - qs[i] = getQ(qPosition, kms[i]); - if (rowIndex >= 0) { // direct row match - ws[i] = rows.get(rowIndex).getW(qPosition); + if (Double.isNaN(ws[i] = rows.get(rowIndex).getW(qPosition)) + && errors != null) { + errors.addProblem(kms[i], "cannot find w"); + } continue; } @@ -540,13 +557,19 @@ if (rowIndex < 1 || rowIndex >= R1) { // do not extrapolate + if (errors != null) { + errors.addProblem(kms[i], "cannot find km"); + } ws[i] = Double.NaN; continue; } Row r1 = rows.get(rowIndex-1); Row r2 = rows.get(rowIndex); - ws[i] = r1.getW(r2, kms[i], qPosition); + if (Double.isNaN(ws[i] = r1.getW(r2, kms[i], qPosition)) + && errors != null) { + errors.addProblem(kms[i], "cannot find w"); + } } return qPosition;