annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java @ 3172:36806f6e23fb

Removed trailing whitespace. flys-artifacts/trunk@4785 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 25 Jun 2012 16:04:08 +0000
parents 5642a83420f2
children 0f7abd95c6e2
rev   line source
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
2
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
3 import java.util.ArrayList;
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
4 import java.util.Arrays;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
5 import java.util.List;
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
6 import java.util.Map;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
7
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
8 import org.apache.log4j.Logger;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
9
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10 import org.w3c.dom.Document;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 import de.intevation.artifactdatabase.state.Facet;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import de.intevation.artifacts.Artifact;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import de.intevation.artifacts.ArtifactFactory;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 import de.intevation.artifacts.CallMeta;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17
2740
64dc2997b2dd Refactor static xpath, other artifacts will come in a later commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2733
diff changeset
18 import de.intevation.flys.artifacts.StaticFLYSArtifact;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import de.intevation.flys.artifacts.model.FacetTypes;
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
20 import de.intevation.flys.artifacts.model.WQKms;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22 import de.intevation.flys.artifacts.states.DefaultState;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
24 import de.intevation.flys.artifacts.model.Calculation;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
25 import de.intevation.flys.artifacts.model.CalculationResult;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
26
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
27 import de.intevation.flys.artifacts.model.DischargeTables;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
28
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
29 import de.intevation.flys.model.Gauge;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
30 import de.intevation.flys.model.River;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
31
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
32 import de.intevation.flys.utils.FLYSUtils;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
33
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 /**
3046
6e4ad35bcb11 Fix certain GaugeDischargeArtifact-issues, import river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
36 * Artifact to get discharge curves at gauges.
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 public class GaugeDischargeArtifact
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 extends WINFOArtifact
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 implements FacetTypes
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 /** The logger for this class. */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 private static Logger logger = Logger.getLogger(GaugeDischargeArtifact.class);
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 /** The name of the artifact. */
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
46 public static final String ARTIFACT_NAME = "gaugedischarge";
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 /**
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 * Trivial Constructor.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 public GaugeDischargeArtifact() {
3046
6e4ad35bcb11 Fix certain GaugeDischargeArtifact-issues, import river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
53 logger.debug("GaugeDischargeArtifact.GaugeDischargeArtifact()");
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 /**
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 * Gets called from factory, to set things up.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 * Especially, when loaded via datacage mechanisms, provide the
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 * data document.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 * @param data filled with stuff from dc, if any.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 @Override
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 public void setup(
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65 String identifier,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 ArtifactFactory factory,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 Object context,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 CallMeta callMeta,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 Document data)
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 logger.debug("GaugeDischargeArtifact.setup");
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
72 String ids = StaticFLYSArtifact.getDatacageIDValue(data);
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
73 addStringData("ids", ids);
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
74 logger.debug("id for gaugedischarge: " + ids);
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 super.setup(identifier, factory, context, callMeta, data);
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 /** Return the name of this artifact. */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80 public String getName() {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 return ARTIFACT_NAME;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 /**
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 * Setup state and facet, copy from master artifact.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
88 @Override
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
89 protected void initialize(Artifact art, Object context, CallMeta meta) {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
90 logger.debug("GaugeDischargeArtifact.initialize");
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
91 List<Facet> fs = new ArrayList<Facet>();
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
92 FLYSArtifact artifact = (FLYSArtifact) art;
3046
6e4ad35bcb11 Fix certain GaugeDischargeArtifact-issues, import river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
93 importData(artifact, "river");
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
94
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
95 // Get the location(s)
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
96 //importData(artifact, "ld_mode", ld_from, ld_to, ld_locations
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
97 addStringData("ld_from", "0");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
98 addStringData("ld_to", "1000");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
99 addStringData("ld_mode", "distance");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
100
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 DefaultState state = (DefaultState) getCurrentState(context);
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102 state.computeInit(this, hash(), context, meta, fs);
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
103 if (!fs.isEmpty()) {
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
104 logger.debug("Facets to add in GaugeDischargeArtifact.initialize. ("
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
105 + state.getID() + "/ " + getCurrentStateId() + ").");
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
106 facets.put(getCurrentStateId(), fs);
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
107 }
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
108 else {
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
109 logger.debug("No facets to add in GaugeDischargeArtifact.initialize ("
3046
6e4ad35bcb11 Fix certain GaugeDischargeArtifact-issues, import river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
110 + state.getID() + "/ "+getCurrentStateId()+").");
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
111 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
112 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
113
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
114
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
115 /** Get the Gauges name which came with datacage data-document. */
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
116 public String getGaugeName() {
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
117 return this.getDataAsString("ids");
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
118 }
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
119
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
120
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
121 /** Get the Gauges which came with datacage data-document. */
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
122 public Gauge getGauge() {
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
123 River river = FLYSUtils.getRiver(this);
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
124 return river.determineGaugeByName(getGaugeName());
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
125 }
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
126
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
127
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
128 /**
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
129 * Returns the data that is used to create discharge curves.
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
130 * @return CalculationResult with WQKms.
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
131 */
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
132 public CalculationResult getDischargeCurveData() {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
133
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
134 River river = FLYSUtils.getRiver(this);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
135 if (river == null) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
136 return error(new WQKms[0], "no.river.selected");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
137 }
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
138 /*
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
139 // This one would allow to automatically pick the right Gauge.
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
140 double [] distance = FLYSUtils.getKmRange(this);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
141 logger.debug("getDischargeCurveData: get range");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
142
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
143 if (distance == null) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
144 return error(new WQKms[0], "no.range.found");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
145 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
146
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
147 List<Gauge> gauges = river.determineGauges(distance[0], distance[1]);
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
148 logger.debug("getDischargeCurveData: got " + gauges.size() + " gauges");
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
149
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
150 if (gauges.isEmpty()) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
151 return error(new WQKms[0], "no.gauge.selected");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
152 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
153
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
154 String [] names = new String[gauges.size()];
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
155
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
156 for (int i = 0; i < names.length; ++i) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
157 names[i] = gauges.get(i).getName();
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
158 logger.debug("getDischargeCurveData: name " + names[i]);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
159 }
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
160 */
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
161
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
162 DischargeTables dt = new DischargeTables(river.getName(), getDataAsString("ids"));
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
163
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
164 Map<String, double [][]> map = dt.getValues(100);
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
165
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
166 ArrayList<WQKms> res = new ArrayList<WQKms>();
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
167
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
168 Gauge gauge = river.determineGaugeByName(this.getDataAsString("ids"));
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
169
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
170 String name = getGaugeName();
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
171 double [][] values = map.get(name);
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
172 if (values == null) {
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
173 logger.error("No values for this gauge / discharge found.");
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
174 }
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
175 for (int i = 0 ; i < values[0].length; i++) {
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
176 values[0][i] += gauge.getDatum().doubleValue();
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
177 }
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
178 double [] kms = new double[values[0].length];
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
179 Arrays.fill(kms, gauge.getStation().doubleValue());
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
180 res.add(new WQKms(kms, values[0], values[1], name));
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
181
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
182 return new CalculationResult(
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
183 res.toArray(new WQKms[res.size()]),
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
184 new Calculation());
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
185 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
186
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
187
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
188 /**
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
189 * Determines Facets initial disposition regarding activity (think of
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
190 * selection in Client ThemeList GUI). This will be checked one time
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
191 * when the facet enters a collections describe document.
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
192 *
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
193 * @param facetName name of the facet.
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
194 * @param index index of the facet.
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
195 * @return 1 - all Facets enter activated.
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
196 */
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
197 @Override
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
198 public int getInitialFacetActivity(
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
199 String outputName,
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
200 String facetName,
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
201 int index)
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
202 {
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
203 return 1;
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
204 }
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
205 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
206 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org