annotate 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
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5869
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5869
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
9 package org.dive4elements.river.artifacts;
4508
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
10
9425
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
11 import java.io.Serializable;
4508
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
12
9425
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
13 import org.apache.log4j.Logger;
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
14 import org.dive4elements.artifacts.CallContext;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
15 import org.dive4elements.river.artifacts.model.CalculationResult;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
16 import org.dive4elements.river.artifacts.model.WKms;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
17 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4736
diff changeset
19
2651
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 /**
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 * The default fixation analysis artifact.
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 *
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 */
9425
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
25 public class FixationArtifact extends D4EArtifact implements WaterLineArtifact {
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
26
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
27 private static final long serialVersionUID = 1L;
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
28
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6496
diff changeset
29 /** The log for this class. */
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6496
diff changeset
30 private static Logger log = Logger.getLogger(FixationArtifact.class);
2651
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 /** The name of the artifact. */
9425
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
33 private static final String ARTIFACT_NAME = "fixanalysis";
2651
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34
4418
e0a355d0c771 FixationArtifact: In doc, mention where the FacetActivity is registered.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3917
diff changeset
35 /* FacetActivity for this artifact is registered in FixAnalysisCompute . */
e0a355d0c771 FixationArtifact: In doc, mention where the FacetActivity is registered.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3917
diff changeset
36
2651
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 /**
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 * The default constructor.
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 */
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 public FixationArtifact() {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6496
diff changeset
41 log.debug("ctor()");
2651
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 }
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 /**
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 * Returns the name of the concrete artifact.
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 *
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 * @return the name of the concrete artifact.
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 */
3193
2f922be407ea Moved common code of the *Artifacts into FLYSArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2728
diff changeset
49 @Override
2651
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 public String getName() {
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 return ARTIFACT_NAME;
9e9eb9d97548 Initial transition configuration and artifact/state stubs for fixation
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 }
4508
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
53
6496
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
54 /** Calculate waterlines against a cross section. */
4508
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
55 @Override
9425
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
56 public double getWaterLevel(final ComputeType type, final String hash, final String stateId, final double currentKm, final Serializable waterLineIndex,
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
57 final double nextKm, final double prevKm, final CallContext context) {
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
58 final FixRealizingResult result = (FixRealizingResult) ((CalculationResult) this.compute(context, ComputeType.ADVANCE, false)).getData();
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4508
diff changeset
59
9425
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
60 final int wstIndex = (Integer) waterLineIndex;
4508
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
61
9425
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
62 final WKms wkms = result.getWQKms()[wstIndex];
4508
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
63
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
64 // Find W at km.
9425
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
65 final double wAtKm = StaticWKmsArtifact.getWAtKm(wkms, currentKm);
4508
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
66
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
67 if (wAtKm == -1 || Double.isNaN(wAtKm)) {
9425
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
68 log.warn("Waterlevel at km " + currentKm + " unknown.");
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
69 return Double.NaN;
4508
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
70 }
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
71
9425
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
72 return wAtKm;
4508
03b8d10a99c0 FixationArtifact: implement WaterLineArtifact, deliver lines for cross-sections.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4418
diff changeset
73 }
9425
3f49835a00c3 Extended CrossSectionFacet so it may fetch different data from within the artifact result.
gernotbelger
parents: 8856
diff changeset
74 }

http://dive4elements.wald.intevation.org