annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 2617:71086a3a1c5f

Issue 499. Added validation for 'W free'. flys-artifacts/trunk@4201 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 05 Apr 2012 08:51:53 +0000
parents 247f3e98a14b
children 3f24865082da
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
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
3 import de.intevation.artifactdatabase.ProtocolUtils;
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
4
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
5 import de.intevation.artifactdatabase.data.StateData;
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
7 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
8 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
9 import de.intevation.artifactdatabase.state.StateEngine;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
10
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
11 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
12
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
13 import de.intevation.artifacts.CallContext;
1157
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
14 import de.intevation.artifacts.Message;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
15
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
16 import de.intevation.artifacts.common.ArtifactNamespaceContext;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
17
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
18 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
19
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
20 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
21
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
22 import de.intevation.flys.artifacts.context.FLYSContext;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
23
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
24 import de.intevation.flys.artifacts.model.Calculation1;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
25 import de.intevation.flys.artifacts.model.Calculation2;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
26 import de.intevation.flys.artifacts.model.Calculation3;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
27 import de.intevation.flys.artifacts.model.Calculation4;
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
28 import de.intevation.flys.artifacts.model.Calculation5;
2215
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2194
diff changeset
29 import de.intevation.flys.artifacts.model.Calculation6;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
30 import de.intevation.flys.artifacts.model.Calculation;
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
31 import de.intevation.flys.artifacts.model.CalculationMessage;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
32 import de.intevation.flys.artifacts.model.CalculationResult;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
33 import de.intevation.flys.artifacts.model.DischargeTables;
1809
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
34 import de.intevation.flys.artifacts.model.FacetTypes;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
35 import de.intevation.flys.artifacts.model.MainValuesFactory;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
36 import de.intevation.flys.artifacts.model.Segment;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
37 import de.intevation.flys.artifacts.model.WQKms;
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
38 import de.intevation.flys.artifacts.model.WW;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
39 import de.intevation.flys.artifacts.model.WstValueTable;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
40 import de.intevation.flys.artifacts.model.WstValueTableFactory;
2126
d626ae185305 Use the fast cross section lines from backend now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2120
diff changeset
41
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
42 import de.intevation.flys.artifacts.states.DefaultState;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
43 import de.intevation.flys.artifacts.states.LocationDistanceSelect;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
44
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
45 import de.intevation.flys.geom.Lines;
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
46
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
47 import de.intevation.flys.model.FastCrossSectionLine;
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
48 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
49 import de.intevation.flys.model.River;
2418
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
50 import de.intevation.flys.model.DischargeTable;
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
51
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
52 import de.intevation.flys.utils.DoubleUtil;
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1055
diff changeset
53 import de.intevation.flys.utils.FLYSUtils;
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
54
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
55 import gnu.trove.TDoubleArrayList;
451
73bc64c4a7b0 Use new logic to calculate "W für ungleichwertige Abfluesse". Not working yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
56
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
57 import java.awt.geom.Point2D;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
58
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
59 import java.util.ArrayList;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
60 import java.util.Arrays;
2228
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2219
diff changeset
61 import java.util.Calendar;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
62 import java.util.Collections;
2228
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2219
diff changeset
63 import java.util.GregorianCalendar;
1157
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
64 import java.util.LinkedList;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
65 import java.util.List;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
66 import java.util.Map;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
67
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
68 import org.apache.log4j.Logger;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
69
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
70 import org.w3c.dom.Document;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
71 import org.w3c.dom.Element;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
72 import org.w3c.dom.Node;
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 /**
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 * The default WINFO artifact.
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 *
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 * @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
78 */
1809
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
79 public class WINFOArtifact
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
80 extends FLYSArtifact
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1975
diff changeset
81 implements FacetTypes, WaterLineArtifact {
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82
1029
3f3988bb6284 Picky Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 943
diff changeset
83 /** The logger for this class. */
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 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
85
1029
3f3988bb6284 Picky Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 943
diff changeset
86 /** The name of the artifact. */
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
87 public static final String ARTIFACT_NAME = "winfo";
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
88
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
89 /** XPath */
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
90 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
91
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
92 /** The default number of steps between the start end end of a selected Q
1115
eaf32c767bac Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1102
diff changeset
93 * range. */
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
94 public static final int DEFAULT_Q_STEPS = 30;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
95
1115
eaf32c767bac Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1102
diff changeset
96 /** The default step width between the start end end kilometer. */
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
97 public static final double DEFAULT_KM_STEPS = 0.1;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
98
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
99
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100 /**
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 * The default constructor.
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 */
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 public WINFOArtifact() {
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 }
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 /**
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 * 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
109 *
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 * @param data Some data.
128
206312c2aa76 I18N of strings for the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
111 * @param context The CallContext.
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 *
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 * @return the description of this artifact.
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 */
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 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
116 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
117
624
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 456
diff changeset
118 if (logger.isDebugEnabled()) {
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 456
diff changeset
119 dumpArtifact();
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 456
diff changeset
120 }
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 456
diff changeset
121
1777
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1771
diff changeset
122 FLYSContext flysContext = FLYSUtils.getFlysContext(context);
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
123
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
124 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
125 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
126
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
127 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
128 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
129
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
130 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
131 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
132
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
133 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
134 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
135 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
136 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
137 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
138
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
139 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
140 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
141
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
142 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
143
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
144 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
145 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
146 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
147
1145
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
148 appendBackgroundActivity(creator, root, context);
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
149
303
2d393c8bd38c Write the name of an artifact into the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 302
diff changeset
150 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
151 creator, "name",
2d393c8bd38c Write the name of an artifact into the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 302
diff changeset
152 new String[] { "value" },
2d393c8bd38c Write the name of an artifact into the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 302
diff changeset
153 new String[] { getName() });
2d393c8bd38c Write the name of an artifact into the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 302
diff changeset
154
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
155 Element ui = ProtocolUtils.createArtNode(
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
156 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
157
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
158 Element staticUI = ProtocolUtils.createArtNode(
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
159 creator, "static", null, null);
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
160
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
161 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
162 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
163 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
164
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
165 appendStaticUI(description, staticUI, context, identifier());
128
206312c2aa76 I18N of strings for the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
166
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
167 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
168 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
169 description,
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
170 root,
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
171 context,
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
172 identifier());
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
173
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
174 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
175 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
176 }
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
177
128
206312c2aa76 I18N of strings for the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
178 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
179
303
2d393c8bd38c Write the name of an artifact into the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 302
diff changeset
180 root.appendChild(name);
127
21d791e21aca Introduced a state to select the calculation mode.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 124
diff changeset
181 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
182 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
183
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
184 return description;
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 }
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
186
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
187
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
188 /**
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
189 * Returns the name of the concrete artifact.
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
190 *
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
191 * @return the name of the concrete artifact.
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
192 */
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
193 public String getName() {
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
194 return ARTIFACT_NAME;
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
195 }
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
196
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
197
1802
26d7077e42d2 Corrected CrossSection diagram/out to include one facet per computed waterlevel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1777
diff changeset
198 protected static void appendBackgroundActivity(
1145
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
199 ElementCreator cr,
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
200 Element root,
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
201 CallContext context
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
202 ) {
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
203 Element inBackground = cr.create("background-processing");
1157
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
204 root.appendChild(inBackground);
1145
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
205
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
206 cr.addAttr(
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
207 inBackground,
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
208 "value",
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
209 String.valueOf(context.isInBackground()),
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
210 true);
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
211
1157
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
212 LinkedList<Message> messages = context.getBackgroundMessages();
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
213
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
214 if (messages == null) {
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
215 return;
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
216 }
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
217
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
218 CalculationMessage message = (CalculationMessage) messages.getLast();
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
219 cr.addAttr(
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
220 inBackground,
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
221 "steps",
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
222 String.valueOf(message.getSteps()),
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
223 true);
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
224
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
225 cr.addAttr(
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
226 inBackground,
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
227 "currentStep",
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
228 String.valueOf(message.getCurrentStep()),
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
229 true);
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
230
a470b7c3b165 Write status messages and progress information of WSPLGEN Calculations into Artifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1155
diff changeset
231 inBackground.setTextContent(message.getMessage());
1145
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
232 }
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
233
b33a350d79db Append an attribute 'background-processing' (can be 'true' or 'false') to the WINFOArtifact's DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1142
diff changeset
234
1765
5d8b3880a553 Do not store association of states to facets, let artifacts keep facets in a pure list.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1762
diff changeset
235 /**
5d8b3880a553 Do not store association of states to facets, let artifacts keep facets in a pure list.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1762
diff changeset
236 * Append output mode nodes to a document.
5d8b3880a553 Do not store association of states to facets, let artifacts keep facets in a pure list.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1762
diff changeset
237 */
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
238 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
239 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
240 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
241 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
242 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
243 {
2606
619f6dfec901 #460 Fixed duplicated Outputs in DESCRIBE documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2600
diff changeset
244 List<Output> generated = getOutputs(context);
619f6dfec901 #460 Fixed duplicated Outputs in DESCRIBE documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2600
diff changeset
245 logger.debug("This Artifact has " + generated.size() + " Outputs.");
693
af393c5eb2c8 Write computed facets into artifacts describe document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 689
diff changeset
246
2606
619f6dfec901 #460 Fixed duplicated Outputs in DESCRIBE documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2600
diff changeset
247 ProtocolUtils.appendOutputModes(doc, outs, generated);
144
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
248 }
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
249
dde6904ba160 The DESCRIBE of the WINFO artifact contains the available output modes now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 134
diff changeset
250
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
251 /**
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
252 * 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
253 * 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
254 *
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
255 * @param doc The document.
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
256 * @param ui The root node.
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
257 * @param context The CallContext.
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
258 * @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
259 */
128
206312c2aa76 I18N of strings for the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
260 protected void appendStaticUI(
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
261 Document doc,
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
262 Node ui,
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
263 CallContext context,
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
264 String uuid)
128
206312c2aa76 I18N of strings for the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 127
diff changeset
265 {
661
fdc898a134a7 Use java.util.List instead of java.util.Vector. Removed superfluous imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 655
diff changeset
266 List<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
267
1777
a8aa343799a2 Extracet getFlysContext from FLYSArtifact to FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1771
diff changeset
268 FLYSContext flysContext = FLYSUtils.getFlysContext(context);
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
269 StateEngine engine = (StateEngine) flysContext.get(
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
270 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
271
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
272 for (String stateId: stateIds) {
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
273 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
274 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
275
624
929137ee8154 ISSUE-62 (part I/II) States are no longer filled with data - if a state needs user input, it needs to query the owner artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 456
diff changeset
276 ui.appendChild(state.describeStatic(this, doc, ui, context, uuid));
134
f3dfa188d8b2 Let the states describe the static ui part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 128
diff changeset
277 }
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
278 }
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
279
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
280
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
281 //
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
282 // 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
283 //
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
284
687
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
285 /**
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
286 * 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
287 *
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
288 * @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
289 */
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
290 public CalculationResult getWaterlevelData()
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
291 {
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
292 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
293
1102
7bd514eb4b2c Commit accidentally omitted result of refactoring (WINFO/FLYSUtils/getRiver).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
294 River river = FLYSUtils.getRiver(this);
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
295 if (river == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
296 return error(new WQKms[0], "no.river.selected");
362
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
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
299 double[] kms = getKms();
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
300 if (kms == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
301 return error(new WQKms[0], "no.kms.selected");
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
302 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
303
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
304 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
305 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
306 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
307
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
308 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
309 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
310 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
311 ws = getWs();
2165
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
312 double [][] qws = getQsForWs(ws);
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
313 if (qws == null || qws.length == 0) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
314 return error(new WQKms[0], "converting.ws.to.qs.failed");
735
db68806e6563 Fixed "W am Pegel" calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 723
diff changeset
315 }
2165
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
316 qs = qws[0];
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
317
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
318 if (qws[1] != null) { // If new ws where generated.
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
319 // TODO: Inform user!
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
320 ws = qws[1];
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
321 }
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
322 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
323
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
324 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
325 if (wst == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
326 return error(new WQKms[0], "no.wst.for.selected.river");
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
327 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
328
708
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 706
diff changeset
329
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1055
diff changeset
330 double [] range = FLYSUtils.getKmRange(this);
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
331 if (range == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
332 return error(new WQKms[0], "no.range.found");
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
333 }
736
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
334
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
335 double refKm;
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
336
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
337 if (isFreeQ() || isFreeW()) {
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
338 refKm = range[0];
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
339 logger.debug("'free' calculation (km " + refKm + ")");
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
340 }
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
341 else {
736
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
342 Gauge gauge = river.determineGaugeByPosition(range[0]);
708
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 706
diff changeset
343 if (gauge == null) {
736
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
344 return error(
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
345 new WQKms[0], "no.gauge.found.for.km");
708
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 706
diff changeset
346 }
736
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
347
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
348 refKm = gauge.getStation().doubleValue();
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
349
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
350 logger.debug(
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
351 "reference gauge: " + gauge.getName() + " (km " + refKm + ")");
708
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 706
diff changeset
352 }
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 706
diff changeset
353
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
354 return computeWaterlevelData(kms, qs, ws, wst, refKm);
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
355 }
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
356
1115
eaf32c767bac Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1102
diff changeset
357
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
358 /**
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
359 * 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
360 * in WstValueTable.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
361 *
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
362 * @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
363 * @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
364 * @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
365 *
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
366 * @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
367 */
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
368 public static CalculationResult computeWaterlevelData(
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
369 double [] kms,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
370 double [] qs,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
371 double [] ws,
635
acf3b49ec31f Take the flow direction into account.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 624
diff changeset
372 WstValueTable wst,
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
373 double refKm
635
acf3b49ec31f Take the flow direction into account.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 624
diff changeset
374 ) {
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
375 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
376
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
377 Calculation1 calc1 = new Calculation1(kms, qs, ws, refKm);
636
58276db49b16 Generate fields for w/q input depend on flow direction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 635
diff changeset
378
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
379 return calc1.calculate(wst);
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
380 }
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
381
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 /**
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 * 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
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
386 * @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
387 */
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
388 public CalculationResult getDurationCurveData() {
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
389 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
390
1102
7bd514eb4b2c Commit accidentally omitted result of refactoring (WINFO/FLYSUtils/getRiver).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
391 River r = FLYSUtils.getRiver(this);
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
392
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 if (r == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
394 return error(null, "no.river.selected");
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
395 }
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
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 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
398
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 if (g == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
400 return error(null, "no.gauge.selected");
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
401 }
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
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1055
diff changeset
403 double[] locations = FLYSUtils.getLocations(this);
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
404
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 if (locations == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
406 return error(null, "no.locations.selected");
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
407 }
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
408
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
409 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
410 if (wst == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
411 return error(null, "no.wst.for.river");
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
412 }
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
413
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
414 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
415 }
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
416
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
417
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
418 /**
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
419 * 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
420 *
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
421 * @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
422 * @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
423 *
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
424 * @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
425 */
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
426 public static CalculationResult computeDurationCurveData(
1974
cdeb31ef20a1 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1852
diff changeset
427 Gauge gauge,
cdeb31ef20a1 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1852
diff changeset
428 WstValueTable wst,
cdeb31ef20a1 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1852
diff changeset
429 double location)
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
430 {
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
431 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
432
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
433 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
434
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
435 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
436 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
437
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
438 Calculation3 calculation = new Calculation3(location, days, qs);
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
439
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
440 return calculation.calculate(wst);
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
441 }
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
442
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 /**
687
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
445 * Returns the data that is used to create discharge curves.
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
446 *
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
447 */
721
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
448 public CalculationResult getDischargeCurveData() {
687
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
449
1102
7bd514eb4b2c Commit accidentally omitted result of refactoring (WINFO/FLYSUtils/getRiver).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
450 River river = FLYSUtils.getRiver(this);
721
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
451 if (river == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
452 return error(new WQKms[0], "no.river.selected");
687
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
453 }
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
454
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1055
diff changeset
455 double [] distance = FLYSUtils.getKmRange(this);
687
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
456
721
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
457 if (distance == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
458 return error(new WQKms[0], "no.range.found");
687
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
459 }
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
460
721
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
461 List<Gauge> gauges = river.determineGauges(distance[0], distance[1]);
687
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
462
721
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
463 if (gauges.isEmpty()) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
464 return error(new WQKms[0], "no.gauge.selected");
721
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
465 }
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
466
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
467 String [] names = new String[gauges.size()];
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
468
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
469 for (int i = 0; i < names.length; ++i) {
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
470 names[i] = gauges.get(i).getName();
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
471 }
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
472
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
473 DischargeTables dt = new DischargeTables(river.getName(), names);
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
474
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
475 Map<String, double [][]> map = dt.getValues(100d);
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
476
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
477 ArrayList<WQKms> res = new ArrayList<WQKms>();
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
478
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
479 for (Gauge gauge: gauges) {
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
480 String name = gauge.getName();
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
481 double [][] values = map.get(name);
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
482 if (values == null) {
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
483 continue;
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
484 }
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
485 double [] kms = new double[values[0].length];
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
486 Arrays.fill(kms, gauge.getStation().doubleValue());
723
8900966ad945 "Abflusskurve am Pegel" looks correct again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 721
diff changeset
487 res.add(new WQKms(kms, values[0], values[1], name));
721
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
488 }
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
489
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
490 return new CalculationResult(
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
491 res.toArray(new WQKms[res.size()]),
7298d58a1f5a Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 714
diff changeset
492 new Calculation());
687
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
493 }
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
494
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
495
06689035024c Added a compute() method to WINFOArtifact which acts as a dispatcher for different computations. It triggers a calculation based on ComputeCallbacks that are generated by the current states.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 686
diff changeset
496 /**
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
497 * 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
498 *
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
499 * @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
500 */
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
501 public CalculationResult getComputedDischargeCurveData()
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
502 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
503 {
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
504 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
505
1102
7bd514eb4b2c Commit accidentally omitted result of refactoring (WINFO/FLYSUtils/getRiver).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
506 River r = FLYSUtils.getRiver(this);
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
507
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
508 if (r == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
509 return error(new WQKms[0], "no.river.selected");
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
510 }
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
511
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1055
diff changeset
512 double[] locations = FLYSUtils.getLocations(this);
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
513
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
514 if (locations == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
515 return error(new WQKms[0], "no.locations.selected");
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
516 }
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
517
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
518 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
519 if (wst == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
520 return error(new WQKms[0], "no.wst.for.river");
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
521 }
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
522
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
523 return computeDischargeCurveData(wst, locations[0]);
456
af1b64ec7250 The curve of a computed discharge curve has a human readable text now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 455
diff changeset
524 }
af1b64ec7250 The curve of a computed discharge curve has a human readable text now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 455
diff changeset
525
af1b64ec7250 The curve of a computed discharge curve has a human readable text now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 455
diff changeset
526
af1b64ec7250 The curve of a computed discharge curve has a human readable text now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 455
diff changeset
527 /**
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
528 * 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
529 *
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
530 * @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
531 * @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
532 *
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
533 * @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
534 * 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
535 */
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
536 public static CalculationResult computeDischargeCurveData(
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
537 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
538 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
539 {
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
540 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
541
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
542 Calculation2 calculation = new Calculation2(location);
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
543
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
544 return calculation.calculate(wst);
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
545 }
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
546
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
547 protected static final CalculationResult error(Object data, String msg) {
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
548 return new CalculationResult(data, new Calculation(msg));
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
549 }
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
550
1148
302461d5d071 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1145
diff changeset
551
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
552 /**
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
553 * 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
554 * 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
555 *
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
556 * @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
557 */
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
558 public CalculationResult getDischargeLongitudinalSectionData() {
451
73bc64c4a7b0 Use new logic to calculate "W für ungleichwertige Abfluesse". Not working yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
559
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
560 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
561
1102
7bd514eb4b2c Commit accidentally omitted result of refactoring (WINFO/FLYSUtils/getRiver).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
562 River river = FLYSUtils.getRiver(this);
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
563 if (river == null) {
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
564 logger.debug("No river selected.");
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
565 return error(new WQKms[0], "no.river.selected");
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
566 }
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
567
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
568 WstValueTable table = WstValueTableFactory.getTable(river);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
569 if (table == null) {
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
570 logger.debug("No wst found for selected river.");
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
571 return error(new WQKms[0], "no.wst.for.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
572 }
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
573
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
574 List<Segment> segments = getSegments();
637
f0c1250d1e7b Make "Berechnungsart 4" work independent of flow direction. Commented out back jump correction temporarily.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 636
diff changeset
575
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
576 if (segments == null) {
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
577 logger.debug("Cannot create segments.");
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
578 return error(new WQKms[0], "cannot.create.segments");
451
73bc64c4a7b0 Use new logic to calculate "W für ungleichwertige Abfluesse". Not working yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
579 }
450
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
580
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
581 double [] range = getFromToStep();
451
73bc64c4a7b0 Use new logic to calculate "W für ungleichwertige Abfluesse". Not working yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
582
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
583 if (range == null) {
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
584 logger.debug("Cannot figure out range.");
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
585 return error(new WQKms[0], "no.range.found");
451
73bc64c4a7b0 Use new logic to calculate "W für ungleichwertige Abfluesse". Not working yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
586 }
73bc64c4a7b0 Use new logic to calculate "W für ungleichwertige Abfluesse". Not working yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 450
diff changeset
587
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
588 Calculation4 calc4 = new Calculation4(segments, river, isQ());
455
7137ef65c17c Reintroduced titles for the "W for unausgeglichene Abfluesse".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 453
diff changeset
589
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
590 return calc4.calculate(table, range[0], range[1], range[2]);
450
c8bb38115290 Enabled the discharge longitudinal section to be exported as WST.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 449
diff changeset
591 }
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
592
2229
9dc81827b187 Add some fake 'input' data for reference curve. plot references curves from input km to input km +2.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2228
diff changeset
593
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
594 /**
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
595 * Returns the data that is computed by a reference curve computation.
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
596 *
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
597 * @return the data computed by a reference curve computation.
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
598 */
2326
c321b39b39ab 'Bezugslinienverfahren': Generate valid i18n names for datasets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2309
diff changeset
599 public CalculationResult getReferenceCurveData(CallContext context) {
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
600
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
601 Double startKm = getReferenceStartKm();
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
602
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
603 if (startKm == null) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
604 return error(new WW[0], "no.reference.start.km");
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
605 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
606
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
607 double [] endKms = getReferenceEndKms();
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
608
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
609 if (endKms == null || endKms.length == 0) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
610 return error(new WW[0], "no.reference.end.kms");
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
611 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
612
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
613 Calculation5 calc5 = new Calculation5(startKm, endKms);
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
614
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
615 River r = FLYSUtils.getRiver(this);
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
616 if (r == null) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
617 return error(new WW[0], "no.river.found");
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
618 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
619
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
620 WstValueTable wst = WstValueTableFactory.getTable(r);
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
621 if (wst == null) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
622 return error(new WW[0], "no.wst.for.river");
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
623 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
624
2257
86685feb5b1c Adjusted to name change in River class (hibernate fix).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2256
diff changeset
625 Map<Double, Double> kms2gaugeDatums = r.queryGaugeDatumsKMs();
2256
dd93a8e1377a First steps to serve the data in cm if we are are gauges only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2251
diff changeset
626
2326
c321b39b39ab 'Bezugslinienverfahren': Generate valid i18n names for datasets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2309
diff changeset
627 return calc5.calculate(wst, kms2gaugeDatums, context);
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
628 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
629
2229
9dc81827b187 Add some fake 'input' data for reference curve. plot references curves from input km to input km +2.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2228
diff changeset
630
2251
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
631 /** Get reference (start) km. */
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
632 protected Double getReferenceStartKm() {
2308
41a5c87c2761 Renamed data item names to allow translations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2257
diff changeset
633 StateData sd = getData("reference_startpoint");
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
634
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
635 if (sd == null) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
636 logger.warn("no reference start given.");
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
637 return null;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
638 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
639
2251
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
640 logger.debug("Reference start km given: " + sd.getValue());
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
641
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
642 String input = (String) sd.getValue();
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
643
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
644 if (input == null | (input = input.trim()).length() == 0) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
645 logger.warn("reference start string is empty.");
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
646 return null;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
647 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
648
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
649 try {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
650 return Double.valueOf(input);
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
651 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
652 catch (NumberFormatException nfe) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
653 logger.warn("reference start string is not numeric.");
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
654 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
655
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
656 return null;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
657 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
658
2251
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
659
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
660 protected double [] getReferenceEndKms() {
2308
41a5c87c2761 Renamed data item names to allow translations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2257
diff changeset
661 StateData sd = getData("reference_endpoint");
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
662
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
663 if (sd == null) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
664 logger.warn("no reference end given.");
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
665 return null;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
666 }
2251
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
667 else {
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
668 logger.debug("Reference end km : " + sd.getValue());
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
669 }
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
670
2251
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
671 String input = (String) sd.getValue();
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
672
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
673 if (input == null || (input = input.trim()).length() == 0) {
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
674 logger.warn("reference end string is empty.");
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
675 return null;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
676 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
677
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
678 TDoubleArrayList endKms = new TDoubleArrayList();
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
679
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
680 for (String part: input.split("\\s+")) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
681 try {
2309
92640472e563 Prevent duplicates in end kms for reference curve calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2308
diff changeset
682 double km = Double.parseDouble(part);
92640472e563 Prevent duplicates in end kms for reference curve calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2308
diff changeset
683 if (!endKms.contains(km)) {
92640472e563 Prevent duplicates in end kms for reference curve calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2308
diff changeset
684 endKms.add(km);
92640472e563 Prevent duplicates in end kms for reference curve calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2308
diff changeset
685 }
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
686 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
687 catch (NumberFormatException nfe) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
688 logger.warn("reference end string is not numeric.");
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
689 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
690 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
691
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
692 return endKms.toNativeArray();
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
693 }
1137
073c36bb94ed Minor cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1125
diff changeset
694
2215
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2194
diff changeset
695
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2194
diff changeset
696 public CalculationResult getHistoricalDischargeData() {
2219
4b6e9b377a84 Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
697 Gauge gauge = FLYSUtils.getReferenceGauge(this);
4b6e9b377a84 Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
698 String rawTimerange = getDataAsString("year_range");
4b6e9b377a84 Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
699 String rawValues = getDataAsString("historical_values");
4b6e9b377a84 Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
700 int mode = getDataAsInteger("historical_mode");
4b6e9b377a84 Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
701
2600
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
702 long[] timerange = FLYSUtils.longArrayFromString(rawTimerange);
2219
4b6e9b377a84 Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
703 double[] values = FLYSUtils.doubleArrayFromString(rawValues);
4b6e9b377a84 Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2215
diff changeset
704
2600
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
705 Calendar start = new GregorianCalendar();
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
706 start.setTimeInMillis(timerange[0]);
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
707 Calendar end = new GregorianCalendar();
3f1cc396d253 Issue 506.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2556
diff changeset
708 end.setTimeInMillis(timerange[1]);
2228
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2219
diff changeset
709
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2219
diff changeset
710 Calculation6 calc = new Calculation6(
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2219
diff changeset
711 mode,
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2219
diff changeset
712 new long[] { start.getTimeInMillis(), end.getTimeInMillis() },
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2219
diff changeset
713 values);
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2219
diff changeset
714
4db19a88bddb Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2219
diff changeset
715 return calc.calculate(gauge);
2215
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2194
diff changeset
716 }
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2194
diff changeset
717
ebbb18ed78c4 Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2194
diff changeset
718
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
719 public List<Segment> getSegments() {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
720 StateData wqValues = getData("wq_values");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
721 if (wqValues == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
722 logger.warn("no wq_values given");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
723 return Collections.emptyList();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
724 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
725 String input = (String)wqValues.getValue();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
726 if (input == null || (input = input.trim()).length() == 0) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
727 logger.warn("wq_values are empty");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
728 return Collections.emptyList();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
729 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
730 return Segment.parseSegments(input);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
731 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
732
1122
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
733
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
734 /**
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
735 * Get points of line describing the surface of water at cross section.
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
736 *
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
737 * @return an array holding coordinates of points of surface of water (
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
738 * in the form {{x1, x2} {y1, y2}} ).
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
739 */
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2107
diff changeset
740 public double [][] getWaterLines(int idx, FastCrossSectionLine csl) {
1975
b30e1710df1d Server-side of interactive cross-section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1974
diff changeset
741 logger.debug("getWaterLines(" + idx + ")");
b30e1710df1d Server-side of interactive cross-section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1974
diff changeset
742
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2107
diff changeset
743 List<Point2D> points = csl.getPoints();
1802
26d7077e42d2 Corrected CrossSection diagram/out to include one facet per computed waterlevel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1777
diff changeset
744
1139
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
745 // Need W at km
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
746 WQKms [] wqkms = (WQKms[]) getWaterlevelData().getData();
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
747 if (wqkms.length == 0) {
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
748 logger.error("No WQKms found.");
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
749 return Lines.createWaterLines(points, 0.0f);
1139
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
750 }
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
751
1802
26d7077e42d2 Corrected CrossSection diagram/out to include one facet per computed waterlevel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1777
diff changeset
752 if (wqkms.length < idx) {
26d7077e42d2 Corrected CrossSection diagram/out to include one facet per computed waterlevel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1777
diff changeset
753 logger.error("getWaterLines() requested index ("
26d7077e42d2 Corrected CrossSection diagram/out to include one facet per computed waterlevel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1777
diff changeset
754 + idx + " not found.");
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
755 }
1802
26d7077e42d2 Corrected CrossSection diagram/out to include one facet per computed waterlevel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1777
diff changeset
756
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
757 // Find W at km, linear naive approach.
1802
26d7077e42d2 Corrected CrossSection diagram/out to include one facet per computed waterlevel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1777
diff changeset
758 WQKms triple = wqkms[idx];
26d7077e42d2 Corrected CrossSection diagram/out to include one facet per computed waterlevel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1777
diff changeset
759
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
760 // Find index of km.
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2107
diff changeset
761 double wishKM = csl.getKm();
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
762 int old_idx = 0;
1139
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
763
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
764 if (triple.size() == 0) {
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
765 logger.warn("Calculation of waterline is empty.");
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
766 return Lines.createWaterLines(points, 0.0f);
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
767 }
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
768
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
769 // Linear seach in WQKms for closest km.
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
770 double old_dist_wish = Math.abs(wishKM - triple.getKm(0));
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
771 double last_w = triple.getW(0);
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
772
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
773 for (int i = 0, T = triple.size(); i < T; i++) {
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
774 double diff = Math.abs(wishKM - triple.getKm(i));
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
775 if (diff > old_dist_wish) {
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
776 break;
1139
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
777 }
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
778 last_w = triple.getW(i);
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
779 old_dist_wish = diff;
1139
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
780 }
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
781 return Lines.createWaterLines(points, last_w);
1122
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
782 }
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
783
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
784
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
785 /**
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
786 * Returns the Qs for a number of Ws. This method makes use of
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
787 * DischargeTables.getQForW().
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
788 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
789 * @param ws An array of W values.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
790 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
791 * @return an array of Q values.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
792 */
2165
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
793 public double [][] getQsForWs(double[] ws) {
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
794
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
795 if (ws == null) {
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
796 logger.error("getQsForWs: ws == null");
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
797 return null;
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
798 }
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
799
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
800 boolean debug = logger.isDebugEnabled();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
801
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
802 if (debug) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
803 logger.debug("FLYSArtifact.getQsForWs");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
804 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
805
1102
7bd514eb4b2c Commit accidentally omitted result of refactoring (WINFO/FLYSUtils/getRiver).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
806 River r = FLYSUtils.getRiver(this);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
807 if (r == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
808 logger.warn("no river found");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
809 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
810 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
811
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1055
diff changeset
812 double [] range = FLYSUtils.getKmRange(this);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
813 if (range == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
814 logger.warn("no ranges found");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
815 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
816 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
817
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
818 if (isFreeW()) {
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
819 logger.debug("Bezugslinienverfahren I: W auf freier Strecke");
2165
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
820 // The simple case of the "Bezugslinienverfahren"
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
821 // "W auf freier Strecke".
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
822 WstValueTable wst = WstValueTableFactory.getTable(r);
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
823 if (wst == null) {
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
824 logger.warn("no wst value table found");
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
825 return null;
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
826 }
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
827 double km = range[0];
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
828
2165
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
829 TDoubleArrayList outQs = new TDoubleArrayList(ws.length);
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
830 TDoubleArrayList outWs = new TDoubleArrayList(ws.length);
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
831
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
832 boolean generatedWs = false;
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
833
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
834 for (int i = 0; i < ws.length; ++i) {
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
835 double w = ws[i];
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
836 if (debug) {
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
837 logger.debug("getQsForWs: lookup Q for W: " + w);
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
838 }
2165
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
839 // There could bemore than one Q per W.
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
840 double [] qs = wst.findQsForW(km, w);
2165
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
841 for (int j = 0; j < qs.length; ++j) {
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
842 outWs.add(ws[i]);
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
843 outQs.add(qs[j]);
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
844 }
2165
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
845 generatedWs |= qs.length != 1;
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
846 }
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
847
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
848 if (debug) {
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
849 logger.debug("getQsForWs: number of Qs: " + outQs.size());
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
850 }
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
851
2165
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
852 return new double [][] {
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
853 outQs.toNativeArray(),
637dd38d0e2f Handle the case in "W auf freier Strecke" where more than ne Q is related to a W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2164
diff changeset
854 generatedWs ? outWs.toNativeArray() : null };
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
855 }
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
856
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
857 if (debug) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
858 logger.debug("range: " + Arrays.toString(range));
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
859 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
860
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
861 Gauge g = r.determineGaugeByPosition(range[0]);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
862 if (g == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
863 logger.warn("no gauge found for km: " + range[0]);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
864 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
865 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
866
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
867 if (debug) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
868 logger.debug("convert w->q with gauge '" + g.getName() + "'");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
869 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
870
2418
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
871 DischargeTable dt = g.fetchMasterDischargeTable();
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
872
2418
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
873 if (dt == null) {
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
874 logger.warn("No master discharge table found for gauge '"
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
875 + g.getName() + "'");
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
876 return null;
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
877 }
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
878
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
879 double [][] values = DischargeTables.loadDischargeTableValues(dt, 1);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
880
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
881 TDoubleArrayList wsOut = new TDoubleArrayList(ws.length);
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
882 TDoubleArrayList qsOut = new TDoubleArrayList(ws.length);
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
883
2418
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
884 boolean generatedWs = false;
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
885
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
886 for (int i = 0; i < ws.length; i++) {
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
887 if (Double.isNaN(ws[i])) {
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
888 logger.warn("W is NaN: ignored");
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
889 continue;
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
890 }
2418
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
891 double w = ws[i] / 100d;
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
892 double [] qs = DischargeTables.getQsForW(values, w);
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
893
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
894 if (qs.length == 0) {
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
895 logger.warn("No Qs found for W = " + ws[i]);
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
896 }
2418
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
897 else {
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
898 for (double q: qs) {
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
899 wsOut.add(ws[i]);
2607
247f3e98a14b Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2606
diff changeset
900 qsOut.add(q * 100d);
2418
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
901 }
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
902 }
2418
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
903 generatedWs |= qs.length != 1;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
904 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
905
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
906 return new double [][] {
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
907 qsOut.toNativeArray(),
2418
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
908 generatedWs ? wsOut.toNativeArray() : null
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
909 };
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
910 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
911
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
912
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
913 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
914 * Determines the selected mode of distance/range input.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
915 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
916 * @return true, if the range mode is selected otherwise false.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
917 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
918 public boolean isRange() {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
919 StateData mode = getData("ld_mode");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
920
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
921 if (mode == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
922 logger.warn("No mode location/range chosen. Defaults to range.");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
923 return true;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
924 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
925
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
926 String value = (String) mode.getValue();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
927
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
928 return value.equals("distance");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
929 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
930
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
931
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
932 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
933 * Returns the selected distance based on a given range (from, to).
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
934 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
935 * @param dFrom The StateData that contains the lower value.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
936 * @param dTo The StateData that contains the upper value.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
937 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
938 * @return the selected distance.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
939 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
940 protected double[] getDistanceByRange(StateData dFrom, StateData dTo) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
941 double from = Double.parseDouble((String) dFrom.getValue());
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
942 double to = Double.parseDouble((String) dTo.getValue());
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
943
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
944 return new double[] { from, to };
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
945 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
946
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
947
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
948 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
949 * Returns the selected Kms.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
950 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
951 * @param distance An 2dim array with [lower, upper] values.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
952 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
953 * @return the selected Kms.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
954 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
955 public double[] getKms(double[] distance) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
956 StateData dStep = getData("ld_step");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
957
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
958 if (dStep == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
959 logger.warn("No step width given. Cannot compute Kms.");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
960 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
961 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
962
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
963 double step = Double.parseDouble((String) dStep.getValue());
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
964
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
965 // transform step from 'm' into 'km'
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
966 step = step / 1000;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
967
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
968 if (step == 0d) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
969 step = DEFAULT_KM_STEPS;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
970 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
971
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
972 return DoubleUtil.explode(distance[0], distance[1], step);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
973 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
974
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
975
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
976 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
977 * Returns the selected Kms.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
978 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
979 * @return the selected kms.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
980 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
981 public double[] getKms() {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
982 if (isRange()) {
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1055
diff changeset
983 double[] distance = FLYSUtils.getKmRange(this);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
984 return getKms(distance);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
985
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
986 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
987 else {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
988 return LocationDistanceSelect.getLocations(this);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
989 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
990 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
991
1137
073c36bb94ed Minor cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1125
diff changeset
992
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
993 public double [] getFromToStep() {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
994 if (!isRange()) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
995 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
996 }
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1055
diff changeset
997 double [] fromTo = FLYSUtils.getKmRange(this);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
998
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
999 if (fromTo == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1000 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1001 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1002
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1003 StateData dStep = getData("ld_step");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1004 if (dStep == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1005 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1006 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1007
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1008 double [] result = new double[3];
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1009 result[0] = fromTo[0];
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1010 result[1] = fromTo[1];
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1011
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1012 try {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1013 String step = (String)dStep.getValue();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1014 result[2] = DoubleUtil.round(Double.parseDouble(step) / 1000d);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1015 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1016 catch (NumberFormatException nfe) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1017 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1018 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1019
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1020 return result;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1021 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1022
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1023
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1024 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1025 * Returns the gauge based on the current distance and river.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1026 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1027 * @return the gauge.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1028 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1029 public Gauge getGauge() {
2045
d13be39cfd1d #242 Added header with meta information into CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1981
diff changeset
1030 return FLYSUtils.getGauge(this);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1031 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1032
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1033
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1034 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1035 * Returns the gauges that match the selected kilometer range.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1036 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1037 * @return the gauges based on the selected kilometer range.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1038 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1039 public List<Gauge> getGauges() {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1040
1102
7bd514eb4b2c Commit accidentally omitted result of refactoring (WINFO/FLYSUtils/getRiver).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
1041 River river = FLYSUtils.getRiver(this);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1042 if (river == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1043 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1044 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1045
1102
7bd514eb4b2c Commit accidentally omitted result of refactoring (WINFO/FLYSUtils/getRiver).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1095
diff changeset
1046 double [] dist = FLYSUtils.getKmRange(this);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1047 if (dist == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1048 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1049 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1050
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1051 return river.determineGauges(dist[0], dist[1]);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1052 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1053
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1054
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1055 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1056 * This method returns the Q values.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1057 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1058 * @return the selected Q values or null, if no Q values are selected.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1059 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1060 public double[] getQs() {
2556
efb2038783f9 Renamed state data fields for W/Q input.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2552
diff changeset
1061 StateData dMode = getData("wq_isq");
efb2038783f9 Renamed state data fields for W/Q input.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2552
diff changeset
1062 StateData dSelection = getData("wq_isrange");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1063
2552
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1064 boolean isRange = dSelection != null
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1065 ? Boolean.valueOf((String)dSelection.getValue())
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1066 : false;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1067
2552
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1068 if (isQ()) {
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1069 if (!isRange) {
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1070 return getSingleWQValues();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1071 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1072 else {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1073 return getWQTriple();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1074 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1075 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1076 else {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1077 logger.warn("You try to get Qs, but W has been inserted.");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1078 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1079 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1080 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1081
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1082
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1083 public boolean isQ() {
2556
efb2038783f9 Renamed state data fields for W/Q input.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2552
diff changeset
1084 StateData mode = getData("wq_isq");
2552
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1085 String value = (mode != null) ? (String) mode.getValue() : null;
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1086 return value != null ? Boolean.valueOf(value) : false;
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1087 }
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1088
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1089 public boolean isW() {
2556
efb2038783f9 Renamed state data fields for W/Q input.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2552
diff changeset
1090 StateData mode = getData("wq_isq");
2552
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1091 String value = (mode != null) ? (String) mode.getValue() : null;
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1092 return value != null ? !Boolean.valueOf(value) : false;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1093 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1094
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
1095 public boolean isFreeW() {
2552
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1096 if(!isW()) {
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1097 return false;
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1098 }
2556
efb2038783f9 Renamed state data fields for W/Q input.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2552
diff changeset
1099 StateData mode = getData("wq_isfree");
2552
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1100 String value = (mode != null) ? (String) mode.getValue() : null;
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1101
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1102 return value != null ? Boolean.valueOf(value) : false;
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
1103 }
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
1104
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1105
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1106 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1107 * Returns true, if the parameter is set to compute data on a free range.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1108 * Otherwise it returns false, which tells the calculation that it is bound
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1109 * to a gauge.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1110 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1111 * @return true, if the calculation should compute on a free range otherwise
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1112 * false and the calculation is bound to a gauge.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1113 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1114 public boolean isFreeQ() {
2552
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1115 if(!isQ()) {
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1116 return false;
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1117 }
2556
efb2038783f9 Renamed state data fields for W/Q input.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2552
diff changeset
1118 StateData mode = getData("wq_isfree");
1115
eaf32c767bac Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1102
diff changeset
1119 String value = (mode != null) ? (String) mode.getValue() : null;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1120
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1121 logger.debug("isFreeQ: " + value);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1122
2164
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
1123 return value != null && Boolean.valueOf(value);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1124 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1125
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1126
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1127 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1128 * Returns the Q values based on a specified kilometer range.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1129 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1130 * @param range A 2dim array with lower and upper kilometer range.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1131 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1132 * @return an array of Q values.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1133 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1134 public double[] getQs(double[] range) {
2556
efb2038783f9 Renamed state data fields for W/Q input.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2552
diff changeset
1135 StateData dMode = getData("wq_isq");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1136
2552
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1137 if (isQ()) {
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1138 return getWQForDist(range);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1139 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1140
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1141 logger.warn("You try to get Qs, but Ws has been inserted.");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1142 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1143 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1144
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1145
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1146 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1147 * Returns the W values based on a specified kilometer range.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1148 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1149 * @param range A 2dim array with lower and upper kilometer range.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1150 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1151 * @return an array of W values.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1152 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1153 public double[] getWs(double[] range) {
2552
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1154 if (isW()) {
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1155 return getWQForDist(range);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1156 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1157
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1158 logger.warn("You try to get Ws, but Qs has been inserted.");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1159 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1160 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1161
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1162
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1163 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1164 * This method returns the W values.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1165 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1166 * @return the selected W values or null, if no W values are selected.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1167 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1168 public double[] getWs() {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1169 StateData dSingle = getData("wq_single");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1170
2552
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1171 if (isW()) {
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1172 if (dSingle != null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1173 return getSingleWQValues();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1174 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1175 else {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1176 return getWQTriple();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1177 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1178 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1179 else {
2552
c7dbe696286c Refactored the wq data fields.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2418
diff changeset
1180 logger.warn("You try to get Ws, but Q has been inserted.");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1181 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1182 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1183 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1184
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1185 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1186 * This method returns the given W or Q values for a specific range
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1187 * (inserted in the WQ input panel for discharge longitudinal sections).
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1188 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1189 * @param dist A 2dim array with lower und upper kilometer values.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1190 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1191 * @return an array of W or Q values.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1192 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1193 protected double[] getWQForDist(double[] dist) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1194 logger.debug("Search wq values for range: " + dist[0] + " - " + dist[1]);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1195 StateData data = getData("wq_values");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1196
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1197 if (data == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1198 logger.warn("Missing wq values!");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1199 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1200 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1201
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1202 String dataString = (String) data.getValue();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1203 String[] ranges = dataString.split(":");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1204
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1205 for (String range: ranges) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1206 String[] parts = range.split(";");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1207
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1208 double lower = Double.parseDouble(parts[0]);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1209 double upper = Double.parseDouble(parts[1]);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1210
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1211 if (lower <= dist[0] && upper >= dist[1]) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1212 String[] values = parts[2].split(",");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1213
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1214 int num = values.length;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1215 double[] res = new double[num];
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1216
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1217 for (int i = 0; i < num; i++) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1218 try {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1219 res[i] = Double.parseDouble(values[i]);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1220 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1221 catch (NumberFormatException nfe) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1222 logger.warn(nfe, nfe);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1223 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1224 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1225
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1226 return res;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1227 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1228 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1229
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1230 logger.warn("Specified range for WQ not found!");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1231
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1232 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1233 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1234
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1235
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1236 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1237 * This method returns an array of inserted WQ triples that consist of from,
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1238 * to and the step width.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1239 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1240 * @return an array of from, to and step width.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1241 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1242 protected double[] getWQTriple() {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1243 StateData dFrom = getData("wq_from");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1244 StateData dTo = getData("wq_to");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1245
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1246 if (dFrom == null || dTo == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1247 logger.warn("Missing start or end value for range.");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1248 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1249 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1250
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1251 double from = Double.parseDouble((String) dFrom.getValue());
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1252 double to = Double.parseDouble((String) dTo.getValue());
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1253
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1254 StateData dStep = getData("wq_step");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1255
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1256 if (dStep == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1257 logger.warn("No step width given. Cannot compute Qs.");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1258 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1259 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1260
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1261 double step = Double.parseDouble((String) dStep.getValue());
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1262
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1263 // if no width is given, the DEFAULT_Q_STEPS is used to compute the step
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1264 // width. Maybe, we should round the value to a number of digits.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1265 if (step == 0d) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1266 double diff = to - from;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1267 step = diff / DEFAULT_Q_STEPS;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1268 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1269
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1270 return DoubleUtil.explode(from, to, step);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1271 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1272
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1273
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1274 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1275 * Returns an array of inserted WQ double values stored as whitespace
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1276 * separated list.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1277 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1278 * @return an array of W or Q values.
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1279 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1280 protected double[] getSingleWQValues() {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1281 StateData dSingle = getData("wq_single");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1282
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1283 if (dSingle == null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1284 logger.warn("Cannot determine single WQ values. No data given.");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1285 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1286 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1287
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1288 String tmp = (String) dSingle.getValue();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1289 String[] strValues = tmp.split(" ");
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1290
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1291 TDoubleArrayList values = new TDoubleArrayList();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1292
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1293 for (String strValue: strValues) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1294 try {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1295 values.add(Double.parseDouble(strValue));
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1296 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1297 catch (NumberFormatException nfe) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1298 logger.warn(nfe, nfe);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1299 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1300 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1301
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1302 values.sort();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1303
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1304 return values.toNativeArray();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1305 }
1762
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1306
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1307
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1308 /**
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1309 * Determines Facets initial disposition regarding activity (think of
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1310 * selection in Client ThemeList GUI). This will be checked one time
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1311 * when the facet enters a collections describe document.
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1312 *
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1313 * @param facetName name of the facet.
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1314 * @param index index of the facet.
1809
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1315 * @return 0 if not active
1762
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1316 */
1809
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1317 @Override
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1318 public int getInitialFacetActivity(String outputName, String facetName, int index) {
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1319 String [] inactives = new String[] {
1852
feef1121e800 Let Q Duration Curves enter life inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1809
diff changeset
1320 LONGITUDINAL_Q,
feef1121e800 Let Q Duration Curves enter life inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1809
diff changeset
1321 DURATION_Q
feef1121e800 Let Q Duration Curves enter life inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1809
diff changeset
1322 };
1809
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1323
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1324 logger.debug("WINFOArtifact.active?: "
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1325 + outputName
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1326 + "/"
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1327 + facetName);
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1328
1852
feef1121e800 Let Q Duration Curves enter life inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1809
diff changeset
1329 if (facetName.equals(COMPUTED_DISCHARGE_MAINVALUES_Q) ||
1809
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1330 facetName.equals(COMPUTED_DISCHARGE_MAINVALUES_W)
1852
feef1121e800 Let Q Duration Curves enter life inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1809
diff changeset
1331 && outputName.equals("computed_discharge_curve"))
1809
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1332 {
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1333 return 0;
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1334 }
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1803
diff changeset
1335 return Arrays.asList(inactives).contains(facetName)
1762
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1336 ? 0
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1337 : 1;
c85a84d60f68 In LongitudinalSection-Diagram, Qs enter inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1651
diff changeset
1338 }
2617
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2607
diff changeset
1339
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2607
diff changeset
1340
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2607
diff changeset
1341 /**
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2607
diff changeset
1342 * Returns the WstValueTable.
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2607
diff changeset
1343 */
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2607
diff changeset
1344 public WstValueTable getWstValueTable() {
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2607
diff changeset
1345 River r = FLYSUtils.getRiver(this);
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2607
diff changeset
1346 return WstValueTableFactory.getTable(r);
71086a3a1c5f Issue 499.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2607
diff changeset
1347 }
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1348 }
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1349 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org