Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RelativePointFacet.java @ 3068:2fc9d0c65dc9
Removed superfluous import.
flys-artifacts/trunk@4652 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 13 Jun 2012 13:00:34 +0000 |
parents | 703be13ffa74 |
children | 0f7abd95c6e2 |
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; |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
13 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
|
14 import de.intevation.flys.artifacts.model.FacetTypes; |
2758
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
15 import de.intevation.flys.artifacts.model.DurationCurveFacet; |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
16 import de.intevation.flys.artifacts.model.ReferenceCurveFacet; |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
17 import de.intevation.flys.artifacts.model.WQDay; |
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 /** |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
20 * 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
|
21 */ |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 public class RelativePointFacet |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 extends BlackboardDataFacet |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 implements FacetTypes { |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 |
2999
703be13ffa74
Cosmetics and ommitted fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2760
diff
changeset
|
26 /** Own logger. */ |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 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
|
28 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 /** Trivial Constructor. */ |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 public RelativePointFacet(String description) { |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 this(RELATIVE_POINT, description); |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
34 |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 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
|
36 this.name = name; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 this.description = description; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 this.index = 0; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 |
2758
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
42 protected Point2D calculateDurationCurvePoint(CallContext context, |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
43 StaticWKmsArtifact artifact) |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
44 { |
2760
23b4ff116015
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2758
diff
changeset
|
45 // 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
|
46 // 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
|
47 Object wqdays = null; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
48 double km = 0d; |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 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
|
50 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
|
51 if (providers.size() < 1) { |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
52 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
|
53 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 else { |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
55 wqdays = providers.get(0).provideData( |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
56 DurationCurveFacet.BB_DURATIONCURVE, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
57 null, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
58 context); |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 } |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
60 List<DataProvider> kmproviders = context. |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
61 getDataProvider(DurationCurveFacet.BB_DURATIONCURVE_KM); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
62 if (kmproviders.size() < 1) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
63 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
|
64 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
65 else { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
66 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
|
67 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
|
68 DurationCurveFacet.BB_DURATIONCURVE_KM, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
69 null, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
70 context).toString(); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
71 km = Double.valueOf(dckm); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
72 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
73 |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
74 if (wqdays != null) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
75 // Which W at this km? |
2758
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
76 double w = artifact.getWAtKmLin(artifact.getWKms(0), km); |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
77 if (w == -1) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
78 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
|
79 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
80 // 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
|
81 WQDay wqday = (WQDay) wqdays; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
82 // 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
|
83 int idx = 0; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
84 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
|
85 if (wIncreases) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
86 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
|
87 idx++; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
88 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
89 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
90 else { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
91 idx = wqday.size() -1; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
92 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
|
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 |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
97 double day = 0d; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
98 int mod = (wIncreases) ? -1 : +1; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
99 if (idx != 0 && idx <= wqday.size()-1) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
100 day = Linear.linear(w, wqday.getW(idx +mod), wqday.getW(idx), |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
101 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
|
102 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
103 |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
104 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
|
105 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
106 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
|
107 // 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
|
108 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
|
109 //return null; |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
110 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
111 |
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 /** |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
114 * 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
|
115 * 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
|
116 */ |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
117 public Point2D calculateReferenceCurvePoint(CallContext context, |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
118 StaticWKmsArtifact artifact) { |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 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
|
123 } |
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 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
|
126 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
|
127 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
128 providers = context. |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
129 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
|
130 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
|
131 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
|
132 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
133 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
|
134 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
|
135 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
136 logger.debug("Got s " + start + " e " + ends); |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
137 double startW = artifact.getWAtKmLin(artifact.getWKms(0), start.doubleValue()); |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
138 // TODO handle multiple ends. |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
139 double endW = artifact.getWAtKmLin(artifact.getWKms(0), ends[0]); |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
140 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
|
141 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
|
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 |
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 * 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
|
147 * |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
148 * @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
|
149 * @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
|
150 * |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
151 * @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
|
152 */ |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
153 @Override |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
154 public Object getData(Artifact artifact, CallContext context) { |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
155 StaticWKmsArtifact staticData = (StaticWKmsArtifact) artifact; |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
156 // 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
|
157 // 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
|
158 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
159 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
|
160 DurationCurveFacet.BB_DURATIONCURVE_KM).size() > 0) { |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
161 return calculateDurationCurvePoint(context, staticData); |
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 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
|
164 ReferenceCurveFacet.BB_REFERENCECURVE_STARTKM).size() > 0) { |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
165 return calculateReferenceCurvePoint(context, staticData); |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
166 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
167 |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
168 // TODO better signal failure. |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
169 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
|
170 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
171 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
172 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
173 /** |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
174 * 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
|
175 * @return a deep copy. |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
176 */ |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
177 @Override |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
178 public RelativePointFacet deepCopy() { |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
179 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
|
180 copy.set(this); |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
181 return copy; |
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 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
184 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |