comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixOutlierFacet.java @ 3466:8160e62bbb3a

Registered new output 'fix_vollmer_wq_curve' for the vollmer path of fixings analysis module; create required Facets for it after calculation. flys-artifacts/trunk@5137 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 26 Jul 2012 11:47:04 +0000
parents e3c7a3228bc2
children e727e3ebdf85
comparison
equal deleted inserted replaced
3465:7d0ebde8c3e3 3466:8160e62bbb3a
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 the outliers in a fix calculation. 15 * Facet to show the outliers in a fix calculation.
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>
47 41
48 42
49 /** 43 /**
50 * Returns the data this facet requires. 44 * Returns the data this facet requires.
51 * 45 *
52 * @param artifact the owner artifact. 46 * @param artifact the owner artifact; needs to be a FLYSArtifact.
53 * @param context the CallContext (ignored). 47 * @param context the CallContext; required to retrieve the value of
48 * <i>currentKm</i>.
54 * 49 *
55 * @return the data. 50 * @return an array of QW objects or null.
56 */ 51 */
57 @Override 52 @Override
58 public Object getData(Artifact artifact, CallContext context) { 53 public Object getData(Artifact artifact, CallContext context) {
59 logger.debug("FixOutlierFacet.getData"); 54 logger.debug("FixOutlierFacet.getData");
60 55
61 if (artifact instanceof FLYSArtifact) { 56 if (artifact instanceof FLYSArtifact) {
62 FLYSArtifact flys = (FLYSArtifact)artifact; 57 FLYSArtifact flys = (FLYSArtifact)artifact;
63 FixAnalysisAccess access = new FixAnalysisAccess(flys);
64 58
65 CalculationResult res = 59 CalculationResult res =
66 (CalculationResult) flys.compute(context, 60 (CalculationResult) flys.compute(context,
67 ComputeType.ADVANCE, 61 ComputeType.ADVANCE,
68 false); 62 false);
69 63
70 FixAnalysisResult result = (FixAnalysisResult) res.getData(); 64 FixResult result = (FixResult) res.getData();
71 double currentKm = 65 double currentKm =
72 ((Double)context.getContextValue("currentKm")).doubleValue(); 66 ((Double)context.getContextValue("currentKm")).doubleValue();
73 67
74 KMIndex<QW []> kmQWs = result.getOutliers(); 68 KMIndex<QW []> kmQWs = result.getOutliers();
69 KMIndex.Entry<QW []> qwsEntry = kmQWs.binarySearch(currentKm);
75 70
76 KMIndex.Entry<QW []> qwsEntry = kmQWs.binarySearch(currentKm);
77 QW[] qws = null; 71 QW[] qws = null;
78 if(qwsEntry != null) { 72 if(qwsEntry != null) {
79 qws = qwsEntry.getValue(); 73 qws = qwsEntry.getValue();
74
75 logger.debug("Found " + (qws != null ? qws.length : 0)
76 + " KMIndex.Entry for km " + currentKm);
80 } 77 }
78 else {
79 logger.debug("Found no KMIndex.Entry for km " + currentKm);
80 }
81
81 return qws; 82 return qws;
82 } 83 }
83 else { 84 else {
84 logger.debug("Not an instance of FixationArtifact."); 85 logger.warn("Not an instance of FLYSArtifact.");
85 return null; 86 return null;
86 } 87 }
87 } 88 }
88 89
89 90

http://dive4elements.wald.intevation.org