annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java @ 2745:b63017afbca8

Add helper to allow for points at duration curve facet. flys-artifacts/trunk@4480 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 23 May 2012 19:31:26 +0000
parents 0251393f037c
children 2f7fed1eb4bf
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
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
12 import de.intevation.artifactdatabase.data.DefaultStateData;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import de.intevation.artifactdatabase.state.Facet;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15 import de.intevation.artifacts.Artifact;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 import de.intevation.artifacts.ArtifactFactory;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import de.intevation.artifacts.ArtifactNamespaceContext;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 import de.intevation.artifacts.CallMeta;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20 import de.intevation.artifacts.common.utils.XMLUtils;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
21
2740
64dc2997b2dd Refactor static xpath, other artifacts will come in a later commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2733
diff changeset
22 import de.intevation.flys.artifacts.StaticFLYSArtifact;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23 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
24 import de.intevation.flys.artifacts.model.WQKms;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
26 import de.intevation.flys.artifacts.states.DefaultState;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
28 import de.intevation.flys.artifacts.model.Calculation;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
29 import de.intevation.flys.artifacts.model.CalculationResult;
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.artifacts.model.DischargeTables;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
32
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
33 import de.intevation.flys.model.Gauge;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
34 import de.intevation.flys.model.River;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
35
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
36 import de.intevation.flys.utils.FLYSUtils;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
37
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 /**
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 * Artifact to store user-added points.
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 public class GaugeDischargeArtifact
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 extends WINFOArtifact
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 implements FacetTypes
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 /** The logger for this class. */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 private static Logger logger = Logger.getLogger(GaugeDischargeArtifact.class);
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 /** The name of the artifact. */
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
50 public static final String ARTIFACT_NAME = "gaugedischarge";
2723
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
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 * Trivial Constructor.
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 public GaugeDischargeArtifact() {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 logger.debug("GaugeDischargeArtifact.HistoricalQArtifact()");
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60
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 * Gets called from factory, to set things up.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 * Especially, when loaded via datacage mechanisms, provide the
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 * data document.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65 * @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
66 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 @Override
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 public void setup(
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 String identifier,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 ArtifactFactory factory,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 Object context,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 CallMeta callMeta,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 Document data)
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 logger.debug("GaugeDischargeArtifact.setup");
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 super.setup(identifier, factory, context, callMeta, data);
2741
0251393f037c Refactor usage of now static xpath, other artifacts will follow in later commits.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2740
diff changeset
77 String ids = StaticFLYSArtifact.getDatacageIDValue(data);
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 logger.debug("id for gaugedischarge: " + ids);
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80
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 /** Return the name of this artifact. */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 public String getName() {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84 return ARTIFACT_NAME;
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
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 /** Access state data storing the jsonstring with points.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
89 public String getPointsData(String facetName) {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
90 return getDataAsString(facetName + ".data");
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
91 }*/
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
92
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 /**
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
95 * Setup state and facet, copy from master artifact.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
96 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
97 @Override
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
98 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
99 logger.debug("GaugeDischargeArtifact.initialize");
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 List<Facet> fs = new ArrayList<Facet>();
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 FLYSArtifact artifact = (FLYSArtifact) art;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
103 // Get the location(s)
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
104 //importData(artifact, "ld_mode");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
105 //importData(artifact, "ld_from");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
106 //importData(artifact, "ld_to");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
107 //importData(artifact, "ld_locations");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
108 addStringData("ld_from", "0");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
109 addStringData("ld_to", "1000");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
110 addStringData("ld_mode", "distance");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
111
2723
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 DefaultState state = (DefaultState) getCurrentState(context);
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
114 state.computeInit(this, hash(), context, meta, fs);
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
115 if (!fs.isEmpty()) {
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
116 logger.debug("Facets to add in GaugeDischargeArtifact.initialize. ("
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
117 + state.getID() + ").");
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
118 facets.put(getCurrentStateId(), fs);
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
119 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
120 else {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
121 logger.debug("No facets to add in GaugeDischargeArtifact.initialize ("
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
122 + state.getID() + ").");
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
123 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
124 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
125
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
126
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
127 /**
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
128 * Determines Facets initial disposition regarding activity (think of
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
129 * selection in Client ThemeList GUI). This will be checked one time
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
130 * when the facet enters a collections describe document.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
131 *
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
132 * @param facetName name of the facet.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
133 * @param index index of the facet.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
134 * @return 0 if not active
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
135 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
136 @Override
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
137 public int getInitialFacetActivity(
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
138 String outputName,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
139 String facetName,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
140 int index)
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
141 {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
142 return 1;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
143 }
2733
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 /**
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
147 * Returns the data that is used to create discharge curves.
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 */
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
150 public CalculationResult getDischargeCurveData() {
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 River river = FLYSUtils.getRiver(this);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
153 if (river == null) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
154 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
155 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
156
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
157 double [] distance = FLYSUtils.getKmRange(this);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
158 logger.debug("getDischargeCurveData: get range");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
159
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
160 if (distance == null) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
161 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
162 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
163
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
164 List<Gauge> gauges = river.determineGauges(distance[0], distance[1]);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
165 logger.debug("getDischargeCurveData: get gauges");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
166
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
167 if (gauges.isEmpty()) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
168 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
169 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
170
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
171 String [] names = new String[gauges.size()];
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
172
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
173 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
174 names[i] = gauges.get(i).getName();
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
175 logger.debug("getDischargeCurveData: name " + names[i]);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
176 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
177
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
178 DischargeTables dt = new DischargeTables(river.getName(), names);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
179
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
180 Map<String, double [][]> map = dt.getValues(100d);
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 ArrayList<WQKms> res = new ArrayList<WQKms>();
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
183
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
184 for (Gauge gauge: gauges) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
185 String name = gauge.getName();
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
186 double [][] values = map.get(name);
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
187 if (values == null) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
188 continue;
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
189 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
190 double [] kms = new double[values[0].length];
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
191 Arrays.fill(kms, gauge.getStation().doubleValue());
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
192 res.add(new WQKms(kms, values[0], values[1], name));
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
193 logger.debug("getDischargeCurveData: add one res gauge");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
194 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
195
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
196 return new CalculationResult(
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
197 res.toArray(new WQKms[res.size()]),
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
198 new Calculation());
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
199 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
200
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
201 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
202 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org