Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RelativePointFacet.java @ 5798:febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 24 Apr 2013 08:21:52 +0200 |
parents | cce12c06466f |
children |
rev | line source |
---|---|
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 import java.util.List; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 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
|
5 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 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
|
7 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.Artifact; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.CallContext; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.DataProvider; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.artifacts.StaticWKmsArtifact; |
5797
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
13 import de.intevation.flys.artifacts.StaticWQKmsArtifact; |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
14 import de.intevation.flys.artifacts.math.Linear; |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 /** |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
17 * 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
|
18 */ |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 public class RelativePointFacet |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 extends BlackboardDataFacet |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 implements FacetTypes { |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 |
2999
703be13ffa74
Cosmetics and ommitted fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2760
diff
changeset
|
23 /** Own logger. */ |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 private static Logger logger = Logger.getLogger(RelativePointFacet.class); |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 /** Trivial Constructor. */ |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 public RelativePointFacet(String description) { |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 this(RELATIVE_POINT, description); |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
31 |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 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
|
33 this.name = name; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 this.description = description; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 this.index = 0; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 } |
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 |
2758
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
39 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
|
40 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
|
41 { |
2760
23b4ff116015
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2758
diff
changeset
|
42 // 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
|
43 // 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
|
44 Object wqdays = null; |
3442
cd5eb8f5f6f1
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
45 double km = 0d; |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 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
|
47 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
|
48 if (providers.size() < 1) { |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
49 logger.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
|
50 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 else { |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
52 wqdays = providers.get(0).provideData( |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
53 DurationCurveFacet.BB_DURATIONCURVE, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
54 null, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
55 context); |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 } |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
57 List<DataProvider> kmproviders = context. |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
58 getDataProvider(DurationCurveFacet.BB_DURATIONCURVE_KM); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
59 if (kmproviders.size() < 1) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
60 logger.warn("Could not find durationcurve.km data provider."); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
61 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
62 else { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
63 logger.debug("Found durationcurve.km data provider."); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
64 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
|
65 DurationCurveFacet.BB_DURATIONCURVE_KM, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
66 null, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
67 context).toString(); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
68 km = Double.valueOf(dckm); |
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 |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
71 if (wqdays != null) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
72 // 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
|
73 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
|
74 if (w == -1) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
75 logger.warn("w is -1, already bad sign!"); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
76 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
77 // 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
|
78 WQDay wqday = (WQDay) wqdays; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
79 // 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
|
80 int idx = 0; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
81 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
|
82 if (wIncreases) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
83 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
|
84 idx++; |
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 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
87 else { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
88 idx = wqday.size() -1; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
89 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
|
90 idx--; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
91 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
92 } |
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 double day = 0d; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
95 int mod = (wIncreases) ? -1 : +1; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
96 if (idx != 0 && idx <= wqday.size()-1) { |
3442
cd5eb8f5f6f1
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3317
diff
changeset
|
97 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
|
98 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
|
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 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
|
102 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
103 logger.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
|
104 // 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
|
105 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
|
106 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
107 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
108 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
109 /** |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
110 * 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
|
111 * 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
|
112 */ |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
113 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
|
114 WKms wKms) { |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
115 |
2758
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
116 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
|
117 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
|
118 if (providers.size() < 1) { |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
119 logger.warn("Could not find reference curve startkm data provider."); |
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 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
122 Double start = (Double) providers.get(0). |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
123 provideData(ReferenceCurveFacet.BB_REFERENCECURVE_STARTKM, null, context); |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
124 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
125 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_ENDKMS); |
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) { |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
128 logger.warn("Could not find reference curve endkms data provider."); |
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[] ends = (double[]) providers.get(0). |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
131 provideData(ReferenceCurveFacet.BB_REFERENCECURVE_ENDKMS, null, context); |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
132 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
133 logger.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
|
134 |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
135 double startW = StaticWKmsArtifact.getWAtKmLin(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
|
136 // TODO handle multiple ends. |
5797
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
137 double endW = StaticWKmsArtifact.getWAtKmLin(wKms, ends[0]); |
2758
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
138 logger.debug("Gotw s " + startW + " e " + endW); |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
139 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
|
140 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
141 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
142 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
143 /** |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
144 * 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
|
145 * |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
146 * @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
|
147 * @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
|
148 * |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
149 * @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
|
150 */ |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
151 @Override |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
152 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
|
153 WKms wKms = null; |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
154 if (artifact instanceof StaticWKmsArtifact) { |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
155 wKms = ((StaticWKmsArtifact) artifact).getWKms(0); |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
156 } |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
157 else if (artifact instanceof StaticWQKmsArtifact) { |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
158 wKms = ((StaticWQKmsArtifact) artifact).getWQKms(); |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
159 } |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
160 else { |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
161 logger.error("Cannot handle Artifact to create relative point."); |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
162 return null; |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
163 } |
cce12c06466f
RelativePointFacet: Through minor refactoring prepared to used StaticWQKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3442
diff
changeset
|
164 |
2758
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
165 // 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
|
166 // 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
|
167 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
168 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
|
169 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
|
170 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
|
171 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
172 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
|
173 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
|
174 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
|
175 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
176 |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
177 // TODO better signal failure. |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
178 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
|
179 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
180 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
181 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
182 /** |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
183 * 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
|
184 * @return a deep copy. |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
185 */ |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
186 @Override |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
187 public RelativePointFacet deepCopy() { |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
188 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
|
189 copy.set(this); |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
190 return copy; |
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |