comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixOutlierFacet.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/FixOutlierFacet.java@26774405c884
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.FacetTypes;
10 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
11 import org.dive4elements.river.utils.KMIndex;
12
13 /**
14 * Facet to show the outliers in a fix calculation.
15 *
16 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
17 */
18 public class FixOutlierFacet
19 extends FixingsFacet
20 implements FacetTypes {
21
22 /** House logger. */
23 private static Logger logger = Logger.getLogger(FixOutlierFacet.class);
24
25 /** Trivial Constructor. */
26 public FixOutlierFacet() {
27 }
28
29
30 /**
31 * @param name
32 */
33 public FixOutlierFacet(String name, String description) {
34 super(0, name, description, ComputeType.ADVANCE, null, null);
35 }
36
37 public FixOutlierFacet(int index, String name, String description) {
38 super(index, name, description, ComputeType.ADVANCE, null, null);
39 }
40
41
42 /**
43 * Returns the data this facet requires.
44 *
45 * @param artifact the owner artifact; needs to be a FLYSArtifact.
46 * @param context the CallContext; required to retrieve the value of
47 * <i>currentKm</i>.
48 *
49 * @return an array of QW objects or null.
50 */
51 @Override
52 public Object getData(Artifact artifact, CallContext context) {
53 logger.debug("FixOutlierFacet.getData");
54
55 if (artifact instanceof FLYSArtifact) {
56 FLYSArtifact flys = (FLYSArtifact)artifact;
57
58 CalculationResult res =
59 (CalculationResult) flys.compute(context,
60 ComputeType.ADVANCE,
61 false);
62
63 FixResult result = (FixResult) res.getData();
64 double currentKm = getCurrentKm(context);
65
66 KMIndex<QWI []> kmQWs = result.getOutliers();
67 KMIndex.Entry<QWI []> qwsEntry = kmQWs.binarySearch(currentKm);
68
69 QWI [] qws = null;
70 if (qwsEntry != null) {
71 qws = qwsEntry.getValue();
72
73 if (logger.isDebugEnabled()) {
74 logger.debug("Found " + (qws != null ? qws.length : 0)
75 + " KMIndex.Entry for km " + currentKm);
76 }
77 }
78 else {
79 logger.debug("Found no KMIndex.Entry for km " + currentKm);
80 }
81
82 return qws;
83 }
84
85 logger.warn("Not an instance of FLYSArtifact.");
86 return null;
87 }
88
89
90 /**
91 * Create a deep copy of this Facet.
92 * @return a deep copy.
93 */
94 @Override
95 public FixOutlierFacet deepCopy() {
96 FixOutlierFacet copy = new FixOutlierFacet();
97 copy.set(this);
98 return copy;
99 }
100 }
101 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org