Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/access/ExtremeAccess.java @ 9801:1d7a72a50183 3.2.x tip
Assume Compose V2, consistently
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 23 Nov 2023 10:14:13 +0100 |
parents | 0a5239a1e46e |
children |
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 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
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 |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
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 |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
11 import org.dive4elements.river.artifacts.D4EArtifact; |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
12 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4825
diff
changeset
|
13 import org.dive4elements.river.artifacts.model.RangeWithValues; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4825
diff
changeset
|
14 |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4825
diff
changeset
|
15 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
|
16 |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
17 import java.util.ArrayList; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
18 import java.util.List; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
19 |
9726 | 20 import org.apache.logging.log4j.Logger; |
21 import org.apache.logging.log4j.LogManager; | |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
4040
363445873737
Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3777
diff
changeset
|
23 /** 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
|
24 public class ExtremeAccess |
4825
f8217f1fef2e
ExtremeAccess, RangeAccess and callers: Refactored, moved getStep to RangeAccess.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4333
diff
changeset
|
25 extends RangeAccess |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6102
diff
changeset
|
27 /** Our private log. */ |
9726 | 28 private static Logger log = LogManager.getLogger(ExtremeAccess.class); |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
30 protected Long start; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
31 protected Long end; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
32 |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
33 protected Double percent; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
34 |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
35 protected String function; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
36 |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
37 protected List<RangeWithValues> ranges; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
38 |
4052
6d8c7a00e74e
Do cumentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4040
diff
changeset
|
39 |
6101
a0078e5e3b39
Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
40 public ExtremeAccess(D4EArtifact artifact) { |
a0078e5e3b39
Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
41 super(artifact); |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
42 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
43 |
4332
0545002e112c
ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4272
diff
changeset
|
44 |
0545002e112c
ExtremeAccess: Renamed log to logger, documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4272
diff
changeset
|
45 /** Returns the percent given. */ |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
46 public Double getPercent() { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
47 |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
48 if (percent == null) { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
49 percent = getDouble("percent"); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
50 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
51 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6102
diff
changeset
|
52 if (log.isDebugEnabled()) { |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6102
diff
changeset
|
53 log.debug("percent: '" + percent + "'"); |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
54 } |
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 return percent; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
57 } |
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 public String getFunction() { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
60 if (function == null) { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
61 function = getString("function"); |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
62 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
63 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6102
diff
changeset
|
64 if (log.isDebugEnabled()) { |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6102
diff
changeset
|
65 log.debug("function: '" + function + "'"); |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
66 } |
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 return function; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
69 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
70 |
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
|
71 |
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 /** 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
|
73 * 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
|
74 * @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
|
75 */ |
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 public double[] getValuesForRange(double location) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6102
diff
changeset
|
77 log.debug("ExtemeAcces.getValuesForRange"); |
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
|
78 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
|
79 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
|
80 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
|
81 } |
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 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
|
84 } |
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 |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
87 public List<RangeWithValues> getRanges() { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
88 |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
89 if (ranges == null) { |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
90 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
|
91 if (rangesS == null) { |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
92 return null; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
93 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
94 ranges = new ArrayList<RangeWithValues>(); |
8856 | 95 DoubleUtil.parseSegments( |
96 rangesS, | |
97 new DoubleUtil.SegmentCallback() { | |
98 @Override | |
99 public void newSegment( | |
100 double from, | |
101 double to, | |
102 double [] values | |
103 ) { | |
104 ranges.add(new RangeWithValues(from, to, values)); | |
105 } | |
106 }); | |
3776
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 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6102
diff
changeset
|
109 if (log.isDebugEnabled()) { |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6102
diff
changeset
|
110 log.debug("ranges: " + ranges); |
3776
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
111 } |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
112 |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
113 return ranges; |
1ddbf66a2b0a
Implemented the access for 'Auslagerung extremer Wasserspiegellagen'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3775
diff
changeset
|
114 } |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 } |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |