annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/WaterlevelFacet.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: 5445
diff changeset
9 package org.dive4elements.river.artifacts.model;
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5445
diff changeset
11 import org.dive4elements.artifactdatabase.state.Facet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5445
diff changeset
12 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5445
diff changeset
13 import org.dive4elements.artifacts.CallContext;
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
14 import org.dive4elements.river.artifacts.D4EArtifact;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5445
diff changeset
15 import org.dive4elements.river.artifacts.math.Linear;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5445
diff changeset
16 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5445
diff changeset
17 import org.dive4elements.river.artifacts.model.extreme.ExtremeResult;
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
19 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
20 import org.apache.logging.log4j.LogManager;
2017
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
21
1721
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1136
diff changeset
22 /**
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1136
diff changeset
23 * Facet of a Waterlevel (WQKms).
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1136
diff changeset
24 */
2122
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
25 public class WaterlevelFacet extends DataFacet {
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
27 private static Logger log = LogManager.getLogger(WaterlevelFacet.class);
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 public WaterlevelFacet(int index, String name, String description) {
2122
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
30 super(index, name, description, ComputeType.ADVANCE, null, null);
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 }
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
722
4800230fba8a Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
33 public WaterlevelFacet(
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 722
diff changeset
34 int index,
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 722
diff changeset
35 String name,
722
4800230fba8a Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
36 String description,
4800230fba8a Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
37 ComputeType type,
4800230fba8a Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
38 String stateID,
4800230fba8a Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
39 String hash
4800230fba8a Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
40 ) {
6485
2e0ba1f67900 WaterlevelFacet: Added a comment.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
41 // Pretty weird to change order of the two String params
2e0ba1f67900 WaterlevelFacet: Added a comment.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
42 // hash and stateID in comparison to parent. Its difficult to fix, now.
2125
7a8f52267a5c Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2122
diff changeset
43 super(index, name, description, type, hash, stateID);
2122
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
44 }
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
45
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
46 public WaterlevelFacet() {
722
4800230fba8a Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
47 }
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
3461
1481322efc02 FixA: Removed instanceof hack to fetch the WQKms of the fix realizations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3455
diff changeset
49 protected WQKms [] getWQKms(CalculationResult res) {
4303
d65cf8e40230 WaterlevelFacet: Deal with ExtremeResult if it is embedded in CalculationResult (instead of WQKms).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4045
diff changeset
50 if (res.getData() instanceof ExtremeResult)
d65cf8e40230 WaterlevelFacet: Deal with ExtremeResult if it is embedded in CalculationResult (instead of WQKms).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4045
diff changeset
51 return ((ExtremeResult) res.getData()).getWQKms();
5444
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
52 else if (res.getData() instanceof WQKms[]) {
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
53 return (WQKms []) res.getData();
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
54 }
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
55 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6485
diff changeset
56 log.error("WaterlevelFacet got wrong data type " + res.getData());
5444
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
57 return null;
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
58 }
3461
1481322efc02 FixA: Removed instanceof hack to fetch the WQKms of the fix realizations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3455
diff changeset
59 }
1136
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
60
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
61 /**
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
62 * Get waterlevel data.
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
63 * @return a WQKms at given index.
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
64 */
4045
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
65 @Override
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 public Object getData(Artifact artifact, CallContext context) {
2196
5f3726f31f00 "Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2125
diff changeset
67
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6485
diff changeset
68 if (log.isDebugEnabled()) {
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6485
diff changeset
69 log.debug("Get data for waterlevels at index: " + index +
2196
5f3726f31f00 "Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2125
diff changeset
70 " /stateId: " + stateId);
5f3726f31f00 "Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2125
diff changeset
71 }
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
4045
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
73 if (artifact == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6485
diff changeset
74 log.error("WaterlevelFacet.getData: artifact is null");
4045
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
75 return null;
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
76 }
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
77
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
78 D4EArtifact winfo = (D4EArtifact) artifact;
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 705
diff changeset
80 CalculationResult res = (CalculationResult)
2122
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
81 winfo.compute(context, hash, stateId, type, false);
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 705
diff changeset
82
3455
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
83 if (res == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6485
diff changeset
84 log.error("WaterlevelFacet.getData: null result");
3455
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
85 return null;
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
86 }
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
87
3461
1481322efc02 FixA: Removed instanceof hack to fetch the WQKms of the fix realizations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3455
diff changeset
88 WQKms [] wqkms = getWQKms(res);
3597
deeda39ef01b Shortend overlong line. Simplified code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3596
diff changeset
89 Object KM = context.getContextValue("currentKm");
3596
6aea625190da Handle former W calculations in fixA W/Q out.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3461
diff changeset
90
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
91 // Interpolation.
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
92 if (KM != null) {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
93 linearInterpolate(wqkms[index], (Double) KM);
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
94 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
95 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6485
diff changeset
96 log.debug("Do not interpolate.");
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
97 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
98
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
99 return wqkms != null ? wqkms[index] : null;
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
100 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
101
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
102
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
103 /**
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
104 * Linear interpolation of WQKms.
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
105 * TODO rewrite.
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
106 * @return [w, q, km]
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
107 */
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
108 public WQKms linearInterpolate(WQKms wqkms, double km) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6485
diff changeset
109 log.debug("interpolate at given km (" + km + ")");
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
110
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
111 WQKms resultWQKms = new WQKms();
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
112 int size = wqkms.size();
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
113 boolean kmIncreasing = wqkms.getKm(0) < wqkms.getKm(size-1);
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
114 int mod = kmIncreasing ? +1 : -1;
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
115 int idx = 0;
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
116 // Move idx to closest from one direction, check for match.
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
117 if (!kmIncreasing) {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
118 while (idx < size && wqkms.getKm(idx) < km) {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
119 if (Math.abs(wqkms.getKm(idx) - km) < 0.01d) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
120 resultWQKms.add(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
121 wqkms.getW(idx), wqkms.getQ(idx), wqkms.getKm(idx));
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
122 return resultWQKms;
3596
6aea625190da Handle former W calculations in fixA W/Q out.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3461
diff changeset
123 }
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
124 idx++;
3596
6aea625190da Handle former W calculations in fixA W/Q out.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3461
diff changeset
125 }
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
126 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
127 else {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
128 idx = size-1;
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
129 while (idx > 0 && wqkms.getKm(idx) > km) {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
130 if (Math.abs(wqkms.getKm(idx) - km) < 0.01d) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
131 resultWQKms.add(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
132 wqkms.getW(idx), wqkms.getQ(idx), wqkms.getKm(idx));
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
133 return resultWQKms;
3596
6aea625190da Handle former W calculations in fixA W/Q out.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3461
diff changeset
134 }
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
135 idx--;
3596
6aea625190da Handle former W calculations in fixA W/Q out.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3461
diff changeset
136 }
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
137 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
138 if (Math.abs(wqkms.getKm(idx) - km) < 0.01d) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
139 resultWQKms.add(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
140 wqkms.getW(idx), wqkms.getQ(idx), wqkms.getKm(idx));
3596
6aea625190da Handle former W calculations in fixA W/Q out.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3461
diff changeset
141 return resultWQKms;
6aea625190da Handle former W calculations in fixA W/Q out.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3461
diff changeset
142 }
3455
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
143
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
144 if ((idx != -1)
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
145 && (idx < size)
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
146 && (idx - mod != -1)
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
147 && (idx - mod < size)
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
148 ) {
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
149 double inW = Linear.linear(
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
150 km,
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
151 wqkms.getKm(idx), wqkms.getKm(idx - mod),
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
152 wqkms.getW(idx), wqkms.getW(idx - mod));
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
153 double inQ = Linear.linear(
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
154 km,
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
155 wqkms.getKm(idx), wqkms.getKm(idx - mod),
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
156 wqkms.getQ(idx), wqkms.getQ(idx - mod));
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
157 resultWQKms.add(inW, inQ, km);
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
158 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
159 else {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
160 log.debug("waterlevelfacet stuff " + idx
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
161 + " size " + size + " mod: " + mod);
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
162 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
163
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
164 return resultWQKms;
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 }
1061
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
166
1136
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
167
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
168 /** Copy deeply. */
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
169 @Override
1061
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
170 public Facet deepCopy() {
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
171 WaterlevelFacet copy = new WaterlevelFacet();
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
172 copy.set(this);
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
173 copy.type = type;
2125
7a8f52267a5c Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2122
diff changeset
174 copy.hash = hash;
2122
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
175 copy.stateId = stateId;
1061
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
176 return copy;
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
177 }
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 }
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org