annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeState.java @ 4729:0df1cac6c4b5

Removed removeExtension implementations, which have been moved to FileTools, update callers.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 28 Dec 2012 13:33:36 +0100
parents 208a891c21b5
children
rev   line source
2696
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.List;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import de.intevation.artifacts.Artifact;
2705
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
8 import de.intevation.artifacts.CallContext;
2696
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.common.model.KVP;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.model.DischargeZone;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import de.intevation.flys.model.River;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import de.intevation.flys.artifacts.FLYSArtifact;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import de.intevation.flys.utils.FLYSUtils;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 public class DischargeState extends MultiIntArrayState {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
3759
e54f8dc222cf Renamed input parameters of MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3087
diff changeset
21 public static final String MAIN_CHANNEL = "main_channel";
e54f8dc222cf Renamed input parameters of MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 3087
diff changeset
22 public static final String TOTAL_CHANNEL = "total_channel";
2696
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 private static final Logger logger = Logger.getLogger(DischargeState.class);
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
3927
208a891c21b5 Partly fix issue871.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3759
diff changeset
28 /** Let client display a matrix. */
2696
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 @Override
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 public String getUIProvider() {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 return "parameter-matrix";
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 /**
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 * This method fetches all DischargeZones for a given river (extracted from
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 * <i>artifact</i>) and returns a KVP[] where the key is the ID of the
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 * DischargeZone and the value is a string that consists of lower discharge
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 * and upper discharge.
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 *
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 * @param artifact Needs to be a FLYSArtifact that provides river
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 * information.
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 * @param parameterName The name of a parameter.
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 *
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 * @return a KVP[].
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 */
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 @Override
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 protected KVP<Integer, String>[] getOptions(
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 Artifact artifact,
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 String parameterName
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 )
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 throws IllegalArgumentException
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 if (!testParameterName(parameterName)) {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 throw new IllegalArgumentException(
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 "Invalid parameter for state: '" + parameterName + "'");
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 List<DischargeZone> zones = getDischargeZones(artifact);
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 KVP[] kvp = new KVP[zones.size()];
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
3087
4a76da133144 Removed repeated x.size() calls from for loops.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2705
diff changeset
63 for (int i = 0, Z = zones.size(); i < Z; i++) {
2696
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 DischargeZone zone = zones.get(i);
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 String lower = zone.getLowerDischarge();
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 String upper = zone.getUpperDischarge();
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 if (lower.equals(upper)) {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 kvp[i] = new KVP(zone.getId(), lower);
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 else {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 kvp[i] = new KVP(zone.getId(), lower + " - " + upper);
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 return kvp;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
2705
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
81 @Override
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
82 protected String getLabelFor(
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
83 CallContext cc,
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
84 String parameterName,
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
85 int value
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
86 ) throws IllegalArgumentException
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
87 {
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
88 if (!testParameterName(parameterName)) {
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
89 throw new IllegalArgumentException(
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
90 "Invalid parameter for state: '" + parameterName + "'");
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
91 }
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
92
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
93 DischargeZone zone = DischargeZone.getDischargeZoneById(value);
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
94
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
95 if (zone == null) {
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
96 throw new IllegalArgumentException(
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
97 "Invalid id for DischargeZone: '" + value + "'");
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
98 }
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
99
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
100 String lo = zone.getLowerDischarge();
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
101 String hi = zone.getUpperDischarge();
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
102
3927
208a891c21b5 Partly fix issue871.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3759
diff changeset
103 return hi != null && !lo.equals(hi)
2705
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
104 ? lo + " - " + hi
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
105 : lo;
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
106 }
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
107
71f072d8b3d8 Improved the MultiIntArrayState, so the clients are able to display human readable strings for parameters and its values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 2696
diff changeset
108
2696
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 /**
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 * This method might be used to test, if a parameter name is handled by this
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 * state.
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 *
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 * @param parameterName The name of a parameter.
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 *
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 * @return true, if parameterName is one of <i>MAIN_CHANNEL</i> or
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 * <i>TOTAL_CHANNEL</i>. Otherwise false.
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 */
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 protected boolean testParameterName(String parameterName) {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119 if (parameterName == null || parameterName.length() == 0) {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 return false;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122 else if (parameterName.equals(MAIN_CHANNEL)) {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 return true;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 else if (parameterName.equals(TOTAL_CHANNEL)) {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 return true;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 else {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129 return false;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 /**
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 * Returns all discharge zones for a given river. The river information is
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136 * extracted from <i>artifact</i> using FLYSUtils.getRiver().
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 *
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 * @param artifact Needs to be a FLYSArtifact that stores a rivername.
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 *
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140 * @return a list of DischargeZones.
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 *
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 * @throws IllegalArgumentException if no river information is provided by
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 * <i>artifact</i>.
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 */
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 protected List<DischargeZone> getDischargeZones(Artifact artifact)
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 throws IllegalArgumentException
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 River river = FLYSUtils.getRiver((FLYSArtifact) artifact);
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 if (river == null) {
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 throw new IllegalArgumentException("No river found");
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 List<DischargeZone> zones = DischargeZone.getDischargeZones(river);
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 logger.debug("Found " + zones.size() + " DischargeZones.");
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 return zones;
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 }
1bc35de0b786 Improved the states for MINFO flow velocity calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org