Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/RelativePointFacet.java @ 9425:3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
Also allows to have acces to the potentially already computed artifact result via its normal computation cache.
author | gernotbelger |
---|---|
date | Fri, 17 Aug 2018 15:31:02 +0200 |
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 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 import org.apache.log4j.Logger; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5797
diff
changeset
|
16 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5797
diff
changeset
|
17 import org.dive4elements.artifacts.CallContext; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5797
diff
changeset
|
18 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
|
19 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5797
diff
changeset
|
20 import org.dive4elements.river.artifacts.StaticWKmsArtifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5797
diff
changeset
|
21 import org.dive4elements.river.artifacts.StaticWQKmsArtifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5797
diff
changeset
|
22 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
|
23 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 /** |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
25 * 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
|
26 */ |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 public class RelativePointFacet |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 extends BlackboardDataFacet |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 implements FacetTypes { |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
31 /** Own log. */ |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
32 private static Logger log = Logger.getLogger(RelativePointFacet.class); |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 /** Trivial Constructor. */ |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 public RelativePointFacet(String description) { |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 this(RELATIVE_POINT, description); |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
39 |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 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
|
41 this.name = name; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 this.description = description; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 this.index = 0; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 } |
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 |
2758
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
47 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
|
48 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
|
49 { |
2760
23b4ff116015
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2758
diff
changeset
|
50 // 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
|
51 // 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
|
52 Object wqdays = null; |
3442
cd5eb8f5f6f1
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
53 double km = 0d; |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 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
|
55 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
|
56 if (providers.size() < 1) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
57 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
|
58 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 else { |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
60 wqdays = providers.get(0).provideData( |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
61 DurationCurveFacet.BB_DURATIONCURVE, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
62 null, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
63 context); |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 } |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
65 List<DataProvider> kmproviders = context. |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
66 getDataProvider(DurationCurveFacet.BB_DURATIONCURVE_KM); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
67 if (kmproviders.size() < 1) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
68 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
|
69 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
70 else { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
71 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
|
72 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
|
73 DurationCurveFacet.BB_DURATIONCURVE_KM, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
74 null, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
75 context).toString(); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
76 km = Double.valueOf(dckm); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
77 } |
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 if (wqdays != null) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
80 // 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
|
81 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
|
82 if (w == -1) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
83 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
|
84 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
85 // 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
|
86 WQDay wqday = (WQDay) wqdays; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
87 // 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
|
88 int idx = 0; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
89 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
|
90 if (wIncreases) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
91 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
|
92 idx++; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
93 } |
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 else { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
96 idx = wqday.size() -1; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
97 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
|
98 idx--; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
99 } |
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 double day = 0d; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
103 int mod = (wIncreases) ? -1 : +1; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
104 if (idx != 0 && idx <= wqday.size()-1) { |
3442
cd5eb8f5f6f1
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
105 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
|
106 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
|
107 } |
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 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
|
110 } |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
111 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
|
112 // 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
|
113 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
|
114 } |
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 * 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
|
119 * 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
|
120 */ |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
121 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
|
122 WKms wKms) { |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
123 |
2758
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
124 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
|
125 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
|
126 if (providers.size() < 1) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
127 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
|
128 } |
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 Double start = (Double) providers.get(0). |
8856 | 131 provideData( |
132 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
|
133 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
134 providers = context. |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
135 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
|
136 if (providers.size() < 1) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
137 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
|
138 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
139 double[] ends = (double[]) providers.get(0). |
8856 | 140 provideData( |
141 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
|
142 |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
143 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
|
144 |
8856 | 145 double startW = StaticWKmsArtifact.getWAtKmLin( |
146 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
|
147 // TODO handle multiple ends. |
5797
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
148 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
|
149 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
|
150 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
|
151 } |
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 * 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
|
156 * |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
157 * @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
|
158 * @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
|
159 * |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
160 * @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
|
161 */ |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
162 @Override |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
163 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
|
164 WKms wKms = null; |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
165 if (artifact instanceof StaticWKmsArtifact) { |
9425
3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents:
8856
diff
changeset
|
166 wKms = ((StaticWKmsArtifact) artifact).getWKms(); |
5797
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
167 } |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
168 else if (artifact instanceof StaticWQKmsArtifact) { |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
169 wKms = ((StaticWQKmsArtifact) artifact).getWQKms(); |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
170 } |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
171 else { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
172 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
|
173 return null; |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
174 } |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
175 |
2758
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
176 // 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
|
177 // 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
|
178 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
179 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
|
180 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
|
181 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
|
182 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
183 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
|
184 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
|
185 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
|
186 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
187 |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
188 // TODO better signal failure. |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
189 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
|
190 } |
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 * 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
|
195 * @return a deep copy. |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
196 */ |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
197 @Override |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
198 public RelativePointFacet deepCopy() { |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
199 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
|
200 copy.set(this); |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
201 return copy; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
202 } |
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |