comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixLongitudinalAnalysisFacet.java @ 5831:bd047b71ab37

Repaired internal references
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:06:39 +0200
parents flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalAnalysisFacet.java@66f539df4e8b
children
comparison
equal deleted inserted replaced
5830:160f53ee0870 5831:bd047b71ab37
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 :

http://dive4elements.wald.intevation.org