annotate artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java @ 9130:f61bc0c63188

WQSelect can now handle distance-only data
author gernotbelger
date Wed, 06 Jun 2018 14:16:28 +0200
parents e3519c3e7a0a
children 3f49835a00c3
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5848
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5848
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5848
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5919
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5848
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5919
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5848
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5848
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
9 package org.dive4elements.river.artifacts;
3233
7e5460d08eb0 WINFOArtifact: minor code improvement when lookup if facet should be initially active.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3227
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
11 import org.dive4elements.artifactdatabase.data.StateData;
4812
65bfb6faa538 Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4652
diff changeset
12
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
13 import org.dive4elements.artifactdatabase.state.Facet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
14 import org.dive4elements.artifactdatabase.state.FacetActivity;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
15
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
16 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
17 import org.dive4elements.artifacts.CallContext;
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
18
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
19 import org.dive4elements.artifacts.common.utils.StringUtils;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
20
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
21 import org.dive4elements.river.artifacts.access.Calculation4Access;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
22 import org.dive4elements.river.artifacts.access.RangeAccess;
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
23 import org.dive4elements.river.artifacts.access.RiverAccess;
8914
e3519c3e7a0a Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents: 8856
diff changeset
24 import org.dive4elements.river.artifacts.access.ComputationRangeAccess;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
25 import org.dive4elements.river.artifacts.geom.Lines;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
26
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
27 import org.dive4elements.river.artifacts.model.Calculation1;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
28 import org.dive4elements.river.artifacts.model.Calculation2;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
29 import org.dive4elements.river.artifacts.model.Calculation3;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
30 import org.dive4elements.river.artifacts.model.Calculation4;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
31 import org.dive4elements.river.artifacts.model.Calculation5;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
32 import org.dive4elements.river.artifacts.model.Calculation;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
33 import org.dive4elements.river.artifacts.model.CalculationResult;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
34 import org.dive4elements.river.artifacts.model.DischargeTables;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
35 import org.dive4elements.river.artifacts.model.FacetTypes;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
36 import org.dive4elements.river.artifacts.model.WQCKms;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
37 import org.dive4elements.river.artifacts.model.WQKms;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
38 import org.dive4elements.river.artifacts.model.WW;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
39 import org.dive4elements.river.artifacts.model.WstValueTable;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
40 import org.dive4elements.river.artifacts.model.WstValueTableFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
41
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
42 import org.dive4elements.river.artifacts.model.extreme.ExtremeResult;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
43
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
44 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
45
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
46 import org.dive4elements.river.model.DischargeTable;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
47 import org.dive4elements.river.model.FastCrossSectionLine;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
48 import org.dive4elements.river.model.Gauge;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
49 import org.dive4elements.river.model.River;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
50
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5786
diff changeset
51 import org.dive4elements.river.utils.DoubleUtil;
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
52 import org.dive4elements.river.utils.RiverUtils;
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
53
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
54 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
55
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
56 import java.awt.geom.Point2D;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
57
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
58 import java.util.Arrays;
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.List;
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.Map;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
61
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
62 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
63
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2726
diff changeset
64
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 /**
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 * The default WINFO artifact.
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 *
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 * @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
69 */
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
70 public class WINFOArtifact
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
71 extends D4EArtifact
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1975
diff changeset
72 implements FacetTypes, WaterLineArtifact {
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
74 /** The log for this class. */
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
75 private static Logger log = Logger.getLogger(WINFOArtifact.class);
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76
1029
3f3988bb6284 Picky Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 943
diff changeset
77 /** The name of the artifact. */
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
78 public static final String ARTIFACT_NAME = "winfo";
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
79
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
80 /** XPath */
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8758
diff changeset
81 public static final String XPATH_STATIC_UI =
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8758
diff changeset
82 "/art:result/art:ui/art:static";
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
83
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
84 /** 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
85 * range. */
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
86 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
87
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
88 private static final String [] INACTIVES = new String[] {
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
89 LONGITUDINAL_Q,
5400
acc34bf0d5b2 WINFOArtifact: Setting facetactivity for historical discharge, main values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4861
diff changeset
90 DURATION_Q,
5848
410a578cfc47 issue949: Have W facets active, Q inactive.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5838
diff changeset
91 STATIC_WQKMS_Q
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
92 };
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
93
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
94 static {
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
95 // TODO: Move to configuration.
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
96 FacetActivity.Registry.getInstance().register(
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
97 ARTIFACT_NAME,
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
98 new FacetActivity() {
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
99 @Override
3558
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
100 public Boolean isInitialActive(
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
101 Artifact artifact,
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
102 Facet facet,
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
103 String outputName
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
104 ) {
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
105 String fname = facet.getName();
8331
27d42c9ee367 Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents: 8202
diff changeset
106 if ((fname.equals(MAINVALUES_Q)
4181
e1f81795401f Let MAINVALUES enter life in inactive state in WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3892
diff changeset
107 || fname.equals(MAINVALUES_W))
e1f81795401f Let MAINVALUES enter life in inactive state in WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3892
diff changeset
108 && outputName.equals("computed_discharge_curve"))
e1f81795401f Let MAINVALUES enter life in inactive state in WINFOArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3892
diff changeset
109 {
3558
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
110 return Boolean.FALSE;
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
111 }
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
112 return !StringUtils.contains(fname, INACTIVES);
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
113 }
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
114 });
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3449
diff changeset
115 }
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
116
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 /**
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 * The default constructor.
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 */
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 public WINFOArtifact() {
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 }
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
124
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
125 /**
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
126 * Returns the name of the concrete artifact.
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
127 *
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
128 * @return the name of the concrete artifact.
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
129 */
3193
2f922be407ea Moved common code of the *Artifacts into FLYSArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3124
diff changeset
130 @Override
121
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
131 public String getName() {
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
132 return ARTIFACT_NAME;
e0ded17a4846 Implemented the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 119
diff changeset
133 }
124
b7a9557957d1 Appende the static data to the static node of the DESCRIBE document.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 121
diff changeset
134
2624
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
135 protected static boolean reportGeneratedWs(
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
136 Calculation report,
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
137 double [] ws
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
138 ) {
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
139 if (ws == null || ws.length < 2) {
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
140 return false;
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
141 }
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
142
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
143 double lastW = ws[0];
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
144 boolean alreadyReported = false;
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
145
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
146 for (int i = 1; i < ws.length; ++i) {
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
147 if (Math.abs(lastW - ws[i]) < 1e-5) {
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
148 if (!alreadyReported) {
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
149 alreadyReported = true;
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
150 report.addProblem("more.than.one.q.for.w", ws[i]);
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
151 }
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
152 }
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
153 else {
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
154 alreadyReported = false;
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
155 }
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
156 lastW = ws[i];
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
157 }
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
158
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
159 return true;
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
160 }
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
161
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
162
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
163 //
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
164 // 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
165 //
4479
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
166 //
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
167 /**
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
168 * Returns the data that is computed by a waterlevel computation.
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
169 *
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
170 * @return an array of data triples that consist of W, Q and Kms.
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
171 */
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
172 public CalculationResult getWaterlevelData() {
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
173 return this.getWaterlevelData(null);
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
174 }
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
175
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
176 private CalculationResult getDischargeLongitudinalSectionData() {
8565
ea17665c5aad Replace offensive comment by a more constructive note.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8562
diff changeset
177 // TODO: This caluclation should be cached as it is quite expensive.
4812
65bfb6faa538 Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4652
diff changeset
178 return new Calculation4(new Calculation4Access(this)).calculate();
65bfb6faa538 Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4652
diff changeset
179 }
65bfb6faa538 Bring Access pattern to "W fuer ungleichwertige Abflusslaengsschnitte".
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4652
diff changeset
180
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
181 /**
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
182 * 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
183 *
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
184 * @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
185 */
4478
6153c50f78cf WaterLineArtifact: Added callcontext-parameter to interfaces getWaterLine.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4181
diff changeset
186 public CalculationResult getWaterlevelData(CallContext context)
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
187 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
188 log.debug("WINFOArtifact.getWaterlevelData");
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
189
4479
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
190 String calculationMode = getDataAsString("calculation_mode");
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
191
6619
075c00b767d7 issue1399: WINFOArtifact: Compute difference also if part of difference building oneselve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6326
diff changeset
192 // If this WINFO-Artifact has a calculation trait.
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
193 if (calculationMode != null)
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
194 {
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
195 if (calculationMode.equals("calc.discharge.longitudinal.section"))
6619
075c00b767d7 issue1399: WINFOArtifact: Compute difference also if part of difference building oneselve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6326
diff changeset
196 return getDischargeLongitudinalSectionData();
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
197
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
198 if (calculationMode.equals("calc.extreme.curve"))
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
199 return (CalculationResult)this.compute(context, ComputeType.ADVANCE, false);
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
200
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
201 if (calculationMode.equals("calc.w.differences"))
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
202 return (CalculationResult)this.compute(context, ComputeType.ADVANCE, true);
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
203
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
204 log.warn("Unhandled calculation_mode " + calculationMode);
4479
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
205 }
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
206
6619
075c00b767d7 issue1399: WINFOArtifact: Compute difference also if part of difference building oneselve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6326
diff changeset
207 // Otherwise get it from parameterization.
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
208 // TODO: wrong comment: now always a waterlevle computation is executed; actually there is a calc_mode for that, why dont check?
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
209 return computeWaterlevelData();
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
210 }
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
211
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
212 /** Execu5tes the calculation of 'waterlevel', fetches all input data from this artifact */
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
213 private CalculationResult computeWaterlevelData() {
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
214 final double[] kms = new ComputationRangeAccess(this).getKms();
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
215 if (kms == null)
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
216 return error(new WQKms[0], "no.kms.selected");
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
217
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
218 return computeWaterlevelData(kms);
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
219 }
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
220
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
221 /**
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
222 * Execu5tes the calculation of 'waterlevel'.
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
223 * Allows to override the stations for which the calculation is done. All other inputs are fetched from this artifact.
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
224 */
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
225 public final CalculationResult computeWaterlevelData(final double kms[]) {
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
226
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
227 final River river = new RiverAccess(this).getRiver();
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
228 if (river == null)
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
229 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
230
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
231 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
232 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
233
2624
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
234 Calculation report = new Calculation();
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
235
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
236 if (qs == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
237 log.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
238 ws = getWs();
8704
93a31cfb18c0 (issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents: 8565
diff changeset
239 double [][] qws = getQsForWs(ws, report);
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
240 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
241 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
242 }
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
243 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
244
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2765
diff changeset
245 if (reportGeneratedWs(report, qws[1])) {
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
246 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
247 }
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
248 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
249
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
250 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
251 if (wst == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
252 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
253 }
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
254
6101
a0078e5e3b39 Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
255 RangeAccess rangeAccess = new RangeAccess(this);
4861
aae2b7492c1e WINFOArtifact: Updated to use RangeAccess instead of FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4846
diff changeset
256 double [] range = rangeAccess.getKmRange();
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
257 if (range == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
258 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
259 }
736
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
260
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
261 double refKm;
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
262
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
263 if (isFreeQ() || isFreeW()) {
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
264 refKm = range[0];
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
265 log.debug("'free' calculation (km " + refKm + ")");
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
266 }
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
267 else {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8758
diff changeset
268 Gauge gauge = river.determineRefGauge(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8758
diff changeset
269 range, rangeAccess.isRange());
8728
f51b9305d338 (issue1801) Reference gauge for waterlevel calculation depends on direction of calculation or flow direction.
Tom Gottfried <tom@intevation.de>
parents: 8704
diff changeset
270
708
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 706
diff changeset
271 if (gauge == null) {
736
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
272 return error(
5786
470460bfb5fc issue1289: Show km station with certain error message.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5400
diff changeset
273 new WQKms[0], "no.gauge.found.for.km", range[0]);
708
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 706
diff changeset
274 }
736
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
275
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
276 refKm = gauge.getStation().doubleValue();
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
277
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
278 log.debug(
736
d9d9f67af984 Fix for flys/issue86
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 735
diff changeset
279 "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
280 }
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 706
diff changeset
281
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
282 return computeWaterlevelData(kms, qs, ws, wst, refKm, report);
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
283 }
5606ba4139e0 WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 443
diff changeset
284
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
285 /**
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
286 * 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
287 * in WstValueTable.
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
288 *
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
289 * @param kms The kilometer values.
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3233
diff changeset
290 * @param qs The discharge values.
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
291 * @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
292 *
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
293 * @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
294 */
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
295 private static CalculationResult computeWaterlevelData(
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
296 double [] kms,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
297 double [] qs,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
298 double [] ws,
635
acf3b49ec31f Take the flow direction into account.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 624
diff changeset
299 WstValueTable wst,
2624
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
300 double refKm,
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
301 Calculation report
635
acf3b49ec31f Take the flow direction into account.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 624
diff changeset
302 ) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
303 log.info("WINFOArtifact.computeWaterlevelData");
362
d79a51fc4f1d Added necessary methods to start the computation of waterlevel data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 355
diff changeset
304
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 736
diff changeset
305 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
306
2624
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
307 if (report != null) {
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
308 calc1.addProblems(report);
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
309 }
3f24865082da Generate error message when more than one Q is found for given Q in "W auf freier Strecke".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2617
diff changeset
310
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
311 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
312 }
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
313
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
314
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
315 /**
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
316 * 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
317 *
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
318 * @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
319 */
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
320 public CalculationResult getDurationCurveData() {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
321 log.debug("WINFOArtifact.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
322
8758
d4caab3fedde A duration curve is always calculated for a single location.
Tom Gottfried <tom@intevation.de>
parents: 8757
diff changeset
323 RangeAccess rangeAccess = new RangeAccess(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
324
8758
d4caab3fedde A duration curve is always calculated for a single location.
Tom Gottfried <tom@intevation.de>
parents: 8757
diff changeset
325 River r = rangeAccess.getRiver();
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
326 if (r == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
327 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
328 }
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
329
8758
d4caab3fedde A duration curve is always calculated for a single location.
Tom Gottfried <tom@intevation.de>
parents: 8757
diff changeset
330 double[] locations = rangeAccess.getLocations();
d4caab3fedde A duration curve is always calculated for a single location.
Tom Gottfried <tom@intevation.de>
parents: 8757
diff changeset
331 if (locations == null) {
d4caab3fedde A duration curve is always calculated for a single location.
Tom Gottfried <tom@intevation.de>
parents: 8757
diff changeset
332 return error(null, "no.locations.selected");
d4caab3fedde A duration curve is always calculated for a single location.
Tom Gottfried <tom@intevation.de>
parents: 8757
diff changeset
333 }
385
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
334
8758
d4caab3fedde A duration curve is always calculated for a single location.
Tom Gottfried <tom@intevation.de>
parents: 8757
diff changeset
335 Gauge g = r.determineGaugeByPosition(locations[0]);
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
336 if (g == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
337 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
338 }
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
339
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
340 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
341 if (wst == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
342 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
343 }
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
344
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
345 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
346 }
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
347
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
348
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
349 /**
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
350 * 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
351 *
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
352 * @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
353 * @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
354 *
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
355 * @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
356 */
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
357 private static CalculationResult computeDurationCurveData(
1974
cdeb31ef20a1 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1852
diff changeset
358 Gauge gauge,
cdeb31ef20a1 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1852
diff changeset
359 WstValueTable wst,
cdeb31ef20a1 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1852
diff changeset
360 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
361 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
362 log.info("WINFOArtifact.computeDurationCurveData");
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
363
3647
421d1b0576b8 Removed deprecated method.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3558
diff changeset
364 Object[] obj = gauge.fetchDurationCurveData();
385
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
365
478940d06876 Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 380
diff changeset
366 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
367 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
368
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
369 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
370
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
371 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
372 }
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
373
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
374
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
375 /**
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
376 * 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
377 *
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
378 * @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
379 */
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
380 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
381 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
382 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
383 log.debug("WINFOArtifact.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
384
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
385 River r = RiverUtils.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
386
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
387 if (r == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
388 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
389 }
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
390
6101
a0078e5e3b39 Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
391 RangeAccess rangeAccess = new RangeAccess(this);
4846
298d540f7b70 WINFOArtifact: Use RangeAccess.getLocations instead of FLYSUtils.getLocations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4812
diff changeset
392 double[] locations = rangeAccess.getLocations();
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
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
394 if (locations == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
395 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
396 }
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
397
443
5d65fe4c08d5 Separated the WST table loading logic from the calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 402
diff changeset
398 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
399 if (wst == null) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2165
diff changeset
400 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
401 }
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
402
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
403 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
404 }
af1b64ec7250 The curve of a computed discharge curve has a human readable text now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 455
diff changeset
405
af1b64ec7250 The curve of a computed discharge curve has a human readable text now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 455
diff changeset
406
af1b64ec7250 The curve of a computed discharge curve has a human readable text now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 455
diff changeset
407 /**
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
408 * 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
409 *
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3233
diff changeset
410 * @param wst The WstValueTable that is used for the interpolation (river-
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3233
diff changeset
411 * bound).
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
412 * @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
413 *
befedd7629d5 Enabled the WINFO artifact to compute the data for discharge curves (computed) - ComputedDischargeCurveGenerator uses those values now to create the chart.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
414 * @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
415 * 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
416 */
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
417 private 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
418 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
419 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
420 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
421 log.info("WINFOArtifact.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
422
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 661
diff changeset
423 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
424
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
425 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
426 }
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
427
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3233
diff changeset
428
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3233
diff changeset
429 /** Create CalculationResult with data and message. */
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
430 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
431 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
432 }
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
433
5786
470460bfb5fc issue1289: Show km station with certain error message.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5400
diff changeset
434 /** Create CalculationResult with data and message with args. */
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8758
diff changeset
435 protected static final CalculationResult error(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8758
diff changeset
436 Object data,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8758
diff changeset
437 String msg,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8758
diff changeset
438 Object ... args
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8758
diff changeset
439 ) {
5786
470460bfb5fc issue1289: Show km station with certain error message.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5400
diff changeset
440 return new CalculationResult(data, new Calculation(msg, args));
470460bfb5fc issue1289: Show km station with certain error message.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5400
diff changeset
441 }
470460bfb5fc issue1289: Show km station with certain error message.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5400
diff changeset
442
1148
302461d5d071 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1145
diff changeset
443
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
444 /**
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
445 * 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
446 *
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
447 * @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
448 */
2326
c321b39b39ab 'Bezugslinienverfahren': Generate valid i18n names for datasets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2309
diff changeset
449 public CalculationResult getReferenceCurveData(CallContext context) {
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
450
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
451 Double startKm = getReferenceStartKm();
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
452
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
453 if (startKm == null) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
454 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
455 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
456
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
457 double [] endKms = getReferenceEndKms();
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
458
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
459 if (endKms == null || endKms.length == 0) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
460 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
461 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
462
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
463 Calculation5 calc5 = new Calculation5(startKm, endKms);
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
464
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
465 River r = RiverUtils.getRiver(this);
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
466 if (r == null) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
467 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
468 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
469
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
470 WstValueTable wst = WstValueTableFactory.getTable(r);
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
471 if (wst == null) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
472 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
473 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
474
2257
86685feb5b1c Adjusted to name change in River class (hibernate fix).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2256
diff changeset
475 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
476
2326
c321b39b39ab 'Bezugslinienverfahren': Generate valid i18n names for datasets.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2309
diff changeset
477 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
478 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
479
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
480
2251
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
481 /** Get reference (start) km. */
2754
832f7bd45f9e Made data accessors for reference curve parameter public.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2733
diff changeset
482 public Double getReferenceStartKm() {
2308
41a5c87c2761 Renamed data item names to allow translations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2257
diff changeset
483 StateData sd = getData("reference_startpoint");
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
484
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
485 if (sd == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
486 log.warn("no reference start given.");
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
487 return null;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
488 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
489
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
490 log.debug("Reference start km given: " + sd.getValue());
2251
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
491
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
492 String input = (String) sd.getValue();
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
493
2726
f53173a8736b Fixings state access: Added more debug putput
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2652
diff changeset
494 if (input == null || (input = input.trim()).length() == 0) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
495 log.warn("reference start string is empty.");
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
496 return null;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
497 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
498
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
499 try {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
500 return Double.valueOf(input);
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
501 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
502 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
503 log.warn("reference start string is not numeric.");
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
504 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
505
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
506 return null;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
507 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
508
2251
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
509
2754
832f7bd45f9e Made data accessors for reference curve parameter public.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2733
diff changeset
510 /**
832f7bd45f9e Made data accessors for reference curve parameter public.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2733
diff changeset
511 * Get end kms for reference curve (null if none).
832f7bd45f9e Made data accessors for reference curve parameter public.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2733
diff changeset
512 */
832f7bd45f9e Made data accessors for reference curve parameter public.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2733
diff changeset
513 public double [] getReferenceEndKms() {
2308
41a5c87c2761 Renamed data item names to allow translations.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2257
diff changeset
514 StateData sd = getData("reference_endpoint");
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
515
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
516 if (sd == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
517 log.warn("no reference end given.");
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
518 return null;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
519 }
2251
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
520 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
521 log.debug("Reference end km : " + sd.getValue());
2251
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
522 }
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
523
2251
c9c788eea200 Improved reference curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2229
diff changeset
524 String input = (String) sd.getValue();
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
525
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
526 if (input == null || (input = input.trim()).length() == 0) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
527 log.warn("reference end string is empty.");
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
528 return null;
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
529 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
530
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
531 TDoubleArrayList endKms = new TDoubleArrayList();
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
532
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
533 for (String part: input.split("\\s+")) {
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
534 try {
2309
92640472e563 Prevent duplicates in end kms for reference curve calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2308
diff changeset
535 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
536 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
537 endKms.add(km);
92640472e563 Prevent duplicates in end kms for reference curve calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2308
diff changeset
538 }
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
539 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
540 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
541 log.warn("reference end string is not numeric.");
2194
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
542 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
543 }
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
544
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
545 return endKms.toNativeArray();
05984871520f Call the "Bezugslinienverfahren" from the WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2166
diff changeset
546 }
1137
073c36bb94ed Minor cosmetics
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1125
diff changeset
547
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
548
1122
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
549 /**
3124
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
550 * Get corrected waterline against surface/profile.
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
551 */
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
552 private Lines.LineData waterLineC(int idx, FastCrossSectionLine csl) {
3124
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
553 List<Point2D> points = csl.getPoints();
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
554
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
555 WQKms[] wqckms = (WQKms[])
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
556 getDischargeLongitudinalSectionData().getData();
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
557
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
558 // Find index of km.
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
559 double wishKM = csl.getKm();
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
560
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
561 // Find W/C at km, linear naive approach.
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
562 WQCKms triple = (WQCKms) wqckms[idx-1];
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
563
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
564 if (triple.size() == 0) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
565 log.warn("Calculation of c/waterline is empty.");
3124
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
566 return Lines.createWaterLines(points, 0.0f);
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
567 }
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
568
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
569 // Linear seach in WQKms for closest km.
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
570 double old_dist_wish = Math.abs(wishKM - triple.getKm(0));
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
571 double last_c = triple.getC(0);
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
572
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
573 for (int i = 0, T = triple.size(); i < T; i++) {
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
574 double diff = Math.abs(wishKM - triple.getKm(i));
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
575 if (diff > old_dist_wish) {
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
576 break;
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
577 }
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
578 last_c = triple.getC(i);
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
579 old_dist_wish = diff;
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
580 }
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
581
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
582 return Lines.createWaterLines(points, last_c);
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
583 }
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
584
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
585
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
586 /**
1122
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
587 * 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
588 *
3123
edf629d43f05 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
589 * @param idx Index for getWaterlevelData.
edf629d43f05 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
590 * @param csl The profile/surface to fill with water.
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3233
diff changeset
591 * @param nextIgnored Ignored in this implementation of WaterLineArtifact.
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3233
diff changeset
592 * @param prevIgnored Ignored in this implementation of WaterLineArtifact.
3123
edf629d43f05 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
593 *
1122
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
594 * @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
595 * 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
596 */
2652
9d2a06c3a134 Added DataType for lines that also stores width, use it. Added HasLabel interface for some series.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2624
diff changeset
597 @Override
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3233
diff changeset
598 public Lines.LineData getWaterLines(int idx, FastCrossSectionLine csl,
4479
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
599 double nextIgnored, double prevIgnored, CallContext context) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
600 log.debug("getWaterLines(" + idx + ")");
1975
b30e1710df1d Server-side of interactive cross-section diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1974
diff changeset
601
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2107
diff changeset
602 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
603
1139
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
604 // Need W at km
4479
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
605 Object waterlevelResult = getWaterlevelData(context).getData();
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
606 WQKms [] wqkms;
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
607
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
608 if (waterlevelResult instanceof ExtremeResult) {
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
609 wqkms = ((ExtremeResult) waterlevelResult).getWQKms();
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
610 }
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
611 else {
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
612 wqkms = (WQKms[]) waterlevelResult;
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
613 }
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
614
1139
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
615 if (wqkms.length == 0) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
616 log.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
617 return Lines.createWaterLines(points, 0.0f);
1139
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
618 }
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
619
3123
edf629d43f05 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
620 if (wqkms.length <= idx) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
621 log.error("getWaterLines() requested index ("
1802
26d7077e42d2 Corrected CrossSection diagram/out to include one facet per computed waterlevel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1777
diff changeset
622 + idx + " not found.");
3124
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
623 return waterLineC(idx, csl);
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
624 }
1802
26d7077e42d2 Corrected CrossSection diagram/out to include one facet per computed waterlevel.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1777
diff changeset
625
4479
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
626 // Find W at km, linear naive approach.
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
627 WQKms triple = wqkms[idx];
5fc7df736634 WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4478
diff changeset
628
3124
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
629 // Find index of km.
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
630 double wishKM = csl.getKm();
555ed85af32e fix issue680; hack.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3123
diff changeset
631
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
632 if (triple.size() == 0) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
633 log.warn("Calculation of waterline is empty.");
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
634 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
635 }
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
636
3892
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
637 // Early abort if we would need to extrapolate.
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
638 int T = triple.size();
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
639 double max_km = triple.getKm(T-1), min_km = triple.getKm(0);
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
640 if (wishKM < min_km || wishKM > max_km) {
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
641 // TODO Does this have to be done in the other WaterlineArtifact
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
642 // implementations, too?
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
643 log.warn("Will not extrapolate waterlevels.");
3892
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
644 return Lines.createWaterLines(points, 0.0f);
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
645 }
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
646
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
647 int old_idx = 0;
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
648
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
649 // 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
650 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
651 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
652
3892
1dc658c3306b Fix issue886 (no extrapolation of waterlines).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3785
diff changeset
653 for (int i = 0; i < T; i++) {
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
654 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
655 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
656 break;
1139
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
657 }
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
658 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
659 old_dist_wish = diff;
1139
6d9b08b958e2 Fix waterline in crosssection diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1138
diff changeset
660 }
3123
edf629d43f05 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
661
1651
a7def20539fb flys/issue317: Removed dependency from cross section demo app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1157
diff changeset
662 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
663 }
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
664
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
665
111794adf285 Get real (but yet not parameterized) data to display in CrossSection.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1116
diff changeset
666 /**
8728
f51b9305d338 (issue1801) Reference gauge for waterlevel calculation depends on direction of calculation or flow direction.
Tom Gottfried <tom@intevation.de>
parents: 8704
diff changeset
667 * Returns the Qs for a number of Ws.
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
668 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
669 * @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
670 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
671 * @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
672 */
9130
f61bc0c63188 WQSelect can now handle distance-only data
gernotbelger
parents: 8914
diff changeset
673 private double [][] getQsForWs(double[] ws, Calculation report) {
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
674
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
675 if (ws == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
676 log.error("getQsForWs: ws == null");
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
677 return null;
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
678 }
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
679
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
680 boolean debug = log.isDebugEnabled();
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
681
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
682 if (debug) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
683 log.debug("D4EArtifact.getQsForWs");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
684 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
685
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
686 River r = RiverUtils.getRiver(this);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
687 if (r == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
688 log.warn("no river found");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
689 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
690 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
691
6101
a0078e5e3b39 Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
692 RangeAccess rangeAccess = new RangeAccess(this);
4861
aae2b7492c1e WINFOArtifact: Updated to use RangeAccess instead of FLYSUtils.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4846
diff changeset
693 double [] range = rangeAccess.getKmRange();
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
694 if (range == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
695 log.warn("no ranges found");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
696 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
697 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
698
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
699 if (isFreeW()) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
700 log.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
701 // 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
702 // "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
703 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
704 if (wst == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
705 log.warn("no wst value table found");
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
706 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
707 }
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
708 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
709
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
710 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
711 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
712
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
713 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
714
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
715 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
716 double w = ws[i];
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
717 if (debug) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
718 log.debug("getQsForWs: lookup Q for W: " + w);
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
719 }
8704
93a31cfb18c0 (issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents: 8565
diff changeset
720 // There could be more than one Q per W.
93a31cfb18c0 (issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents: 8565
diff changeset
721 double [] qs = wst.findQsForW(km, w, report);
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
722 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
723 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
724 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
725 }
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
726 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
727 }
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
728
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
729 if (debug) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
730 log.debug("getQsForWs: number of Qs: " + outQs.size());
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
731 }
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
732
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2765
diff changeset
733 return new double [][] {
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2765
diff changeset
734 outQs.toNativeArray(),
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
735 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
736 }
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
737
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
738 if (debug) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
739 log.debug("range: " + Arrays.toString(range));
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
740 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
741
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8758
diff changeset
742 Gauge g = rangeAccess.getRiver().determineRefGauge(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8758
diff changeset
743 range, rangeAccess.isRange());
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
744 if (g == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
745 log.warn("no gauge found for km: " + range[0]);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
746 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
747 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
748
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
749 if (debug) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
750 log.debug("convert w->q with gauge '" + g.getName() + "'");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
751 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
752
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
753 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
754
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
755 if (dt == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
756 log.warn("No master discharge table found for gauge '"
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
757 + 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
758 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
759 }
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
760
6301
20a32dbdbb59 Remove discharge table scaling but add reference system to W
Andre Heinecke <aheinecke@intevation.de>
parents: 6101
diff changeset
761 double [][] values = DischargeTables.loadDischargeTableValues(dt);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
762
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
763 TDoubleArrayList wsOut = new TDoubleArrayList(ws.length);
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
764 TDoubleArrayList qsOut = new TDoubleArrayList(ws.length);
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
765
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
766 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
767
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
768 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
769 if (Double.isNaN(ws[i])) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
770 log.warn("W is NaN: ignored");
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
771 continue;
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
772 }
6301
20a32dbdbb59 Remove discharge table scaling but add reference system to W
Andre Heinecke <aheinecke@intevation.de>
parents: 6101
diff changeset
773 double [] qs = DischargeTables.getQsForW(values, ws[i]);
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
774
899ca89f497e Another partial fix for flys/issue499: Do the W to Q conversions
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2415
diff changeset
775 if (qs.length == 0) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
776 log.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
777 }
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
778 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
779 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
780 wsOut.add(ws[i]);
6301
20a32dbdbb59 Remove discharge table scaling but add reference system to W
Andre Heinecke <aheinecke@intevation.de>
parents: 6101
diff changeset
781 qsOut.add(q);
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
782 }
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
783 }
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
784 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
785 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
786
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
787 return new double [][] {
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
788 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
789 generatedWs ? wsOut.toNativeArray() : null
2415
64dd65aa620d Partial fix for flys/issue499
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2326
diff changeset
790 };
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
791 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
792
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
793
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
794 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
795 * 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
796 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
797 * @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
798 * @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
799 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
800 * @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
801 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
802 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
803 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
804 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
805
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
806 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
807 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
808
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
809
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 * 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
812 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
813 * @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
814 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
815 public double[] getQs() {
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
816 StateData dMode = getData("wq_isq");
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
817 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
818
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
819 boolean isRange = dSelection != null
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
820 ? Boolean.valueOf((String)dSelection.getValue())
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
821 : false;
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
822
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
823 if (isQ()) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
824 if (!isRange) {
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
825 return getSingleWQValues();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
826 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
827 else {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
828 return getWQTriple();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
829 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
830 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
831 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
832 log.warn("You try to get Qs, but W 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
833 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
834 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
835 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
836
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
837
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
838 public boolean isQ() {
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
839 StateData mode = getData("wq_isq");
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
840 String value = (mode != null) ? (String) mode.getValue() : null;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
841 return value != null ? Boolean.valueOf(value) : false;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
842 }
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
843
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
844 public boolean isW() {
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
845 StateData mode = getData("wq_isq");
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
846 String value = (mode != null) ? (String) mode.getValue() : null;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
847 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
848 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
849
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
850 public boolean isFreeW() {
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
851 if(!isW()) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
852 return false;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
853 }
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
854 StateData mode = getData("wq_isfree");
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
855 String value = (mode != null) ? (String) mode.getValue() : null;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
856
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
857 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
858 }
d548e2e13524 Added code for the simple case of "Bezugslinienverfahren" ("W auf freier Strecke").
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2126
diff changeset
859
1055
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 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
862 * 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
863 * 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
864 * to a gauge.
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 * @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
867 * 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
868 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
869 public boolean isFreeQ() {
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
870 if(!isQ()) {
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
871 return false;
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
872 }
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
873 StateData mode = getData("wq_isfree");
1115
eaf32c767bac Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1102
diff changeset
874 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
875
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
876 log.debug("isFreeQ: " + value);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
877
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
878 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
879 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
880
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
881
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
882 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
883 * 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
884 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
885 * @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
886 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
887 * @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
888 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
889 public double[] getQs(double[] range) {
2423
ac528b883b47 Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2422
diff changeset
890 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
891
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
892 if (isQ()) {
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
893 return getWQForDist(range);
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
894 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
895
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
896 log.warn("You try to get Qs, but Ws 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
897 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
898 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
899
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
900
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
901 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
902 * 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
903 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
904 * @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
905 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
906 * @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
907 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
908 public double[] getWs(double[] range) {
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
909 if (isW()) {
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
910 return getWQForDist(range);
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
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
913 log.warn("You try to get Ws, but Qs 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
914 return null;
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
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 /**
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
919 * 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
920 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
921 * @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
922 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
923 public double[] getWs() {
2422
44dc117aa2b7 Picked rev 4058,4063,4065,4068,4069 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2418
diff changeset
924 if (isW()) {
4652
cf5ac1097d6a WINFOArtifact: Tiny optimization, get data only when needed.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4505
diff changeset
925 StateData dSingle = getData("wq_single");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
926 if (dSingle != null) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
927 return getSingleWQValues();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
928 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
929 else {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
930 return getWQTriple();
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 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
934 log.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
935 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
936 }
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
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 * 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
941 * (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
942 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
943 * @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
944 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
945 * @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
946 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
947 protected double[] getWQForDist(double[] dist) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
948 log.debug("Search wq values for range: " + dist[0] + " - " + dist[1]);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
949 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
950
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
951 if (data == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
952 log.warn("Missing wq values!");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
953 return null;
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
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
956 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
957 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
958
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
959 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
960 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
961
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
962 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
963 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
964
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
965 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
966 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
967
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
968 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
969 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
970
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
971 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
972 try {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
973 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
974 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
975 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
976 log.warn(nfe, nfe);
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
977 }
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
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
980 return res;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
981 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
982 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
983
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
984 log.warn("Specified range for WQ not found!");
1055
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 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
987 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
988
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 * 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
992 * 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
993 *
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
994 * @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
995 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
996 protected double[] getWQTriple() {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
997 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
998 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
999
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1000 if (dFrom == null || dTo == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
1001 log.warn("Missing start or end value for range.");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1002 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1003 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1004
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1005 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
1006 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
1007
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1008 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
1009
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1010 if (dStep == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
1011 log.warn("No step width given. Cannot compute Qs.");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1012 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1013 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1014
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1015 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
1016
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1017 // 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
1018 // 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
1019 if (step == 0d) {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1020 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
1021 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
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 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
1025 }
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
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 * 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
1030 * separated list.
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 * @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
1033 */
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1034 protected double[] getSingleWQValues() {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1035 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
1036
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1037 if (dSingle == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
1038 log.warn("Cannot determine single WQ values. No data given.");
1055
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1039 return null;
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1040 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1041
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1042 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
1043 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
1044
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1045 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
1046
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1047 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
1048 try {
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1049 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
1050 }
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1051 catch (NumberFormatException nfe) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6625
diff changeset
1052 log.warn(nfe, nfe);
1055
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 values.sort();
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 values.toNativeArray();
61c051e53f9b Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1050
diff changeset
1059 }
105
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1060 }
beb991dc4827 Added a first stub of an WINFO artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1061 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org