Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/LocationDistanceSelect.java @ 3917:1ff257ab38ca
Rename fix_derivate to fix_derivate_curve to enable manual points on it
flys-artifacts/trunk@5597 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Wed, 26 Sep 2012 07:36:28 +0000 |
parents | 7467b091fb8e |
children | eb5564662e19 |
rev | line source |
---|---|
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.states; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
628
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
5 import gnu.trove.TDoubleArrayList; |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
6 |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
7 import de.intevation.artifacts.Artifact; |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifactdatabase.data.StateData; |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
10 |
3628
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
11 import de.intevation.flys.artifacts.FLYSArtifact; |
1055
61c051e53f9b
Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1051
diff
changeset
|
12 import de.intevation.flys.artifacts.WINFOArtifact; |
697
b972eba2ed8a
Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
692
diff
changeset
|
13 |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 /** |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 */ |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
722
diff
changeset
|
18 public class LocationDistanceSelect |
921
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
19 extends ComputationRangeState |
721
7298d58a1f5a
Generate facets for "Abflusskurven am Pegel". Not working by now. :-/
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
705
diff
changeset
|
20 { |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1055
diff
changeset
|
22 /** The logger used in this class. */ |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 private static Logger logger = Logger.getLogger(LocationDistanceSelect.class); |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
25 /** The name of the 'mode' field. */ |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
26 public static final String MODE = "ld_mode"; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
27 |
2235
ee5310134463
Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1838
diff
changeset
|
28 /** The name of the 'locations' field. */ |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
29 public static final String LOCATIONS = "ld_locations"; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
30 |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
31 |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 /** |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 * The default constructor that initializes an empty State object. |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 */ |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 public LocationDistanceSelect() { |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 } |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
660
627be3ca1ab6
code clean up in states
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
629
diff
changeset
|
39 @Override |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 protected String getUIProvider() { |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 return "location_distance_panel"; |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 } |
313
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
43 |
89bd0417418f
The location/distance state now writes default values into DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
136
diff
changeset
|
44 |
3265
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2235
diff
changeset
|
45 /** Validates the range (or location). */ |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
46 @Override |
1050
eccf966fb677
State engine: Removed CallContext from state validation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
921
diff
changeset
|
47 public boolean validate(Artifact artifact) |
322
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
48 throws IllegalArgumentException |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
49 { |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
50 logger.debug("LocationDistanceSelect.validate"); |
448d0dc64357
The inserted ranges (distance and WQ ranges) are validated in the feed() operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
313
diff
changeset
|
51 |
3628
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
52 FLYSArtifact flys = (FLYSArtifact)artifact; |
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
53 StateData mode = getData(flys, MODE); |
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
54 String mValue = mode != null ? (String)mode.getValue() : null; |
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
55 if (mValue != null) { |
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
56 if (mValue.equals("distance")) { |
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
57 return super.validate(flys); |
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
58 } |
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
59 else { |
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
60 return validateLocations(flys); |
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
61 } |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
62 } |
3628
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
63 return false; |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
64 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
65 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
66 |
3628
7467b091fb8e
Refactored location/distance state to use FLYSArtifact instead of WINFOArtifact.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3265
diff
changeset
|
67 protected boolean validateLocations(FLYSArtifact flys) |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
68 throws IllegalArgumentException |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
69 { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
70 StateData dValues = getData(flys, LOCATIONS); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
71 String values = dValues != null ? (String)dValues.getValue() : null; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
72 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
73 if (values == null || values.length() == 0) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
74 throw new IllegalArgumentException("error_empty_state"); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
75 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
76 |
921
610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
742
diff
changeset
|
77 double[] absMinMax = getMinMax(flys); |
627
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
78 double[] relMinMax = getMinMaxFromString(values); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
79 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
80 if (relMinMax[0] < absMinMax[0] || relMinMax[0] > absMinMax[1]) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
81 throw new IllegalArgumentException("error_feed_from_out_of_range"); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
82 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
83 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
84 if (relMinMax[1] > absMinMax[1] || relMinMax[1] < absMinMax[0]) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
85 throw new IllegalArgumentException("error_feed_to_out_of_range"); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
86 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
87 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
88 return true; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
89 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
90 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
91 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
92 /** |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
93 * Extracts the min/max values from String <i>s</i>. An |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
94 * IllegalArgumentException is thrown if there is a value that throws a |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
95 * NumberFormatException. |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
96 * |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
97 * @param s String that contains whitespace separated double values. |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
98 * |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
99 * @return a 2dmin array [min,max]. |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
100 */ |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
101 public static double[] getMinMaxFromString(String s) |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
102 throws IllegalArgumentException |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
103 { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
104 String[] values = s.split(" "); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
105 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
106 double[] minmax = new double[] { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
107 Double.MAX_VALUE, |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
108 -Double.MAX_VALUE }; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
109 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
110 for (String v: values) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
111 try { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
112 double value = Double.valueOf(v); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
113 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
114 minmax[0] = minmax[0] < value ? minmax[0] : value; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
115 minmax[1] = minmax[1] > value ? minmax[1] : value; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
116 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
117 catch (NumberFormatException nfe) { |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
118 throw new IllegalArgumentException( |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
119 "error_invalid_double_value"); |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
120 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
121 } |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
122 |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
123 return minmax; |
833290f16f09
ISSUE-85 (part I/III) Added further fields for the location/range state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
624
diff
changeset
|
124 } |
628
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
125 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
126 |
1055
61c051e53f9b
Moved WINFO specific stuff from FLYS into WINFO artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1051
diff
changeset
|
127 public static double[] getLocations(WINFOArtifact flys) { |
2235
ee5310134463
Cosmetics/care/refac.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1838
diff
changeset
|
128 StateData data = flys.getData(LOCATIONS); |
628
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
129 String value = data != null ? (String) data.getValue() : null; |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
130 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
131 if (value == null || value.length() == 0) { |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
132 logger.warn("No location data given."); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
133 return null; |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
134 } |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
135 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
136 String[] splitted = value.split(" "); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
137 TDoubleArrayList values = new TDoubleArrayList(); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
138 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
139 for (String split: splitted) { |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
140 try { |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
141 values.add(Double.valueOf(split)); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
142 } |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
143 catch (NumberFormatException nfe) { |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
144 logger.warn(nfe, nfe); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
145 } |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
146 } |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
147 |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
148 return values.toNativeArray(); |
51b69bca4560
ISSUE-85 (part III/III) Use the given kilometer values for the waterlevel computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
627
diff
changeset
|
149 } |
136
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 } |
2e510c998adb
New state for the location/distance input and some litte modifications of the DefaultState.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |