comparison flys-artifacts/src/main/java/de/intevation/flys/utils/FLYSUtils.java @ 2552:c7dbe696286c

Refactored the wq data fields. flys-artifacts/trunk@4065 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 16 Feb 2012 12:36:25 +0000
parents d69d8dea78dc
children ac528b883b47 ba46af45b6e4
comparison
equal deleted inserted replaced
2551:a0d9a99a5d17 2552:c7dbe696286c
55 * An enum that represents the 5 possible WQ modes in FLYS. The 5 values are 55 * An enum that represents the 5 possible WQ modes in FLYS. The 5 values are
56 * <i>QFREE</i> <i>QGAUGE</i> <i>WGAUGE</i> <i>WFREE</i> and <i>NONE</i>. 56 * <i>QFREE</i> <i>QGAUGE</i> <i>WGAUGE</i> <i>WFREE</i> and <i>NONE</i>.
57 */ 57 */
58 public static enum WQ_MODE { QFREE, QGAUGE, WFREE, WGAUGE, NONE }; 58 public static enum WQ_MODE { QFREE, QGAUGE, WFREE, WGAUGE, NONE };
59 59
60 /**
61 * An enum that represents the 4 possible WQ input modes in FLYS. The 4
62 * values are
63 * <i>ADAPTED</i> <i>SINGLE</i> <i>RANGE</i> and <i>NONE</i>.
64 */
65 public static enum WQ_INPUT { ADAPTED, SINGLE, RANGE, NONE };
60 66
61 public static final Pattern NUMBERS_PATTERN = 67 public static final Pattern NUMBERS_PATTERN =
62 Pattern.compile("\\D*(\\d++.\\d*)\\D*"); 68 Pattern.compile("\\D*(\\d++.\\d*)\\D*");
63 69
64 public static final String XPATH_RIVER_PROJECTION = 70 public static final String XPATH_RIVER_PROJECTION =
167 public static WQ_MODE getWQMode(FLYSArtifact flys) { 173 public static WQ_MODE getWQMode(FLYSArtifact flys) {
168 if (flys == null) { 174 if (flys == null) {
169 return WQ_MODE.NONE; 175 return WQ_MODE.NONE;
170 } 176 }
171 177
172 String mode = flys.getDataAsString("wq_mode"); 178 String values = flys.getDataAsString("wq_values");
173 Boolean free = flys.getDataAsBoolean("wq_free"); 179 Boolean isQ = flys.getDataAsBoolean("wq_mode");
174 180
175 free = free != null ? free : false; 181 if (values != null) {
176 182 return isQ ? WQ_MODE.QGAUGE : WQ_MODE.WGAUGE;
177 if (mode != null && mode.equals("Q")) { 183 }
178 return free ? WQ_MODE.QFREE : WQ_MODE.QGAUGE; 184
179 } 185 Boolean isFree = flys.getDataAsBoolean("wq_free");
180 else if (mode != null && mode.equals("W")) { 186
181 return free ? WQ_MODE.WFREE : WQ_MODE.WGAUGE; 187 if (isQ) {
188 return isFree ? WQ_MODE.QFREE : WQ_MODE.QGAUGE;
189 }
190 else if (!isQ) {
191 return isFree ? WQ_MODE.WFREE : WQ_MODE.WGAUGE;
182 } 192 }
183 else { 193 else {
184 return WQ_MODE.NONE; 194 return WQ_MODE.NONE;
185 } 195 }
186 } 196 }
187 197
198
199 public static WQ_INPUT getWQInputMode(FLYSArtifact flys) {
200 if (flys == null) {
201 return WQ_INPUT.NONE;
202 }
203
204 Boolean selection = flys.getDataAsBoolean("wq_selection");
205 String adapted = flys.getDataAsString("wq_values");
206
207 if(adapted != null && adapted.length() > 0) {
208 return WQ_INPUT.ADAPTED;
209 }
210
211 if (selection != null && selection) {
212 return WQ_INPUT.RANGE;
213 }
214 else {
215 return WQ_INPUT.SINGLE;
216 }
217 }
188 218
189 public static KM_MODE getKmRangeMode(FLYSArtifact flys) { 219 public static KM_MODE getKmRangeMode(FLYSArtifact flys) {
190 String mode = flys.getDataAsString("ld_mode"); 220 String mode = flys.getDataAsString("ld_mode");
191 221
192 if (mode == null || mode.length() == 0) { 222 if (mode == null || mode.length() == 0) {
335 * @param flys A FLYSArtifact. 365 * @param flys A FLYSArtifact.
336 * 366 *
337 * @return the Ws. 367 * @return the Ws.
338 */ 368 */
339 public static double[] getWs(FLYSArtifact flys) { 369 public static double[] getWs(FLYSArtifact flys) {
340 double[] kmRange = getKmRange(flys);
341
342 // XXX this is not nice! 370 // XXX this is not nice!
343 if (flys instanceof WINFOArtifact) { 371 if (flys instanceof WINFOArtifact) {
344 return ((WINFOArtifact) flys).getWs(kmRange); 372 return ((WINFOArtifact) flys).getWs();
345 } 373 }
346 374
347 logger.warn("This method currently supports WINFOArtifact only!"); 375 logger.warn("This method currently supports WINFOArtifact only!");
348 376
349 return null; 377 return null;

http://dive4elements.wald.intevation.org