Mercurial > dive4elements > river
changeset 643:a9bde508824a
flys/issue82: Only successful interpolations are named.
flys-artifacts/trunk@2027 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 30 May 2011 09:19:57 +0000 |
parents | 2dbbb5be30a1 |
children | 02c0cce0e469 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java |
diffstat | 2 files changed, 50 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri May 27 16:52:37 2011 +0000 +++ b/flys-artifacts/ChangeLog Mon May 30 09:19:57 2011 +0000 @@ -1,3 +1,10 @@ +2011-05-30 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + flys/issue82 + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: + Only successful interpolations are named. + 2011-05-27 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/flys/artifacts/math/BackJumpCorrector.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri May 27 16:52:37 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Mon May 30 09:19:57 2011 +0000 @@ -1,6 +1,8 @@ package de.intevation.flys.artifacts; import java.util.List; +import java.util.Set; +import java.util.HashSet; import java.util.Vector; import java.util.ArrayList; @@ -277,11 +279,15 @@ throw new NullPointerException("No Wst found for selected river."); } - WQKms[] results = computeWaterlevelData(kms, qs, wst, river.getKmUp()); + HashSet<Integer> failed = new HashSet<Integer>(); + + WQKms[] results = computeWaterlevelData( + kms, qs, wst, river.getKmUp(), failed); // TODO Introduce a caching mechanism here! - setWaterlevelNames(results, qSel ? qs : ws, qSel ? "Q" : "W"); + setWaterlevelNames( + results, qSel ? qs : ws, qSel ? "Q" : "W", failed); return results; } @@ -295,9 +301,17 @@ * @param v The input values of the computations. * @param wq The WQ mode - can be one of "W" or "Q". */ - public static void setWaterlevelNames(WQKms[] r, double[] v, String wq) { + public static void setWaterlevelNames( + WQKms[] r, + double[] v, + String wq, + Set failed + ) { + int pos = 0; for (int i = 0; i < v.length; i++) { - r[i].setName(wq + "=" + Double.toString(v[i])); + if (!failed.contains(i)) { + r[pos++].setName(wq + "=" + v[i]); + } } } @@ -316,7 +330,8 @@ double[] kms, double[] qs, WstValueTable wst, - boolean up + boolean up, + Set<Integer> failed ) { logger.info("WINFOArtifact.computeWaterlevelData"); @@ -336,6 +351,7 @@ } else { logger.warn("interpolation failed for q = " + qs[i]); + failed.add(i); } } @@ -567,7 +583,12 @@ } if (qs.length == 1) { double [] kms = getKms(segments[0]); - return computeWaterlevelData(kms, qs, wst, kmUp); + HashSet<Integer> failed = new HashSet<Integer>(); + WQKms [] results = computeWaterlevelData + (kms, qs, wst, kmUp, failed); + setWaterlevelNames( + results, qs, isQ() ? "Q" : "W", failed); + return results; } } @@ -652,6 +673,8 @@ int referenceIndex = kmUp ? 0 : boundKms.length-1; + HashSet<Integer> failed = new HashSet<Integer>(); + for (int i = 0; i < iqs.length; ++i) { double [] iqsi = iqs[i]; @@ -662,6 +685,7 @@ if (qPosition == null) { logger.warn("interpolation failed for " + iqsi[i]); + failed.add(i); continue; } @@ -691,7 +715,8 @@ WQKms [] wqkms = results.toArray(new WQKms[results.size()]); - setDischargeLongitudinalSectionNames(wqkms, iqs, isQ() ? "Q" : "W"); + setDischargeLongitudinalSectionNames( + wqkms, iqs, isQ() ? "Q" : "W", failed); return wqkms; } @@ -724,15 +749,21 @@ * in <i>r</i> represents a column. */ public static void setDischargeLongitudinalSectionNames( - WQKms [] wqkms, - double [][] iqs, - String wq + WQKms [] wqkms, + double [][] iqs, + String wq, + Set<Integer> failed ) { logger.debug("WINFOArtifact.setDischargeLongitudinalSectionNames"); // TODO: I18N - for (int j = 0; j < wqkms.length; ++j) { + int pos = 0; + + for (int j = 0; j < iqs.length; ++j) { + if (failed.contains(j)) { + continue; + } StringBuilder sb = new StringBuilder(wq) .append(" benutzerdefiniert ("); @@ -745,7 +776,7 @@ } sb.append(")"); - wqkms[j].setName(sb.toString()); + wqkms[pos++].setName(sb.toString()); } } }