Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WQSelect.java @ 319:d8558dd64152
The WQ state fills the DESCRIBE with default values for W and Q.
flys-artifacts/trunk@1707 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 15 Apr 2011 13:47:10 +0000 |
parents | 89bd0417418f |
children | a8e7c351bdf1 |
comparison
equal
deleted
inserted
replaced
318:8a4360ccbe1c | 319:d8558dd64152 |
---|---|
10 import de.intevation.artifacts.common.utils.XMLUtils; | 10 import de.intevation.artifacts.common.utils.XMLUtils; |
11 | 11 |
12 import de.intevation.artifactdatabase.ProtocolUtils; | 12 import de.intevation.artifactdatabase.ProtocolUtils; |
13 import de.intevation.artifactdatabase.data.StateData; | 13 import de.intevation.artifactdatabase.data.StateData; |
14 | 14 |
15 import de.intevation.flys.model.Gauge; | |
16 import de.intevation.flys.model.River; | |
17 import de.intevation.flys.model.Wst; | |
18 | |
19 import de.intevation.flys.artifacts.FLYSArtifact; | |
20 import de.intevation.flys.artifacts.model.WstFactory; | |
15 import de.intevation.flys.artifacts.resources.Resources; | 21 import de.intevation.flys.artifacts.resources.Resources; |
16 | 22 |
17 /** | 23 /** |
18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 24 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
19 */ | 25 */ |
68 Artifact artifact, | 74 Artifact artifact, |
69 String name, | 75 String name, |
70 CallContext context) | 76 CallContext context) |
71 { | 77 { |
72 // TODO Insert correct min/max values! | 78 // TODO Insert correct min/max values! |
79 double[] minmaxW = determineMinMaxW(artifact); | |
80 double[] minmaxQ = determineMinMaxQ(artifact); | |
73 | 81 |
74 if (name.equals("wq_from")) { | 82 if (name.equals("wq_from")) { |
75 Element minW = createItem(cr, new String[] {"minW", "250"}); | 83 Element minW = createItem( |
76 Element minQ = createItem(cr, new String[] {"minQ", "5.5"}); | 84 cr, new String[] {"minW", new Double(minmaxW[0]).toString()}); |
85 Element minQ = createItem( | |
86 cr, new String[] {"minQ", new Double(minmaxQ[0]).toString()}); | |
77 return new Element[] { minW, minQ }; | 87 return new Element[] { minW, minQ }; |
78 } | 88 } |
79 else if (name.equals("wq_to")) { | 89 else if (name.equals("wq_to")) { |
80 Element maxW = createItem(cr, new String[] {"maxW", "850"}); | 90 Element maxW = createItem( |
81 Element maxQ = createItem(cr, new String[] {"maxQ", "1530"}); | 91 cr, new String[] {"maxW", new Double(minmaxW[1]).toString()}); |
92 Element maxQ = createItem( | |
93 cr, new String[] {"maxQ", new Double(minmaxQ[1]).toString()}); | |
82 return new Element[] { maxW, maxQ }; | 94 return new Element[] { maxW, maxQ }; |
83 } | 95 } |
84 else { | 96 else { |
85 Element stepW = createItem(cr, new String[] {"stepW", DEFAULT_STEP_W}); | 97 Element stepW = createItem(cr, new String[] {"stepW", DEFAULT_STEP_W}); |
86 Element stepQ = createItem(cr, new String[] {"stepQ", DEFAULT_STEP_Q}); | 98 Element stepQ = createItem(cr, new String[] {"stepQ", DEFAULT_STEP_Q}); |
107 | 119 |
108 | 120 |
109 protected String getUIProvider() { | 121 protected String getUIProvider() { |
110 return "wq_panel"; | 122 return "wq_panel"; |
111 } | 123 } |
124 | |
125 | |
126 /** | |
127 * Determines the min and max W value for the current gauge. If no min and | |
128 * max values could be determined, this method will return | |
129 * [Double.MIN_VALUE, Double.MAX_VALUE]. | |
130 * | |
131 * @param artifact The FLYSArtifact. | |
132 * | |
133 * @return the min and max W values for the current gauge. | |
134 */ | |
135 protected double[] determineMinMaxW(Artifact artifact) { | |
136 logger.debug("WQSelect.determineCurrentGauge"); | |
137 | |
138 Gauge gauge = ((FLYSArtifact) artifact).getGauge(); | |
139 double[] minmaxW = gauge.determineMinMaxW(); | |
140 | |
141 double minW = minmaxW != null ? minmaxW[0] : Double.MIN_VALUE; | |
142 double maxW = minmaxW != null ? minmaxW[1] : Double.MAX_VALUE; | |
143 | |
144 return new double[] { minW, maxW }; | |
145 } | |
146 | |
147 | |
148 /** | |
149 * Determines the min and max Q value for the current gauge. If no min and | |
150 * max values could be determined, this method will return | |
151 * [Double.MIN_VALUE, Double.MAX_VALUE]. | |
152 * | |
153 * @param artifact The FLYSArtifact. | |
154 * | |
155 * @return the min and max Q values for the current gauge. | |
156 */ | |
157 protected double[] determineMinMaxQ(Artifact artifact) { | |
158 logger.debug("WQSelect.determineMinMaxQ"); | |
159 | |
160 FLYSArtifact flysArtifact = (FLYSArtifact) artifact; | |
161 | |
162 River river = flysArtifact.getRiver(); | |
163 Gauge gauge = flysArtifact.getGauge(); | |
164 Wst wst = WstFactory.getWst(river); | |
165 | |
166 double[] minmaxQ = wst.determineMinMaxQ(gauge.getRange()); | |
167 | |
168 double minQ = minmaxQ != null ? minmaxQ[0] : Double.MIN_VALUE; | |
169 double maxQ = minmaxQ != null ? minmaxQ[1] : Double.MAX_VALUE; | |
170 | |
171 return new double[] { minQ, maxQ }; | |
172 } | |
112 } | 173 } |
113 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 174 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |