annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 450:c8bb38115290

Enabled the discharge longitudinal section to be exported as WST. flys-artifacts/trunk@1944 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 18 May 2011 10:59:38 +0000
parents 9814d4808410
children 73bc64c4a7b0
rev   line source
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts;
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 105
diff changeset
3 import java.util.List;
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
4 import java.util.Vector;
449
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
5 import java.util.ArrayList;
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 105
diff changeset
6
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import org.w3c.dom.Document;
110
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
8 import org.w3c.dom.Element;
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
9 import org.w3c.dom.Node;
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import org.apache.log4j.Logger;
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12
110
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
13 import de.intevation.artifacts.ArtifactNamespaceContext;
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import de.intevation.artifacts.CallContext;
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
110
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
16 import de.intevation.artifactdatabase.ProtocolUtils;
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
17 import de.intevation.artifactdatabase.state.Output;
110
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
18 import de.intevation.artifactdatabase.state.State;
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
19 import de.intevation.artifactdatabase.state.StateEngine;
112
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
20 import de.intevation.artifactdatabase.transition.TransitionEngine;
110
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
21
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 105
diff changeset
22 import de.intevation.artifacts.common.utils.XMLUtils;
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 105
diff changeset
23
385
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
24 import de.intevation.flys.model.Gauge;
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
25 import de.intevation.flys.model.River;
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
26
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
27 import de.intevation.flys.artifacts.states.DefaultState;
109
9891d133f08d Improved the init process of the WINFOArtifact - there are two new states to select the river and the gauge.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 105
diff changeset
28 import de.intevation.flys.artifacts.context.FLYSContext;
402
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
29 import de.intevation.flys.artifacts.math.BackJumpCorrector;
385
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
30 import de.intevation.flys.artifacts.model.MainValuesFactory;
402
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
31 import de.intevation.flys.artifacts.model.WQCKms;
385
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
32 import de.intevation.flys.artifacts.model.WQDay;
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
33 import de.intevation.flys.artifacts.model.WQKms;
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
34 import de.intevation.flys.artifacts.model.WstValueTable;
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
35 import de.intevation.flys.artifacts.model.WstValueTableFactory;
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 /**
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 * The default WINFO artifact.
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 *
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 */
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 115
diff changeset
43 public class WINFOArtifact extends FLYSArtifact {
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 /** The logger for this class */
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 private static Logger logger = Logger.getLogger(WINFOArtifact.class);
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
49 /** The name of the artifact.*/
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
50 public static final String ARTIFACT_NAME = "winfo";
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
51
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
52 /** XPath */
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
53 public static final String XPATH_STATIC_UI ="/art:result/art:ui/art:static";
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
54
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
55
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 /**
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 * The default constructor.
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 */
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 public WINFOArtifact() {
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 }
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 /**
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 * This method returns a description of this artifact.
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 *
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 * @param data Some data.
128
206312c2aa76 I18N of strings for the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
67 * @param context The CallContext.
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 *
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 * @return the description of this artifact.
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 */
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 public Document describe(Document data, CallContext context) {
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 115
diff changeset
72 logger.debug("Describe: the current state is: " + getCurrentStateId());
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
112
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
74 FLYSContext flysContext = null;
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
75 if (context instanceof FLYSContext) {
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
76 flysContext = (FLYSContext) context;
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
77 }
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
78 else {
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
79 flysContext = (FLYSContext) context.globalContext();
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
80 }
110
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
81
112
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
82 StateEngine stateEngine = (StateEngine) flysContext.get(
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
83 FLYSContext.STATE_ENGINE_KEY);
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
84
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
85 TransitionEngine transitionEngine = (TransitionEngine) flysContext.get(
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
86 FLYSContext.TRANSITION_ENGINE_KEY);
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
87
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
88 List<State> reachable = transitionEngine.getReachableStates(
355
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
89 this, getCurrentState(context), stateEngine);
112
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
90
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
91 Document description = XMLUtils.newDocument();
110
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
92 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
93 description,
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
94 ArtifactNamespaceContext.NAMESPACE_URI,
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
95 ArtifactNamespaceContext.NAMESPACE_PREFIX);
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
96
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
97 Element root = ProtocolUtils.createRootNode(creator);
115
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 112
diff changeset
98 description.appendChild(root);
b51e92fef704 The RiverSelect state creates the dynamic UI part for the describe document now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 112
diff changeset
99
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 115
diff changeset
100 State current = getCurrentState(context);
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 115
diff changeset
101
110
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
102 ProtocolUtils.appendDescribeHeader(creator, root, identifier(), hash());
119
84c0b151203e Added a FLYSArtifact that serves as the default artifact for the FLYS application.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 115
diff changeset
103 ProtocolUtils.appendState(creator, root, current);
112
0fab16cb4d44 Added the current state and reachable states description to the describe document of the WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 110
diff changeset
104 ProtocolUtils.appendReachableStates(creator, root, reachable);
110
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
105
303
2d393c8bd38c Write the name of an artifact into the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 302
diff changeset
106 Element name = ProtocolUtils.createArtNode(
2d393c8bd38c Write the name of an artifact into the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 302
diff changeset
107 creator, "name",
2d393c8bd38c Write the name of an artifact into the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 302
diff changeset
108 new String[] { "value" },
2d393c8bd38c Write the name of an artifact into the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 302
diff changeset
109 new String[] { getName() });
2d393c8bd38c Write the name of an artifact into the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 302
diff changeset
110
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
111 Element ui = ProtocolUtils.createArtNode(
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
112 creator, "ui", null, null);
110
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
113
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
114 Element staticUI = ProtocolUtils.createArtNode(
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
115 creator, "static", null, null);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
116
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
117 Element outs = ProtocolUtils.createArtNode(
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
118 creator, "outputmodes", null, null);
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
119 appendOutputModes(description, outs, context, identifier());
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
120
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
121 appendStaticUI(description, staticUI, context, identifier());
128
206312c2aa76 I18N of strings for the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
122
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
123 Element dynamic = current.describe(
306
35301cc3b875 Modified the states' describe() method - related to the last commit.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 303
diff changeset
124 this,
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
125 description,
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
126 root,
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
127 context,
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
128 identifier());
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
129
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
130 if (dynamic != null) {
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
131 ui.appendChild(dynamic);
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
132 }
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
133
128
206312c2aa76 I18N of strings for the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
134 ui.appendChild(staticUI);
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
135
303
2d393c8bd38c Write the name of an artifact into the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 302
diff changeset
136 root.appendChild(name);
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
137 root.appendChild(ui);
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
138 root.appendChild(outs);
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
139
110
ff3335057f11 Improved the WINFO artifact. Describe() returns the uuid and the hash of the artifact instead of just nothing.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 109
diff changeset
140 return description;
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 }
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
142
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
143
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
144 /**
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
145 * Returns the name of the concrete artifact.
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
146 *
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
147 * @return the name of the concrete artifact.
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
148 */
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
149 public String getName() {
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
150 return ARTIFACT_NAME;
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
151 }
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
152
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
153
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
154 protected void appendOutputModes(
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
155 Document doc,
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
156 Element outs,
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
157 CallContext context,
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
158 String uuid)
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
159 {
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
160 Vector<String> stateIds = getPreviousStateIds();
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
161
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
162 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
163 doc,
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
164 ArtifactNamespaceContext.NAMESPACE_URI,
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
165 ArtifactNamespaceContext.NAMESPACE_PREFIX);
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
166
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
167 FLYSContext flysContext = getFlysContext(context);
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
168 StateEngine engine = (StateEngine) flysContext.get(
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
169 FLYSContext.STATE_ENGINE_KEY);
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
170
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
171 for (String stateId: stateIds) {
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
172 logger.debug("Append output modes for state: " + stateId);
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
173 State state = engine.getState(stateId);
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
174
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
175 List<Output> list = state.getOutputs();
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
176 if (list == null || list.size() == 0) {
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
177 continue;
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
178 }
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
179
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
180 ProtocolUtils.appendOutputModes(creator, outs, list);
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
181 }
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
182
355
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
183 try {
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
184 DefaultState cur = (DefaultState) getCurrentState(context);
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
185 if (cur.validate(this, context)) {
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
186 List<Output> list = cur.getOutputs();
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
187 if (list != null && list.size() > 0) {
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
188 logger.debug(
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
189 "Append output modes for state: " + cur.getID());
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
190
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
191 ProtocolUtils.appendOutputModes(creator, outs, list);
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
192 }
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
193 }
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
194 }
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
195 catch (IllegalArgumentException iae) {
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
196 // state is not valid, so we do not append its outputs.
d97982627596 Bugfixes: Adapted a broken method call of TransitionEngine.isStateReachable() and added the outputs of a current state to the DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 306
diff changeset
197 }
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
198 }
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
199
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
200
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
201 /**
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
202 * This method appends the static data - that has already been inserted by
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
203 * the user - to the static node of the DESCRIBE document.
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
204 *
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
205 * @param doc The document.
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
206 * @param ui The root node.
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
207 * @param context The CallContext.
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
208 * @param uuid The identifier of the artifact.
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
209 */
128
206312c2aa76 I18N of strings for the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
210 protected void appendStaticUI(
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
211 Document doc,
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
212 Node ui,
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
213 CallContext context,
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
214 String uuid)
128
206312c2aa76 I18N of strings for the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
215 {
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
216 Vector<String> stateIds = getPreviousStateIds();
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
217
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
218 FLYSContext flysContext = getFlysContext(context);
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
219 StateEngine engine = (StateEngine) flysContext.get(
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
220 FLYSContext.STATE_ENGINE_KEY);
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
221
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
222 for (String stateId: stateIds) {
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
223 logger.debug("Append static data for state: " + stateId);
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
224 DefaultState state = (DefaultState) engine.getState(stateId);
302
f526f02e8ce2 Bugfix: States are filled with data before they describe themself.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 300
diff changeset
225 state = (DefaultState) fillState(state);
f526f02e8ce2 Bugfix: States are filled with data before they describe themself.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 300
diff changeset
226
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
227 ui.appendChild(state.describeStatic(doc, ui, context, uuid));
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
228 }
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
229 }
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
230
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
231
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
232 //
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
233 // METHODS FOR RETRIEVING COMPUTED DATA FOR DIFFERENT CHART TYPES
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
234 //
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
235
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
236 /**
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
237 * Returns the data that is computed by a waterlevel computation.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
238 *
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
239 * @return an array of data triples that consist of W, Q and Kms.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
240 */
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
241 public WQKms[] getWaterlevelData()
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
242 throws NullPointerException
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
243 {
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
244 logger.debug("WINFOArtifact.getWaterlevelData");
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
245
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
246 River river = getRiver();
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
247 if (river == null) {
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
248 throw new NullPointerException("No river selected.");
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
249 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
250
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
251 double[] kms = getKms();
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
252 if (kms == null) {
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
253 throw new NullPointerException("No Kms selected.");
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
254 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
255
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
256 double[] qs = getQs();
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
257 double[] ws = null;
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
258 boolean qSel = true;
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
259
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
260 if (qs == null) {
377
0ccf7200fc51 Enabled the server to handle longitudinal section chart requests with inserted W data - Ws are transformed into Qs then.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 362
diff changeset
261 logger.debug("Determine Q values based on a set of W values.");
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
262 qSel = false;
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
263 ws = getWs();
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
264 qs = getQsForWs(ws);
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
265 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
266
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
267 WstValueTable wst = WstValueTableFactory.getTable(river);
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
268 if (wst == null) {
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
269 throw new NullPointerException("No Wst found for selected river.");
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
270 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
271
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
272 WQKms[] results = computeWaterlevelData(kms, qs, wst);
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
273
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
274 // TODO Introduce a caching mechanism here!
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
275
447
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
276 setWaterlevelNames(results, qSel ? qs : ws, qSel ? "Q" : "W");
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
277
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
278 return results;
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
279 }
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
280
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
281
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
282 /**
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
283 * Sets the name for waterlevels where each WQKms in <i>r</i> represents a
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
284 * column.
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
285 *
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
286 * @param r The waterlevel columns.
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
287 * @param v The input values of the computations.
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
288 * @param wq The WQ mode - can be one of "W" or "Q".
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
289 */
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
290 public static void setWaterlevelNames(WQKms[] r, double[] v, String wq) {
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
291 for (int i = 0; i < v.length; i++) {
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
292 r[i].setName(wq + "=" + Double.toString(v[i]));
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
293 }
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
294 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
295
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
296
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
297 /**
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
298 * Computes the data of a waterlevel computation based on the interpolation
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
299 * in WstValueTable.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
300 *
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
301 * @param kms The kilometer values.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
302 * @param qa The discharge values.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
303 * @param wst The WstValueTable used for the interpolation.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
304 *
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
305 * @return an array of data triples that consist of W, Q and Kms.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
306 */
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
307 public static WQKms[] computeWaterlevelData(
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
308 double[] kms,
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
309 double[] qs,
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
310 WstValueTable wst)
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
311 {
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
312 logger.info("WINFOArtifact.computeWaterlevelData");
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
313
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
314 WQKms[] wqkms = new WQKms[qs.length];
380
5f55047a17e8 Moved expensive allocation of result arrays out of km loop.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 377
diff changeset
315
449
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
316 ArrayList<WQKms> results = new ArrayList<WQKms>();
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
317
449
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
318 for (int i = 0; i < qs.length; i++) {
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
319 double [] oqs = new double[kms.length];
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
320 double [] ows = new double[kms.length];
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
321 int referenceIndex = 0; // TODO: Make depend on the flow direction
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
322 WstValueTable.QPosition qPosition =
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
323 wst.interpolate(qs[i], referenceIndex, kms, ows, oqs);
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
324 if (qPosition != null) {
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
325 results.add(new WQKms(kms, oqs, ows));
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
326 }
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
327 else {
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
328 logger.warn("interpolation failed for q = " + qs[i]);
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
329 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
330 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
331
449
9814d4808410 flys/issue69: Connected calculation with the UI
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 447
diff changeset
332 return results.toArray(new WQKms[results.size()]);
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
333 }
385
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
334
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
335
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
336 /**
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
337 * Returns the data that is computed by a duration curve computation.
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
338 *
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
339 * @return the data computed by a duration curve computation.
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
340 */
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
341 public WQDay getDurationCurveData()
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
342 throws NullPointerException
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
343 {
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
344 logger.debug("WINFOArtifact.getDurationCurveData");
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
345
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
346 River r = getRiver();
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
347
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
348 if (r == null) {
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
349 throw new NullPointerException("Cannot determine river.");
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
350 }
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
351
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
352 Gauge g = getGauge();
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
353
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
354 if (g == null) {
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
355 throw new NullPointerException("Cannot determine gauge.");
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
356 }
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
357
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
358 double[] locations = getLocations();
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
359
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
360 if (locations == null) {
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
361 throw new NullPointerException("Cannot determine location.");
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
362 }
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
363
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
364 WstValueTable wst = WstValueTableFactory.getTable(r);
385
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
365 if (wst == null) {
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
366 throw new NullPointerException("No Wst found for selected river.");
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
367 }
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
368
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
369 // TODO Introduce a caching mechanism here!
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
370
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
371 return computeDurationCurveData(g, wst, locations[0]);
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
372 }
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
373
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
374
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
375 /**
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
376 * Computes the data used to create duration curves.
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
377 *
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
378 * @param gauge The selected gauge.
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
379 * @param location The selected location.
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
380 *
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
381 * @return the computed data.
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
382 */
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
383 public static WQDay computeDurationCurveData(
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
384 Gauge gauge,
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
385 WstValueTable wst,
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
386 double location)
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
387 {
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
388 logger.info("WINFOArtifact.computeDurationCurveData");
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
389
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
390 Object[] obj = MainValuesFactory.getDurationCurveData(gauge);
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
391
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
392 int[] days = (int[]) obj[0];
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
393 double[] qs = (double[]) obj[1];
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
394
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
395 double[] interpolatedW = new double[qs.length];
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
396 interpolatedW = wst.interpolateW(location, qs, interpolatedW);
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
397
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
398 WQDay wqday = new WQDay(qs.length);
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
399
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
400 for (int i = 0; i < days.length; i++) {
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
401 wqday.add(days[i], interpolatedW[i], qs[i]);
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
402 }
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
403
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
404 return wqday;
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
405 }
393
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
406
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
407
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
408 /**
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
409 * Returns the data that is computed by a discharge curve computation.
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
410 *
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
411 * @return the data computed by a discharge curve computation.
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
412 */
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
413 public WQKms getComputedDischargeCurveData()
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
414 throws NullPointerException
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
415 {
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
416 logger.debug("WINFOArtifact.getComputedDischargeCurveData");
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
417
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
418 River r = getRiver();
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
419
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
420 if (r == null) {
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
421 throw new NullPointerException("Cannot determine river.");
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
422 }
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
423
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
424 double[] locations = getLocations();
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
425
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
426 if (locations == null) {
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
427 throw new NullPointerException("Cannot determine location.");
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
428 }
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
429
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
430 WstValueTable wst = WstValueTableFactory.getTable(r);
393
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
431 if (wst == null) {
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
432 throw new NullPointerException("No Wst found for selected river.");
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
433 }
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
434
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
435 // TODO Introduce a caching mechanism here!
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
436
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
437 return computeDischargeCurveData(wst, locations[0]);
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
438 }
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
439
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
440
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
441 /**
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
442 * Computes the data used to create computed discharge curves.
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
443 *
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
444 * @param wst The WstValueTable that is used for the interpolation.
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
445 * @param location The location where the computation should be based on.
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
446 *
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
447 * @return an object that contains tuples of W/Q values at the specified
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
448 * location.
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
449 */
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
450 public static WQKms computeDischargeCurveData(
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
451 WstValueTable wst,
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
452 double location)
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
453 {
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
454 logger.info("WINFOArtifact.computeDischargeCurveData");
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
455
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
456 double[][] wqs = wst.interpolateWQ(location);
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
457
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
458 if (wqs == null) {
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
459 logger.error("Cannot compute discharge curve data.");
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
460 return null;
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
461 }
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
462
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
463 double[] ws = wqs[0];
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
464 double[] qs = wqs[1];
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
465
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
466 WQKms wqkms = new WQKms(ws.length);
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
467
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
468 for (int i = 0; i < ws.length; i++) {
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
469 wqkms.add(ws[i], qs[i], location);
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
470 }
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
471
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
472 return wqkms;
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
473 }
402
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
474
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
475
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
476 /**
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
477 * Returns the data computed by the discharge longitudinal section
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
478 * computation.
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
479 *
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
480 * @return an array of WQKms object - one object for each given Q value.
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
481 */
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
482 public WQKms[] getDischargeLongitudinalSectionData() {
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
483 logger.debug("WINFOArtifact.getDischargeLongitudinalSectionData");
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
484
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
485 River river = getRiver();
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
486 if (river == null) {
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
487 logger.error("No river selected.");
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
488 }
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
489
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
490 WstValueTable wst = WstValueTableFactory.getTable(river);
402
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
491 if (wst == null) {
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
492 logger.error("No Wst found for selected river.");
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
493 }
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
494
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
495 double[][] dist = getSplittedDistance();
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
496 int num = dist != null ? dist.length : 0;
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
497
450
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
498 double[][] allQs = new double[num][];
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
499 double[][] allWs = new double[num][];
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
500 WQKms[][] wqkms = new WQKms[num][];
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
501
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
502 boolean qSel = true;
402
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
503
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
504 for (int i = 0; i < num; i++) {
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
505 double[] kms = getKms(dist[i]);
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
506 if (kms == null) {
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
507 // XXX maybe we should cancel this operation here.
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
508 continue;
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
509 }
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
510
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
511 double[] qs = getQs(dist[i]);
450
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
512 allQs[i] = qs;
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
513
402
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
514 if (qs == null) {
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
515 logger.debug("Determine Q values based on a set of W values.");
450
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
516 qSel = false;
402
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
517
450
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
518 allWs[i] = getWs(dist[i]);
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
519 qs = getQsForWs(allWs[i]);
402
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
520 }
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
521
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
522 wqkms[i] = computeWaterlevelData(kms, qs, wst);
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
523 }
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
524
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
525 WQKms[] merged = WQKms.merge(wqkms);
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
526 int numMerged = merged.length;
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
527 WQKms[] computed = new WQKms[numMerged];
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
528
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
529 for (int i = 0; i < numMerged; i++) {
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
530 computed[i] = computeDischargeLongitudinalSectionData(merged[i]);
450
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
531
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
532 setDischargeLongitudinalSectionNames(
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
533 computed[i],
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
534 qSel ? allQs : allWs,
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
535 i,
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
536 qSel ? "Q" : "W");
402
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
537 }
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
538
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
539 // TODO Introduce a caching mechanism here!
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
540
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
541 return computed;
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
542 }
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
543
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
544
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
545 /**
450
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
546 * Sets the name for discharge longitudinal section curves where each WQKms
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
547 * in <i>r</i> represents a column.
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
548 *
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
549 * @param wqkms A longitudinal section curve.
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
550 * @param allValues The input values of the computations.
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
551 * @param col The requested column in the table of Ws or Qs.
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
552 * @param wq The WQ mode - can be one of "W" or "Q".
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
553 */
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
554 public static void setDischargeLongitudinalSectionNames(
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
555 WQKms wqkms,
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
556 double[][] allValues,
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
557 int col,
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
558 String wq)
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
559 {
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
560 logger.debug("WINFOArtifact.setDischargeLongitudinalSectionNames");
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
561
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
562 StringBuilder sb = new StringBuilder(" (");
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
563 boolean first = true;
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
564
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
565 int rows = allValues.length;
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
566
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
567 for (int i = 0; i < rows; i++) {
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
568 double[] values = allValues[i];
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
569
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
570 if (!first) {
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
571 sb.append("; ");
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
572 }
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
573
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
574 sb.append(Double.toString(values[col]));
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
575
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
576 first = false;
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
577 }
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
578
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
579 sb.append(")");
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
580
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
581 wqkms.setName(wq + " Benutzerdefiniert" + sb.toString());
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
582 }
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
583
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
584
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
585 /**
402
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
586 * Computes the data used for a discharge longitudinal section based on a
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
587 * given WQKms object. If there are backjumps while computing the data, a
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
588 * WQCKms object is returned, otherwise the incoming wqkms object.
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
589 *
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
590 * @param wqkms The WQKms object that contains W, Q and Kms.
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
591 *
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
592 * @return an instance of WQKms or WQCKms.
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
593 */
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
594 public static WQKms computeDischargeLongitudinalSectionData(WQKms wqkms) {
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
595 logger.info("WINFOArtifact.computeDischargeLongitudinalSectionData");
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
596
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
597 BackJumpCorrector bjc = new BackJumpCorrector();
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
598
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
599 bjc.doCorrection(wqkms.getKms(), wqkms.getWs());
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
600
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
601 if (bjc.hasBackJumps()) {
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
602 logger.info("Discharge longitudinal section has backjumps.");
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
603 return new WQCKms(
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
604 wqkms.getKms(),
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
605 wqkms.getQs(),
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
606 wqkms.getWs(),
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
607 bjc.getCorrected());
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
608 }
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
609 else {
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
610 logger.info("Discharge longitudinal section has no backjumps.");
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
611 return wqkms;
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
612 }
eb22ffe4d74c Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 393
diff changeset
613 }
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
614 }
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
615 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org