Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.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/WINFOArtifact.java Fri Jun 10 14:24:15 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Fri Jun 10 15:59:47 2011 +0000 @@ -1,9 +1,6 @@ package de.intevation.flys.artifacts; import java.util.List; -import java.util.Set; -import java.util.HashSet; -import java.util.ArrayList; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -32,8 +29,8 @@ import de.intevation.flys.artifacts.model.WQDay; import de.intevation.flys.artifacts.model.WQKms; import de.intevation.flys.artifacts.model.WstValueTable; -import de.intevation.flys.artifacts.model.WstValueTable.QPosition; import de.intevation.flys.artifacts.model.WstValueTableFactory; +import de.intevation.flys.artifacts.model.Calculation1; import de.intevation.flys.artifacts.model.Calculation2; import de.intevation.flys.artifacts.model.Calculation3; import de.intevation.flys.artifacts.model.Calculation4; @@ -279,43 +276,14 @@ throw new NullPointerException("No Wst found for selected river."); } - HashSet<Integer> failed = new HashSet<Integer>(); - WQKms[] results = computeWaterlevelData( - kms, qs, wst, river.getKmUp(), failed); + kms, qs, ws, wst, river.getKmUp()); // TODO Introduce a caching mechanism here! - setWaterlevelNames( - results, qSel ? qs : ws, qSel ? "Q" : "W", failed); - return results; } - - /** - * Sets the name for waterlevels where each WQKms in <i>r</i> represents a - * column. - * - * @param r The waterlevel columns. - * @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, - Set failed - ) { - int pos = 0; - for (int i = 0; i < v.length; i++) { - if (!failed.contains(i)) { - r[pos++].setName(wq + "=" + v[i]); - } - } - } - - /** * Computes the data of a waterlevel computation based on the interpolation * in WstValueTable. @@ -327,35 +295,21 @@ * @return an array of data triples that consist of W, Q and Kms. */ public static WQKms[] computeWaterlevelData( - double[] kms, - double[] qs, + double [] kms, + double [] qs, + double [] ws, WstValueTable wst, - boolean up, - Set<Integer> failed + boolean up ) { logger.info("WINFOArtifact.computeWaterlevelData"); - WQKms[] wqkms = new WQKms[qs.length]; - - ArrayList<WQKms> results = new ArrayList<WQKms>(); - - int referenceIndex = up ? 0 : kms.length-1; + Calculation1 calculation = new Calculation1(kms, qs, ws, up); - for (int i = 0; i < qs.length; i++) { - double [] oqs = new double[kms.length]; - double [] ows = new double[kms.length]; - WstValueTable.QPosition qPosition = - wst.interpolate(qs[i], kms[referenceIndex], kms, ows, oqs); - if (qPosition != null) { - results.add(new WQKms(kms, oqs, ows)); - } - else { - logger.warn("interpolation failed for q = " + qs[i]); - failed.add(i); - } - } + WQKms[] wqkms = calculation.calculate(wst); - return results.toArray(new WQKms[results.size()]); + // TODO: report problems to user + + return wqkms; }