Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java @ 5565:a44a3f997ec8
Cleanup whitespace. Removed unused variable.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Apr 2013 09:03:34 +0200 |
parents | acfd48384835 |
children |
rev | line source |
---|---|
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model.fixings; |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
2 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifacts.Artifact; |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 import de.intevation.artifacts.CallContext; |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.flys.artifacts.FLYSArtifact; |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 |
3408
50d61a2494cb
FixA: Renamed FixationArtifactAccess to FixAnalysisAccess
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3203
diff
changeset
|
8 import de.intevation.flys.artifacts.access.FixAnalysisAccess; |
3203
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3131
diff
changeset
|
9 |
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3131
diff
changeset
|
10 import de.intevation.flys.artifacts.model.CalculationResult; |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.flys.artifacts.model.FacetTypes; |
3203
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3131
diff
changeset
|
12 |
3467
b9c2becbcc9e
Towards issue745 (lines for averages in deltawt).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3415
diff
changeset
|
13 import de.intevation.flys.artifacts.model.QWDDateRange; |
b9c2becbcc9e
Towards issue745 (lines for averages in deltawt).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3415
diff
changeset
|
14 |
3203
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3131
diff
changeset
|
15 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.flys.utils.KMIndex; |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 |
3203
1b9f791937c3
Moved FixationArtifactAccess to new access package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3131
diff
changeset
|
19 import org.apache.log4j.Logger; |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
20 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
21 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
22 /** |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
23 * Facet to show average W values for Q sectors. |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
24 * |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
26 */ |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
27 public class FixAvSectorFacet |
4442
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3467
diff
changeset
|
28 extends FixingsFacet |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
29 implements FacetTypes { |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 /** House logger. */ |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 private static Logger logger = Logger.getLogger(FixAvSectorFacet.class); |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 /** Trivial Constructor. */ |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 public FixAvSectorFacet() { |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 } |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
38 |
3043
22da13d1b180
Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3035
diff
changeset
|
39 public FixAvSectorFacet(int ndx, String name, String description) { |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
40 super( |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
41 ndx, |
3043
22da13d1b180
Added facet for derivate curve and fixed facet names.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3035
diff
changeset
|
42 name, |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
43 description, |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
44 ComputeType.ADVANCE, |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
45 null, |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
46 null); |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
47 } |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
48 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
49 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
50 /** |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
51 * Returns the data this facet requires. |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 * |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
53 * @param artifact the owner artifact. |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
54 * @param context the CallContext. |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
55 * |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
56 * @return the data as QWD array (QWD[]). |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
57 */ |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
58 @Override |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
59 public Object getData(Artifact artifact, CallContext context) { |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
60 logger.debug("FixAvSectorFacet.getData"); |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
61 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
62 if (artifact instanceof FLYSArtifact) { |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
63 FLYSArtifact flys = (FLYSArtifact)artifact; |
4866
acfd48384835
Changed data field names in fix analsis to ld_from, ld_to, ld step.
Raimund Renkert <rrenkert@intevation.de>
parents:
4442
diff
changeset
|
64 FixAnalysisAccess access = new FixAnalysisAccess(flys, context); |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
65 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
66 CalculationResult res = |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
67 (CalculationResult) flys.compute(context, |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
68 ComputeType.ADVANCE, |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
69 false); |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
70 |
3415
e3c7a3228bc2
FixA: Renamed FixResult to FixAnalysisResult.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3408
diff
changeset
|
71 FixAnalysisResult result = (FixAnalysisResult) res.getData(); |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
72 |
4442
26774405c884
Introduce a new FixingsFacet to add save access to the current Km
Björn Ricks <bjoern.ricks@intevation.de>
parents:
3467
diff
changeset
|
73 double currentKm = getCurrentKm(context); |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
74 KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods(); |
3062
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
75 KMIndex.Entry<AnalysisPeriod []> kmPeriodsEntry = |
3080
dc2765e31e1f
Added getData method with an additional km parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3069
diff
changeset
|
76 kmPeriods.binarySearch(currentKm); |
3062
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
77 |
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
78 if (kmPeriodsEntry == null) { |
3080
dc2765e31e1f
Added getData method with an additional km parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3069
diff
changeset
|
79 logger.warn("No analysis periods found for km '" + currentKm + "'"); |
3062
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
80 return null; |
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
81 } |
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
82 |
7660cfe5e8f6
FixWQCurveGenerator can generate charts from Fix*-Facets (in theory and not complete)
Christian Lins <christian.lins@intevation.de>
parents:
3043
diff
changeset
|
83 AnalysisPeriod[] periods = kmPeriodsEntry.getValue(); |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
84 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
85 if (periods == null) { |
3066
4c22194b733a
Some minor bugfixes in fix analysis calculation and some more debug output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3063
diff
changeset
|
86 logger.warn("No analysis periods specified!"); |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
87 return null; |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
88 } |
3066
4c22194b733a
Some minor bugfixes in fix analysis calculation and some more debug output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3063
diff
changeset
|
89 |
3067
d87aadaa4f7e
Add FixDerivedCurveGenerator class
Christian Lins <christian.lins@intevation.de>
parents:
3066
diff
changeset
|
90 QWD[] qwdData = null; |
3131
bac0b2721451
FixA: Added delta W(t) chart in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3088
diff
changeset
|
91 int sectorNdx = index & 3; |
bac0b2721451
FixA: Added delta W(t) chart in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3088
diff
changeset
|
92 int periodNdx = index >> 2; |
bac0b2721451
FixA: Added delta W(t) chart in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3088
diff
changeset
|
93 |
bac0b2721451
FixA: Added delta W(t) chart in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3088
diff
changeset
|
94 if (periodNdx < periods.length) { |
bac0b2721451
FixA: Added delta W(t) chart in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3088
diff
changeset
|
95 qwdData = periods[periodNdx].getQSectorAverages(); |
3067
d87aadaa4f7e
Add FixDerivedCurveGenerator class
Christian Lins <christian.lins@intevation.de>
parents:
3066
diff
changeset
|
96 } |
3066
4c22194b733a
Some minor bugfixes in fix analysis calculation and some more debug output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3063
diff
changeset
|
97 |
4c22194b733a
Some minor bugfixes in fix analysis calculation and some more debug output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3063
diff
changeset
|
98 if (logger.isDebugEnabled()) { |
4c22194b733a
Some minor bugfixes in fix analysis calculation and some more debug output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3063
diff
changeset
|
99 int resSize = qwdData != null ? qwdData.length : -1; |
4c22194b733a
Some minor bugfixes in fix analysis calculation and some more debug output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3063
diff
changeset
|
100 logger.debug("Found " + resSize + " result elements."); |
4c22194b733a
Some minor bugfixes in fix analysis calculation and some more debug output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3063
diff
changeset
|
101 } |
4c22194b733a
Some minor bugfixes in fix analysis calculation and some more debug output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3063
diff
changeset
|
102 |
3131
bac0b2721451
FixA: Added delta W(t) chart in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3088
diff
changeset
|
103 if (qwdData == null) { |
bac0b2721451
FixA: Added delta W(t) chart in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3088
diff
changeset
|
104 return null; |
bac0b2721451
FixA: Added delta W(t) chart in fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3088
diff
changeset
|
105 } |
3467
b9c2becbcc9e
Towards issue745 (lines for averages in deltawt).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3415
diff
changeset
|
106 return new QWDDateRange(qwdData[sectorNdx], periods[periodNdx].getDateRange()); |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 } |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
108 else { |
3066
4c22194b733a
Some minor bugfixes in fix analysis calculation and some more debug output.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3063
diff
changeset
|
109 logger.warn("Artifact is no instance of FLYSArtifact."); |
3028
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
110 return null; |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
111 } |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
112 } |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
113 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
114 |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
115 /** |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 * Create a deep copy of this Facet. |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 * @return a deep copy. |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
118 */ |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
119 @Override |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
120 public FixAvSectorFacet deepCopy() { |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
121 FixAvSectorFacet copy = new FixAvSectorFacet(); |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 copy.set(this); |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
123 return copy; |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 } |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 } |
77b5f5a26700
Added facets for fix analysis.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |