Mercurial > dive4elements > river
changeset 377:0ccf7200fc51
Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
flys-artifacts/trunk@1789 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 02 May 2011 12:47:10 +0000 |
parents | aa0889141b15 |
children | 20c3a5b36434 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java |
diffstat | 3 files changed, 85 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Mon May 02 12:41:24 2011 +0000 +++ b/flys-artifacts/ChangeLog Mon May 02 12:47:10 2011 +0000 @@ -1,3 +1,13 @@ +2011-05-02 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: New + methods for retrieving selected W values (getWs()). + + * src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: The + method for retrieving waterlevel data takes care on selected Ws, now. + The selected Ws are transformed using the DischargeTables.getQForW() + into Q values. + 2011-05-02 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/artifacts/model/DischargeTables.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Mon May 02 12:41:24 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Mon May 02 12:47:10 2011 +0000 @@ -32,6 +32,7 @@ import de.intevation.flys.model.River; import de.intevation.flys.artifacts.context.FLYSContext; +import de.intevation.flys.artifacts.model.DischargeTables; import de.intevation.flys.artifacts.model.RiverFactory; import de.intevation.flys.artifacts.states.DefaultState; @@ -533,6 +534,76 @@ * @return the selected Q values or null, if no Q values are selected. */ public double[] getQs() { + StateData dMode = getData("wq_mode"); + + String mode = dMode != null ? (String) dMode.getValue() : ""; + + if (mode.equals("Q")) { + return getWQTriple(); + } + else { + logger.warn("You try to get Qs, but W has been inserted."); + return null; + } + } + + + /** + * This method returns the W values. + * + * @return the selected W values or null, if no W values are selected. + */ + public double[] getWs() { + StateData dMode = getData("wq_mode"); + + String mode = dMode != null ? (String) dMode.getValue() : ""; + + if (mode.equals("W")) { + return getWQTriple(); + } + else { + logger.warn("You try to get Qs, but W has been inserted."); + return null; + } + } + + + /** + * Returns the Qs for a number of Ws. This method makes use of + * DischargeTables.getQForW(). + * + * @param ws An array of W values. + * + * @return an array of Q values. + */ + public double[] getQsForWs(double[] ws) { + logger.debug("FLYSArtifact.getQsForWs"); + + River r = getRiver(); + Gauge g = getGauge(); + + DischargeTables dt = new DischargeTables(r.getName(), g.getName()); + Map<String, double [][]> tmp = dt.getValues(); + + double[][] values = tmp.get(g.getName()); + double[] qs = new double[ws.length]; + + for (int i = 0; i < ws.length; i++) { + qs[i] = dt.getQForW(values, ws[i]); + logger.debug("Q for " + ws[i] + " = " + qs[i]); + } + + return qs; + } + + + /** + * This method returns an array of inserted WQ triples that consist of from, + * to and the step width. + * + * @return an array of from, to and step width. + */ + protected double[] getWQTriple() { StateData dFrom = getData("wq_from"); StateData dTo = getData("wq_to");
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Mon May 02 12:41:24 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Mon May 02 12:47:10 2011 +0000 @@ -248,7 +248,10 @@ double[] qs = getQs(); if (qs == null) { - // TODO Use DischargeTableValue.getQForW() to compute the Qs. + logger.debug("Determine Q values based on a set of W values."); + + double[] ws = getWs(); + qs = getQsForWs(ws); } WstValueTable wst = WstValueTable.getTable(river);