annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/RelativePointFacet.java @ 9726:0a5239a1e46e 3.2.x

Upgrade to Log4j 2
author Tom Gottfried <tom@intevation.de>
date Wed, 02 Mar 2022 10:26:50 +0100
parents 5e38e2924c07
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: 5863
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: 5863
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: 5797
diff changeset
9 package org.dive4elements.river.artifacts.model;
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import java.util.List;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 import java.awt.geom.Point2D;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
14 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
15 import org.apache.logging.log4j.LogManager;
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5797
diff changeset
17 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5797
diff changeset
18 import org.dive4elements.artifacts.CallContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5797
diff changeset
19 import org.dive4elements.artifacts.DataProvider;
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5797
diff changeset
21 import org.dive4elements.river.artifacts.StaticWKmsArtifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5797
diff changeset
22 import org.dive4elements.river.artifacts.StaticWQKmsArtifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5797
diff changeset
23 import org.dive4elements.river.artifacts.math.Linear;
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
24
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
25 /**
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
26 * Facet to access a point.
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
27 */
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28 public class RelativePointFacet
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29 extends BlackboardDataFacet
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30 implements FacetTypes {
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
31
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
32 /** Own log. */
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
33 private static Logger log = LogManager.getLogger(RelativePointFacet.class);
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35 /** Trivial Constructor. */
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 public RelativePointFacet(String description) {
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 this(RELATIVE_POINT, description);
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
40
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 public RelativePointFacet(String name, String description) {
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 this.name = name;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 this.description = description;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 this.index = 0;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
48 protected Point2D calculateDurationCurvePoint(CallContext context,
5797
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
49 WKms wKms)
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
50 {
2760
23b4ff116015 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2758
diff changeset
51 // TODO here and in reference curve calc: Do warn if more than 1
23b4ff116015 Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2758
diff changeset
52 // provider found or (way better) handle it.
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
53 Object wqdays = null;
3442
cd5eb8f5f6f1 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
54 double km = 0d;
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 List<DataProvider> providers = context.
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
56 getDataProvider(DurationCurveFacet.BB_DURATIONCURVE);
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 if (providers.size() < 1) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
58 log.warn("Could not find durationcurve data provider.");
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 else {
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
61 wqdays = providers.get(0).provideData(
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
62 DurationCurveFacet.BB_DURATIONCURVE,
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
63 null,
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
64 context);
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65 }
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
66 List<DataProvider> kmproviders = context.
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
67 getDataProvider(DurationCurveFacet.BB_DURATIONCURVE_KM);
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
68 if (kmproviders.size() < 1) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
69 log.warn("Could not find durationcurve.km data provider.");
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
70 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
71 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
72 log.debug("Found durationcurve.km data provider.");
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
73 String dckm = providers.get(0).provideData(
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
74 DurationCurveFacet.BB_DURATIONCURVE_KM,
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
75 null,
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
76 context).toString();
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
77 km = Double.valueOf(dckm);
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
78 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
79
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
80 if (wqdays != null) {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
81 // Which W at this km?
5797
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
82 double w = StaticWKmsArtifact.getWAtKmLin(wKms, km);
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
83 if (w == -1) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
84 log.warn("w is -1, already bad sign!");
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
85 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
86 // Where is this W passed by in the wq-curve?
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
87 WQDay wqday = (WQDay) wqdays;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
88 // Doing a linear Day Of KM.
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
89 int idx = 0;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
90 boolean wIncreases = wqday.getW(0) < wqday.getW(wqday.size()-1);
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
91 if (wIncreases) {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
92 while (idx < wqday.size() && wqday.getW(idx) < w) {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
93 idx++;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
94 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
95 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
96 else {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
97 idx = wqday.size() -1;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
98 while (idx > 0 && wqday.getW(idx) > w) {
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
99 idx--;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
100 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
101 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
102
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
103 double day = 0d;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
104 int mod = (wIncreases) ? -1 : +1;
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
105 if (idx != 0 && idx <= wqday.size()-1) {
3442
cd5eb8f5f6f1 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3317
diff changeset
106 day = Linear.linear(w, wqday.getW(idx+mod), wqday.getW(idx),
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
107 wqday.getDay(idx+mod), wqday.getDay(idx));
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
108 }
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
109
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
110 return new Point2D.Double((double) day, w);
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
111 }
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
112 log.warn("not wqkms / w / day found");
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
113 // TODO better signal failure.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
114 return new Point2D.Double(0d, 0d);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
115 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
116
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
117
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
118 /**
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
119 * Calculate a reference curve point, that is, a point made of
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
120 * the Ws from start and end km param of the reference curve.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
121 */
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
122 public Point2D calculateReferenceCurvePoint(CallContext context,
5797
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
123 WKms wKms) {
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
124
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
125 List<DataProvider> providers = context.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
126 getDataProvider(ReferenceCurveFacet.BB_REFERENCECURVE_STARTKM);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
127 if (providers.size() < 1) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
128 log.warn("Could not find reference curve startkm data provider.");
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
129 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
130
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
131 Double start = (Double) providers.get(0).
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
132 provideData(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
133 ReferenceCurveFacet.BB_REFERENCECURVE_STARTKM, null, context);
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
134
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
135 providers = context.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
136 getDataProvider(ReferenceCurveFacet.BB_REFERENCECURVE_ENDKMS);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
137 if (providers.size() < 1) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
138 log.warn("Could not find reference curve endkms data provider.");
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
139 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
140 double[] ends = (double[]) providers.get(0).
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
141 provideData(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
142 ReferenceCurveFacet.BB_REFERENCECURVE_ENDKMS, null, context);
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
143
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
144 log.debug("Got s " + start + " e " + ends);
5797
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
145
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
146 double startW = StaticWKmsArtifact.getWAtKmLin(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
147 wKms, start.doubleValue());
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
148 // TODO handle multiple ends.
5797
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
149 double endW = StaticWKmsArtifact.getWAtKmLin(wKms, ends[0]);
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
150 log.debug("Gotw s " + startW + " e " + endW);
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
151 return new Point2D.Double(startW, endW);
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
152 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
153
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
154
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
155 /**
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
156 * Returns the data this facet requires.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
157 *
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
158 * @param artifact the owner artifact.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
159 * @param context the CallContext (ignored).
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
160 *
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
161 * @return the data.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
162 */
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
163 @Override
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
164 public Object getData(Artifact artifact, CallContext context) {
5797
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
165 WKms wKms = null;
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
166 if (artifact instanceof StaticWKmsArtifact) {
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
167 wKms = ((StaticWKmsArtifact) artifact).getWKms(0);
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
168 }
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
169 else if (artifact instanceof StaticWQKmsArtifact) {
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
170 wKms = ((StaticWQKmsArtifact) artifact).getWQKms();
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
171 }
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
172 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
173 log.error("Cannot handle Artifact to create relative point.");
5797
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
174 return null;
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
175 }
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
176
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
177 // Find out whether we live in a duration curve context, there we would
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
178 // provide only a single point.
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
179
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
180 if (context.getDataProvider(
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
181 DurationCurveFacet.BB_DURATIONCURVE_KM).size() > 0) {
5797
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
182 return calculateDurationCurvePoint(context, wKms);
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
183 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
184 else if (context.getDataProvider(
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
185 ReferenceCurveFacet.BB_REFERENCECURVE_STARTKM).size() > 0) {
5797
cce12c06466f RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3442
diff changeset
186 return calculateReferenceCurvePoint(context, wKms);
2758
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
187 }
b05faaa9099b Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2747
diff changeset
188
2747
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
189 // TODO better signal failure.
94c6f4ad9b98 Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
190 return new Point2D.Double(0d, 0d);
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
191 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
192
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
193
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
194 /**
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
195 * Create a deep copy of this Facet.
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
196 * @return a deep copy.
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
197 */
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
198 @Override
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
199 public RelativePointFacet deepCopy() {
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
200 RelativePointFacet copy = new RelativePointFacet(description);
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
201 copy.set(this);
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
202 return copy;
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
203 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
204 }
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
205 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org