annotate artifacts/src/main/java/org/dive4elements/river/artifacts/access/ExtremeAccess.java @ 5863:4897a58c8746

River artifacts: Added new copyright headers.
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 28 Apr 2013 14:40:59 +0200
parents 5aa05a7a34b7
children 59ff03ff48f1
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
6 * documentation coming with Dive4Elements River for details.
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4825
diff changeset
9 package org.dive4elements.river.artifacts.access;
4825
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4333
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4825
diff changeset
11 import org.dive4elements.artifacts.CallContext;
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4825
diff changeset
13 import org.dive4elements.river.artifacts.FLYSArtifact;
3776
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
14
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4825
diff changeset
15 import org.dive4elements.river.artifacts.model.RangeWithValues;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4825
diff changeset
16
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4825
diff changeset
17 import org.dive4elements.river.utils.DoubleUtil;
3776
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
18
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
19 import java.util.ArrayList;
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
20 import java.util.List;
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
21
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 import org.apache.log4j.Logger;
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23
4040
363445873737 Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3777
diff changeset
24 /** Access data used for extreme value analysis. */
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 public class ExtremeAccess
4825
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4333
diff changeset
26 extends RangeAccess
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 {
4332
0545002e112c ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4272
diff changeset
28 /** Our private logger. */
0545002e112c ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4272
diff changeset
29 private static Logger logger = Logger.getLogger(ExtremeAccess.class);
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
3776
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
31 protected Long start;
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
32 protected Long end;
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
33
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
34 protected Double percent;
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
35
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
36 protected String function;
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
37
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
38 protected List<RangeWithValues> ranges;
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
39
4052
6d8c7a00e74e Do cumentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4040
diff changeset
40
4825
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4333
diff changeset
41 public ExtremeAccess(FLYSArtifact artifact, CallContext context) {
f8217f1fef2e ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4333
diff changeset
42 super(artifact, context);
3776
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
43 }
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
44
4332
0545002e112c ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4272
diff changeset
45
0545002e112c ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4272
diff changeset
46 /** Returns the percent given. */
3776
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
47 public Double getPercent() {
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
48
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
49 if (percent == null) {
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
50 percent = getDouble("percent");
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
51 }
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
52
4332
0545002e112c ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4272
diff changeset
53 if (logger.isDebugEnabled()) {
0545002e112c ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4272
diff changeset
54 logger.debug("percent: '" + percent + "'");
3776
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
55 }
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
56
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
57 return percent;
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
58 }
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
59
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
60 public String getFunction() {
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
61 if (function == null) {
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
62 function = getString("function");
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
63 }
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
64
4332
0545002e112c ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4272
diff changeset
65 if (logger.isDebugEnabled()) {
0545002e112c ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4272
diff changeset
66 logger.debug("function: '" + function + "'");
3776
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
67 }
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
68
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
69 return function;
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
70 }
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
71
4333
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
72
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
73 /** Find first RangeWithValues for which the given location
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
74 * is within the range and return its values.
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
75 * @return values of first suitable rangewithvalues or null.
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
76 */
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
77 public double[] getValuesForRange(double location) {
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
78 logger.debug("ExtemeAcces.getValuesForRange");
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
79 for (RangeWithValues rangeValues: getRanges()) {
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
80 if (rangeValues.inside(location)) {
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
81 return rangeValues.getValues();
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
82 }
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
83 }
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
84 return null;
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
85 }
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
86
2d3f8af87b7b ExtremeAccess: Added helper method to find the values for (the range of) a km.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4332
diff changeset
87
3776
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
88 public List<RangeWithValues> getRanges() {
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
89
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
90 if (ranges == null) {
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
91 String rangesS = getString("ranges");
4272
270f3ac8a82e In ExtremeAccess, fix typo that lead to incorrect null-check.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4052
diff changeset
92 if (rangesS == null) {
3776
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
93 return null;
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
94 }
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
95 ranges = new ArrayList<RangeWithValues>();
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
96 DoubleUtil.parseSegments(rangesS, new DoubleUtil.SegmentCallback() {
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
97 @Override
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
98 public void newSegment(double from, double to, double [] values) {
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
99 ranges.add(new RangeWithValues(from, to, values));
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
100 }
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
101 });
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
102 }
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
103
4332
0545002e112c ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4272
diff changeset
104 if (logger.isDebugEnabled()) {
0545002e112c ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4272
diff changeset
105 logger.debug("ranges: " + ranges);
3776
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
106 }
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
107
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
108 return ranges;
1ddbf66a2b0a Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3775
diff changeset
109 }
3775
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 }
d52c4ca93ffb More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org