annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java @ 3918:2fdbe78a8fc2

Fixed various projection issues during map creation. flys-artifacts/trunk@5598 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 26 Sep 2012 08:00:44 +0000
parents 7500c7fbfaa9
children a2735a4bf75e
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
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 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
19 import de.intevation.flys.artifacts.model.WQKms;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21 import de.intevation.flys.artifacts.states.DefaultState;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
23 import de.intevation.flys.artifacts.model.Calculation;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
24 import de.intevation.flys.artifacts.model.CalculationResult;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
25
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
26 import de.intevation.flys.artifacts.model.DischargeTables;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
27
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
28 import de.intevation.flys.model.Gauge;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
29 import de.intevation.flys.model.River;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
30
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
31 import de.intevation.flys.utils.FLYSUtils;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
32
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
33
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34 /**
3046
6e4ad35bcb11 Fix certain GaugeDischargeArtifact-issues, import river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
35 * Artifact to get discharge curves at gauges.
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 public class GaugeDischargeArtifact
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 extends WINFOArtifact
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 implements FacetTypes
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 /** The logger for this class. */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 private static Logger logger = Logger.getLogger(GaugeDischargeArtifact.class);
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 /** The name of the artifact. */
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
45 public static final String ARTIFACT_NAME = "gaugedischarge";
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46
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 * Trivial Constructor.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 public GaugeDischargeArtifact() {
3046
6e4ad35bcb11 Fix certain GaugeDischargeArtifact-issues, import river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
52 logger.debug("GaugeDischargeArtifact.GaugeDischargeArtifact()");
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 }
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 * Gets called from factory, to set things up.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 * Especially, when loaded via datacage mechanisms, provide the
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 * data document.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 * @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
61 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 @Override
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 public void setup(
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 String identifier,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65 ArtifactFactory factory,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 Object context,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 CallMeta callMeta,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 Document data)
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 logger.debug("GaugeDischargeArtifact.setup");
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
71 String ids = StaticFLYSArtifact.getDatacageIDValue(data);
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
72 addStringData("ids", ids);
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
73 logger.debug("id for gaugedischarge: " + ids);
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 super.setup(identifier, factory, context, callMeta, data);
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 }
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 /** Return the name of this artifact. */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 public String getName() {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80 return ARTIFACT_NAME;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 }
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 * Setup state and facet, copy from master artifact.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 @Override
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
88 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
89 logger.debug("GaugeDischargeArtifact.initialize");
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
90 List<Facet> fs = new ArrayList<Facet>();
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
91 FLYSArtifact artifact = (FLYSArtifact) art;
3046
6e4ad35bcb11 Fix certain GaugeDischargeArtifact-issues, import river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
92 importData(artifact, "river");
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
93
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
94 // Get the location(s)
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
95 //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
96 addStringData("ld_from", "0");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
97 addStringData("ld_to", "1000");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
98 addStringData("ld_mode", "distance");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
99
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 DefaultState state = (DefaultState) getCurrentState(context);
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 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
102 if (!fs.isEmpty()) {
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
103 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
104 + state.getID() + "/ " + getCurrentStateId() + ").");
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
105 facets.put(getCurrentStateId(), fs);
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
106 }
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
107 else {
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
108 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
109 + state.getID() + "/ "+getCurrentStateId()+").");
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
110 }
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
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
114 /** 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
115 public String getGaugeName() {
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
116 return this.getDataAsString("ids");
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
117 }
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 /** 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
121 public Gauge getGauge() {
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
122 River river = FLYSUtils.getRiver(this);
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
123 return river.determineGaugeByName(getGaugeName());
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
124 }
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
125
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 * 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
129 * @return CalculationResult with WQKms.
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
130 */
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
131 public CalculationResult getDischargeCurveData() {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
132
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
133 River river = FLYSUtils.getRiver(this);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
134 if (river == null) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
135 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
136 }
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
137 /*
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
138 // 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
139 double [] distance = FLYSUtils.getKmRange(this);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
140 logger.debug("getDischargeCurveData: get range");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
141
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
142 if (distance == null) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
143 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
144 }
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 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
147 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
148
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
149 if (gauges.isEmpty()) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
150 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
151 }
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 String [] names = new String[gauges.size()];
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
154
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
155 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
156 names[i] = gauges.get(i).getName();
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
157 logger.debug("getDischargeCurveData: name " + names[i]);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
158 }
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
159 */
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
160
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
161 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
162
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
163 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
164
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
165 ArrayList<WQKms> res = new ArrayList<WQKms>();
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
166
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
167 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
168
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
169 String name = getGaugeName();
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
170 double [][] values = map.get(name);
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
171 if (values == null) {
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
172 logger.error("No values for this gauge / discharge found.");
3591
7500c7fbfaa9 Fail more gracefully.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
173 return error(new WQKms[0], "no.gauge.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 }
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
186 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
187 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org