Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/FixationArtifact.java @ 9425:3f49835a00c3
Extended CrossSectionFacet so it may fetch different data from within the artifact result.
Also allows to have acces to the potentially already computed artifact result via its normal computation cache.
author | gernotbelger |
---|---|
date | Fri, 17 Aug 2018 15:31:02 +0200 |
parents | 5e38e2924c07 |
children | 8d6e56e57c4a |
comparison
equal
deleted
inserted
replaced
9424:da19f1f58d72 | 9425:3f49835a00c3 |
---|---|
6 * documentation coming with Dive4Elements River for details. | 6 * documentation coming with Dive4Elements River for details. |
7 */ | 7 */ |
8 | 8 |
9 package org.dive4elements.river.artifacts; | 9 package org.dive4elements.river.artifacts; |
10 | 10 |
11 import java.io.Serializable; | |
12 | |
13 import org.apache.log4j.Logger; | |
11 import org.dive4elements.artifacts.CallContext; | 14 import org.dive4elements.artifacts.CallContext; |
12 | |
13 import org.dive4elements.river.artifacts.geom.Lines; | |
14 | |
15 import org.dive4elements.river.artifacts.model.CalculationResult; | 15 import org.dive4elements.river.artifacts.model.CalculationResult; |
16 import org.dive4elements.river.artifacts.model.WKms; | 16 import org.dive4elements.river.artifacts.model.WKms; |
17 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult; | 17 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult; |
18 | |
19 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | 18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
20 | |
21 import org.dive4elements.river.model.FastCrossSectionLine; | |
22 | |
23 import org.apache.log4j.Logger; | |
24 | 19 |
25 /** | 20 /** |
26 * The default fixation analysis artifact. | 21 * The default fixation analysis artifact. |
27 * | 22 * |
28 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 23 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
29 */ | 24 */ |
30 public class FixationArtifact | 25 public class FixationArtifact extends D4EArtifact implements WaterLineArtifact { |
31 extends D4EArtifact | 26 |
32 implements WaterLineArtifact | 27 private static final long serialVersionUID = 1L; |
33 { | 28 |
34 /** The log for this class. */ | 29 /** The log for this class. */ |
35 private static Logger log = Logger.getLogger(FixationArtifact.class); | 30 private static Logger log = Logger.getLogger(FixationArtifact.class); |
36 | 31 |
37 /** The name of the artifact. */ | 32 /** The name of the artifact. */ |
38 public static final String ARTIFACT_NAME = "fixanalysis"; | 33 private static final String ARTIFACT_NAME = "fixanalysis"; |
39 | 34 |
40 /* FacetActivity for this artifact is registered in FixAnalysisCompute . */ | 35 /* FacetActivity for this artifact is registered in FixAnalysisCompute . */ |
41 | 36 |
42 /** | 37 /** |
43 * The default constructor. | 38 * The default constructor. |
56 return ARTIFACT_NAME; | 51 return ARTIFACT_NAME; |
57 } | 52 } |
58 | 53 |
59 /** Calculate waterlines against a cross section. */ | 54 /** Calculate waterlines against a cross section. */ |
60 @Override | 55 @Override |
61 public Lines.LineData getWaterLines( | 56 public double getWaterLevel(final ComputeType type, final String hash, final String stateId, final double currentKm, final Serializable waterLineIndex, |
62 int facetIdx, | 57 final double nextKm, final double prevKm, final CallContext context) { |
63 FastCrossSectionLine csl, | 58 final FixRealizingResult result = (FixRealizingResult) ((CalculationResult) this.compute(context, ComputeType.ADVANCE, false)).getData(); |
64 double d, | |
65 double w, | |
66 CallContext context | |
67 ) { | |
68 FixRealizingResult result = (FixRealizingResult) | |
69 ((CalculationResult)this.compute( | |
70 context, ComputeType.ADVANCE, false)).getData(); | |
71 | 59 |
72 WKms wkms = result.getWQKms()[facetIdx]; | 60 final int wstIndex = (Integer) waterLineIndex; |
73 | 61 |
74 double km = csl.getKm(); | 62 final WKms wkms = result.getWQKms()[wstIndex]; |
75 | 63 |
76 // Find W at km. | 64 // Find W at km. |
77 double wAtKm; | 65 final double wAtKm = StaticWKmsArtifact.getWAtKm(wkms, currentKm); |
78 | |
79 wAtKm = StaticWKmsArtifact.getWAtKm(wkms, km); | |
80 | 66 |
81 if (wAtKm == -1 || Double.isNaN(wAtKm)) { | 67 if (wAtKm == -1 || Double.isNaN(wAtKm)) { |
82 log.warn("Waterlevel at km " + km + " unknown."); | 68 log.warn("Waterlevel at km " + currentKm + " unknown."); |
83 return new Lines.LineData(new double[][] {{}}, 0d, 0d); | 69 return Double.NaN; |
84 } | 70 } |
85 | 71 |
86 // This should be FixRealizationResult, which can be getWQKms()ed | 72 return wAtKm; |
87 return Lines.createWaterLines(csl.getPoints(), wAtKm); | |
88 } | 73 } |
89 } | 74 } |
90 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |