annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java @ 5501:9a14eac637ec

New Artifact and static state for sq relation.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 28 Mar 2013 15:17:02 +0100
parents 3c7e7d47939f
children
rev   line source
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
2196
5f3726f31f00 "Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2125
diff changeset
3 import de.intevation.artifactdatabase.state.Facet;
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import de.intevation.artifacts.Artifact;
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import de.intevation.artifacts.CallContext;
2122
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
6 import de.intevation.flys.artifacts.FLYSArtifact;
4045
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
7 import de.intevation.flys.artifacts.math.Linear;
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: 696
diff changeset
8 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
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
9 import de.intevation.flys.artifacts.model.extreme.ExtremeResult;
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
2196
5f3726f31f00 "Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2125
diff changeset
11 import org.apache.log4j.Logger;
2017
e384d78ff78b Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1721
diff changeset
12
1721
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1136
diff changeset
13 /**
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1136
diff changeset
14 * Facet of a Waterlevel (WQKms).
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1136
diff changeset
15 */
2122
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
16 public class WaterlevelFacet extends DataFacet {
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 private static Logger logger = Logger.getLogger(WaterlevelFacet.class);
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 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
21 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
22 }
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
722
4800230fba8a Improved situtation on rendering "Abflusskurve am Pegel". Not fully working, yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
24 public WaterlevelFacet(
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 722
diff changeset
25 int index,
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 722
diff changeset
26 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
27 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
28 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
29 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
30 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
31 ) {
2125
7a8f52267a5c Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2122
diff changeset
32 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
33 }
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
34
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
35 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
36 }
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
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
38 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
39 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
40 return ((ExtremeResult) res.getData()).getWQKms();
5444
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
41 else if (res.getData() instanceof WQKms[]) {
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
42 return (WQKms []) res.getData();
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
43 }
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
44 else {
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
45 logger.error("WaterlevelFacet got wrong data type " + res.getData());
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
46 return null;
70e0732bd4dd WaterlevelFacet: Avoid classcastexceptions.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4303
diff changeset
47 }
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
48 }
1136
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
49
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
50 /**
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
51 * Get waterlevel data.
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
52 * @return a WQKms at given index.
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
53 */
4045
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
54 @Override
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 public Object getData(Artifact artifact, CallContext context) {
2196
5f3726f31f00 "Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2125
diff changeset
56
5f3726f31f00 "Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2125
diff changeset
57 if (logger.isDebugEnabled()) {
5f3726f31f00 "Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2125
diff changeset
58 logger.debug("Get data for waterlevels at index: " + index +
5f3726f31f00 "Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2125
diff changeset
59 " /stateId: " + stateId);
5f3726f31f00 "Bezugslinienverfahren": Added facet classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2125
diff changeset
60 }
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
4045
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
62 if (artifact == null) {
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
63 logger.error("WaterlevelFacet.getData: artifact is null");
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
64 return null;
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
65 }
de6e2b933f33 Fix for ArrayIndexOutOfBoundsException (#818).
Christian Lins <christian.lins@intevation.de>
parents: 3597
diff changeset
66
3455
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
67 FLYSArtifact winfo = (FLYSArtifact) artifact;
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 705
diff changeset
69 CalculationResult res = (CalculationResult)
2122
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
70 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
71
3455
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
72 if (res == null) {
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
73 logger.error("WaterlevelFacet.getData: null result");
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
74 return null;
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
75 }
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
76
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
77 WQKms [] wqkms = getWQKms(res);
3597
deeda39ef01b Shortend overlong line. Simplified code.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3596
diff changeset
78 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
79
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
80 // Interpolation.
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
81 if (KM != null) {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
82 linearInterpolate(wqkms[index], (Double) KM);
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
83 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
84 else {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
85 logger.debug("Do not interpolate.");
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
86 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
87
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
88 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
89 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
90
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
91
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
92 /**
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
93 * Linear interpolation of WQKms.
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
94 * TODO rewrite.
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
95 * @return [w, q, km]
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
96 */
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
97 public WQKms linearInterpolate(WQKms wqkms, double km) {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
98 logger.debug("interpolate at given km (" + km + ")");
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
99
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
100 WQKms resultWQKms = new WQKms();
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
101 int size = wqkms.size();
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
102 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
103 int mod = kmIncreasing ? +1 : -1;
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
104 int idx = 0;
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
105 // 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
106 if (!kmIncreasing) {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
107 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
108 if (Math.abs(wqkms.getKm(idx) - km) < 0.01d) {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
109 resultWQKms.add(wqkms.getW(idx), wqkms.getQ(idx), wqkms.getKm(idx));
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
110 return resultWQKms;
3596
6aea625190da Handle former W calculations in fixA W/Q out.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3461
diff changeset
111 }
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
112 idx++;
3596
6aea625190da Handle former W calculations in fixA W/Q out.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3461
diff changeset
113 }
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
114 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
115 else {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
116 idx = size-1;
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
117 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
118 if (Math.abs(wqkms.getKm(idx) - km) < 0.01d) {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
119 resultWQKms.add(wqkms.getW(idx), wqkms.getQ(idx), wqkms.getKm(idx));
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
120 return resultWQKms;
3596
6aea625190da Handle former W calculations in fixA W/Q out.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3461
diff changeset
121 }
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
122 idx--;
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 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
125 if (Math.abs(wqkms.getKm(idx) - km) < 0.01d) {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
126 resultWQKms.add(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
127 return resultWQKms;
6aea625190da Handle former W calculations in fixA W/Q out.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3461
diff changeset
128 }
3455
1de62ac261f7 Let WaterlevelFacet handle FixationArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2196
diff changeset
129
5445
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
130 if ((idx != -1) && (idx < size) && (idx - mod != -1) && (idx - mod < size)) {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
131 double inW = Linear.linear(
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
132 km,
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
133 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
134 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
135 double inQ = Linear.linear(
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
136 km,
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
137 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
138 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
139 resultWQKms.add(inW, inQ, km);
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
140 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
141 else {
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
142 logger.debug("waterlevelfacet stuff " + idx + " size " + size + " mod: " + mod);
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
143 }
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
144
3c7e7d47939f WaterlevelFacet: Slight refactoring (more needed), fix flys/issue1149.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5444
diff changeset
145 return resultWQKms;
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146 }
1061
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
147
1136
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
148
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
149 /** Copy deeply. */
8da5f5a9ed3c Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1117
diff changeset
150 @Override
1061
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
151 public Facet deepCopy() {
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
152 WaterlevelFacet copy = new WaterlevelFacet();
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
153 copy.set(this);
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
154 copy.type = type;
2125
7a8f52267a5c Fix stateId/hash assignment in WaterlevelFacet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2122
diff changeset
155 copy.hash = hash;
2122
81312f84689a Refactored to easier enjoy benefits of caching.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2026
diff changeset
156 copy.stateId = stateId;
1061
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
157 return copy;
b1b0a0b61845 Made facets cloneable with the right type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 742
diff changeset
158 }
696
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 }
708b270dfd30 OutGenerators use now facets to fetch necessary data.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org