Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalAnalysisFacet.java @ 4357:11cf29eb002c
FacetTypes: New type: exreme_wq_curve_base (for the Stuetz-Q-Poits).
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 02 Nov 2012 11:58:11 +0100 |
parents | 66f539df4e8b |
children |
rev | line source |
---|---|
3169
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model.fixings; |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
3610
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
3 import org.apache.log4j.Logger; |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
4 |
3169
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.artifacts.Artifact; |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.artifacts.CallContext; |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.flys.artifacts.FLYSArtifact; |
3203
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3171
diff
changeset
|
8 import de.intevation.flys.artifacts.model.CalculationResult; |
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3171
diff
changeset
|
9 import de.intevation.flys.artifacts.model.DataFacet; |
3169
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.flys.artifacts.model.FacetTypes; |
3203
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3171
diff
changeset
|
11 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
3169
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.utils.KMIndex; |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 /** |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 * Facet to show average W values for Q sectors. |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 * |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 */ |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 public class FixLongitudinalAnalysisFacet |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 extends DataFacet |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 implements FacetTypes { |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 /** House logger. */ |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 private static Logger logger = Logger.getLogger(FixLongitudinalAnalysisFacet.class); |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 /** Trivial Constructor. */ |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 public FixLongitudinalAnalysisFacet() { |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
28 } |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 public FixLongitudinalAnalysisFacet( |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 int ndx, |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 String name, |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 String description) |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 { |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 super( |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 ndx, |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 name, |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
39 description, |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 ComputeType.ADVANCE, |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 null, |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
42 null); |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 } |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 /** |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 * Returns the data this facet requires. |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 * |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 * @param artifact the owner artifact. |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 * @param context the CallContext. |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 * |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 * @return the data as KMIndex. |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 */ |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 @Override |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 public Object getData(Artifact artifact, CallContext context) { |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 logger.debug("FixLongitudinalAnalysisFacet.getData"); |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 if (artifact instanceof FLYSArtifact) { |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 FLYSArtifact flys = (FLYSArtifact)artifact; |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 CalculationResult res = |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 (CalculationResult) flys.compute(context, |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 ComputeType.ADVANCE, |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
64 false); |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 |
3415
e3c7a3228bc2
FixA: Renamed FixResult to FixAnalysisResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3408
diff
changeset
|
66 FixAnalysisResult result = (FixAnalysisResult) res.getData(); |
3169
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods(); |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 if (kmPeriods == null) { |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 logger.warn("No analysis periods found."); |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
71 return null; |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 } |
3610
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
73 int periodNdx = index >> 8; |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
74 int qwdNdx = index & 255; |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
75 KMIndex<QWD> resPeriods = |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
76 new KMIndex<QWD>(); |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
77 for (KMIndex.Entry<AnalysisPeriod[]> entry: kmPeriods) { |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
78 AnalysisPeriod ap = entry.getValue()[periodNdx]; |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
79 QWD[] qwds = ap.qwds; |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
80 for(int i = 0; i < qwds.length; i++) { |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
81 if(qwds[i].getIndex() == qwdNdx) { |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
82 resPeriods.add(entry.getKm(), qwds[i]); |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
83 } |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
84 } |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
85 } |
3169
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
86 |
3610
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
87 |
66f539df4e8b
Issue 716.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3415
diff
changeset
|
88 return resPeriods; |
3169
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
89 } |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
90 else { |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
91 logger.warn("Artifact is no instance of FLYSArtifact."); |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
92 return null; |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
93 } |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
94 } |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
95 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
96 |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
97 /** |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
98 * Create a deep copy of this Facet. |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
99 * @return a deep copy. |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
100 */ |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
101 @Override |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
102 public FixLongitudinalAnalysisFacet deepCopy() { |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
103 FixLongitudinalAnalysisFacet copy = new FixLongitudinalAnalysisFacet(); |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
104 copy.set(this); |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
105 return copy; |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
106 } |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 } |
b6da650b0718
FixA: Added longitudinal section chart.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |