Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/GaugeDischargeArtifact.java @ 2989:ee3dbc4a802d
Added more checks in CrossSectionFactory.isNewst() to prevent IndexOutOfBoundsExceptions.
flys-artifacts/trunk@4536 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Sun, 27 May 2012 13:35:15 +0000 |
parents | 2f7fed1eb4bf |
children | 6e4ad35bcb11 |
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 |
2740
64dc2997b2dd
Refactor static xpath, other artifacts will come in a later commit.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2733
diff
changeset
|
19 import de.intevation.flys.artifacts.StaticFLYSArtifact; |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 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
|
21 import de.intevation.flys.artifacts.model.WQKms; |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.artifacts.states.DefaultState; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 |
2733
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
25 import de.intevation.flys.artifacts.model.Calculation; |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
26 import de.intevation.flys.artifacts.model.CalculationResult; |
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.artifacts.model.DischargeTables; |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
29 |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
30 import de.intevation.flys.model.Gauge; |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
31 import de.intevation.flys.model.River; |
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.utils.FLYSUtils; |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
34 |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 |
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 * Artifact to store user-added points. |
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 public class GaugeDischargeArtifact |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 extends WINFOArtifact |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 implements FacetTypes |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 /** The logger for this class. */ |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 private static Logger logger = Logger.getLogger(GaugeDischargeArtifact.class); |
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 name of the artifact. */ |
2733
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
47 public static final String ARTIFACT_NAME = "gaugedischarge"; |
2723
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 /** |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 * Trivial Constructor. |
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 public GaugeDischargeArtifact() { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 logger.debug("GaugeDischargeArtifact.HistoricalQArtifact()"); |
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 /** |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 * Gets called from factory, to set things up. |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 * Especially, when loaded via datacage mechanisms, provide the |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 * data document. |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 * @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
|
63 */ |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 @Override |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 public void setup( |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 String identifier, |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 ArtifactFactory factory, |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 Object context, |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 CallMeta callMeta, |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
70 Document data) |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 logger.debug("GaugeDischargeArtifact.setup"); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 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
|
74 String ids = StaticFLYSArtifact.getDatacageIDValue(data); |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 logger.debug("id for gaugedischarge: " + ids); |
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 /** Access state data storing the jsonstring with points. |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 public String getPointsData(String facetName) { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
87 return getDataAsString(facetName + ".data"); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
88 }*/ |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
89 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
90 |
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 * Setup state and facet, copy from master artifact. |
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 @Override |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 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
|
96 logger.debug("GaugeDischargeArtifact.initialize"); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
97 List<Facet> fs = new ArrayList<Facet>(); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 FLYSArtifact artifact = (FLYSArtifact) art; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
100 // Get the location(s) |
2733
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
101 //importData(artifact, "ld_mode"); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
102 //importData(artifact, "ld_from"); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
103 //importData(artifact, "ld_to"); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
104 //importData(artifact, "ld_locations"); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
105 addStringData("ld_from", "0"); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
106 addStringData("ld_to", "1000"); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
107 addStringData("ld_mode", "distance"); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
108 |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
109 |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
110 DefaultState state = (DefaultState) getCurrentState(context); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
111 state.computeInit(this, hash(), context, meta, fs); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
112 if (!fs.isEmpty()) { |
2733
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
113 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
|
114 + state.getID() + ")."); |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
115 facets.put(getCurrentStateId(), fs); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
116 } |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
117 else { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
118 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
|
119 + state.getID() + ")."); |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
120 } |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
121 } |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
122 |
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 * Determines Facets initial disposition regarding activity (think of |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
126 * 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
|
127 * when the facet enters a collections describe document. |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
128 * |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
129 * @param facetName name of the facet. |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 * @param index index of the facet. |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
131 * @return 0 if not active |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
132 */ |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
133 @Override |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 public int getInitialFacetActivity( |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
135 String outputName, |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
136 String facetName, |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
137 int index) |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
138 { |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
139 return 1; |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
140 } |
2733
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 |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
143 /** |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
144 * 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
|
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 public CalculationResult getDischargeCurveData() { |
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 River river = FLYSUtils.getRiver(this); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
150 if (river == null) { |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
151 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
|
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 double [] distance = FLYSUtils.getKmRange(this); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
155 logger.debug("getDischargeCurveData: get range"); |
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 if (distance == null) { |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
158 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
|
159 } |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
160 |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
161 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
|
162 logger.debug("getDischargeCurveData: get gauges"); |
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 if (gauges.isEmpty()) { |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
165 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
|
166 } |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
167 |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
168 String [] names = new String[gauges.size()]; |
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 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
|
171 names[i] = gauges.get(i).getName(); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
172 logger.debug("getDischargeCurveData: name " + names[i]); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
173 } |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
174 |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
175 DischargeTables dt = new DischargeTables(river.getName(), names); |
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 Map<String, double [][]> map = dt.getValues(100d); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
178 |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
179 ArrayList<WQKms> res = new ArrayList<WQKms>(); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
180 |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
181 for (Gauge gauge: gauges) { |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
182 String name = gauge.getName(); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
183 double [][] values = map.get(name); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
184 if (values == null) { |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
185 continue; |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
186 } |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
187 double [] kms = new double[values[0].length]; |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
188 Arrays.fill(kms, gauge.getStation().doubleValue()); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
189 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
|
190 logger.debug("getDischargeCurveData: add one res gauge"); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
191 } |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
192 |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
193 return new CalculationResult( |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
194 res.toArray(new WQKms[res.size()]), |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
195 new Calculation()); |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
196 } |
ac9a03ed32c1
More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2723
diff
changeset
|
197 |
2723
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
198 } |
5ce5abd173b9
Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
199 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |