Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/RelativePointFacet.java @ 2780:772d0c8100d3
Improved 'line-to-curve' rendering.
flys-artifacts/trunk@4519 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 25 May 2012 13:34:46 +0000 |
parents | 23b4ff116015 |
children | 703be13ffa74 |
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 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 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
|
27 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 /** Trivial Constructor. */ |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 public RelativePointFacet(String description) { |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 this(RELATIVE_POINT, description); |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
33 |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 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
|
35 this.name = name; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 this.description = description; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 this.index = 0; |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 |
2758
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
41 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
|
42 StaticWKmsArtifact artifact) |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
43 { |
2760
23b4ff116015
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2758
diff
changeset
|
44 // 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
|
45 // 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
|
46 Object wqdays = null; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
47 double km = 0d; |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 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
|
49 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
|
50 if (providers.size() < 1) { |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
51 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
|
52 } |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 else { |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
54 wqdays = providers.get(0).provideData( |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
55 DurationCurveFacet.BB_DURATIONCURVE, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
56 null, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
57 context); |
2743
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 } |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
59 List<DataProvider> kmproviders = context. |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
60 getDataProvider(DurationCurveFacet.BB_DURATIONCURVE_KM); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
61 if (kmproviders.size() < 1) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
62 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
|
63 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
64 else { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
65 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
|
66 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
|
67 DurationCurveFacet.BB_DURATIONCURVE_KM, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
68 null, |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
69 context).toString(); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
70 km = Double.valueOf(dckm); |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
71 } |
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 if (wqdays != null) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
74 // 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
|
75 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
|
76 if (w == -1) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
77 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
|
78 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
79 // 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
|
80 WQDay wqday = (WQDay) wqdays; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
81 // 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
|
82 int idx = 0; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
83 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
|
84 if (wIncreases) { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
85 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
|
86 idx++; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
87 } |
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 else { |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
90 idx = wqday.size() -1; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
91 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
|
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 |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
96 double day = 0d; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
97 int mod = (wIncreases) ? -1 : +1; |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
98 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
|
99 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
|
100 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
|
101 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
102 |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
103 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
|
104 } |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
105 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
|
106 // 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
|
107 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
|
108 //return null; |
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 |
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 * 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
|
114 * 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
|
115 */ |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
116 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
|
117 StaticWKmsArtifact artifact) { |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
118 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
|
119 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
|
120 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
|
121 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
|
122 } |
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 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
|
125 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
|
126 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
127 providers = context. |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
128 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
|
129 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
|
130 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
|
131 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
132 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
|
133 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
|
134 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
135 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
|
136 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
|
137 // 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
|
138 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
|
139 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
|
140 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
|
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 /** |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
145 * 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
|
146 * |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
147 * @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
|
148 * @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
|
149 * |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
150 * @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
|
151 */ |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
152 @Override |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
153 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
|
154 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
|
155 // 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
|
156 // 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
|
157 |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
158 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
|
159 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
|
160 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
|
161 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
162 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
|
163 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
|
164 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
|
165 } |
b05faaa9099b
Create points for ref.curve in facet, handle these in generator.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2747
diff
changeset
|
166 |
2747
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
167 // TODO better signal failure. |
94c6f4ad9b98
Handle case of points in wqday (durationcurve) scenarios.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2743
diff
changeset
|
168 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
|
169 } |
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 * 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
|
174 * @return a deep copy. |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
175 */ |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
176 @Override |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
177 public RelativePointFacet deepCopy() { |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
178 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
|
179 copy.set(this); |
10e6400d4166
Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
180 return copy; |
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |