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