Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation2.java @ 6434:898afcce1d0a
Partial fix for flys/1303
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 26 Jun 2013 13:33:15 +0200 |
parents | af13ceeba52a |
children | e4606eae8ea5 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation2.java Wed Jun 26 13:26:43 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation2.java Wed Jun 26 13:33:15 2013 +0200 @@ -8,6 +8,9 @@ package org.dive4elements.river.artifacts.model; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; import java.util.Arrays; import org.apache.log4j.Logger; @@ -28,12 +31,57 @@ this.km = km; } + private void dump(double [][] wqs) { + double [] ws = wqs[0]; + double [] qs = wqs[1]; + + String filename = "/tmp/computed-discharge-curve-" + km + "-" + + System.currentTimeMillis() + ".txt"; + + PrintWriter pw = null; + try { + pw = + new PrintWriter( + new FileWriter(filename)); + + for (int i = 0; i < ws.length; ++i) { + pw.println(ws[i] + " " + qs[i]); + } + + pw.flush(); + } + catch (IOException ioe) { + logger.error(ioe); + } + finally { + if (pw != null) { + pw.close(); + } + } + } + public CalculationResult calculate(WstValueTable wst) { - logger.debug("Calculation2.calculate"); + boolean debug = logger.isDebugEnabled(); + + if (debug) { + logger.debug("Calculation2.calculate: km " + km); + } double [][] wqs = wst.interpolateWQ(km, this); + if (debug) { + if (hasProblems()) { + logger.debug("problems: " + problemsToString()); + } + logger.debug("wqs: " + wqs); + if (wqs != null && wqs[0] != null) { + logger.debug("wqs length: " + wqs[0].length); + // TODO: Uncomment to see the data externally. + //dump(wqs); + } + } + if (wqs == null || wqs[0].length == 0) { addProblem("cannot.compute.discharge.curve"); return new CalculationResult(new WQKms[0], this);