Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalAnalysisFacet.java @ 3610:66f539df4e8b
Issue 716.
FixA: Spilt reference and analysis period themes into one theme for each event.
flys-artifacts/trunk@5239 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 23 Aug 2012 08:49:37 +0000 |
parents | e3c7a3228bc2 |
children |
comparison
equal
deleted
inserted
replaced
3609:a16837d73130 | 3610:66f539df4e8b |
---|---|
1 package de.intevation.flys.artifacts.model.fixings; | 1 package de.intevation.flys.artifacts.model.fixings; |
2 | |
3 import org.apache.log4j.Logger; | |
2 | 4 |
3 import de.intevation.artifacts.Artifact; | 5 import de.intevation.artifacts.Artifact; |
4 import de.intevation.artifacts.CallContext; | 6 import de.intevation.artifacts.CallContext; |
5 | |
6 import de.intevation.flys.artifacts.FLYSArtifact; | 7 import de.intevation.flys.artifacts.FLYSArtifact; |
7 | |
8 import de.intevation.flys.artifacts.access.FixAnalysisAccess; | |
9 | |
10 import de.intevation.flys.artifacts.model.CalculationResult; | 8 import de.intevation.flys.artifacts.model.CalculationResult; |
11 import de.intevation.flys.artifacts.model.DataFacet; | 9 import de.intevation.flys.artifacts.model.DataFacet; |
12 import de.intevation.flys.artifacts.model.FacetTypes; | 10 import de.intevation.flys.artifacts.model.FacetTypes; |
13 | |
14 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | 11 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
15 | |
16 import de.intevation.flys.utils.KMIndex; | 12 import de.intevation.flys.utils.KMIndex; |
17 | |
18 import org.apache.log4j.Logger; | |
19 | 13 |
20 /** | 14 /** |
21 * Facet to show average W values for Q sectors. | 15 * Facet to show average W values for Q sectors. |
22 * | 16 * |
23 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 17 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
61 public Object getData(Artifact artifact, CallContext context) { | 55 public Object getData(Artifact artifact, CallContext context) { |
62 logger.debug("FixLongitudinalAnalysisFacet.getData"); | 56 logger.debug("FixLongitudinalAnalysisFacet.getData"); |
63 | 57 |
64 if (artifact instanceof FLYSArtifact) { | 58 if (artifact instanceof FLYSArtifact) { |
65 FLYSArtifact flys = (FLYSArtifact)artifact; | 59 FLYSArtifact flys = (FLYSArtifact)artifact; |
66 FixAnalysisAccess access = new FixAnalysisAccess(flys); | |
67 | 60 |
68 CalculationResult res = | 61 CalculationResult res = |
69 (CalculationResult) flys.compute(context, | 62 (CalculationResult) flys.compute(context, |
70 ComputeType.ADVANCE, | 63 ComputeType.ADVANCE, |
71 false); | 64 false); |
72 | 65 |
73 FixAnalysisResult result = (FixAnalysisResult) res.getData(); | 66 FixAnalysisResult result = (FixAnalysisResult) res.getData(); |
74 | 67 |
75 KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods(); | 68 KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods(); |
76 | |
77 if (kmPeriods == null) { | 69 if (kmPeriods == null) { |
78 logger.warn("No analysis periods found."); | 70 logger.warn("No analysis periods found."); |
79 return null; | 71 return null; |
80 } | 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 } | |
81 | 86 |
82 return kmPeriods; | 87 |
88 return resPeriods; | |
83 } | 89 } |
84 else { | 90 else { |
85 logger.warn("Artifact is no instance of FLYSArtifact."); | 91 logger.warn("Artifact is no instance of FLYSArtifact."); |
86 return null; | 92 return null; |
87 } | 93 } |