9461
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
|
2 * Software engineering by Intevation GmbH |
|
3 * |
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
|
6 * documentation coming with Dive4Elements River for details. |
|
7 */ |
|
8 |
|
9 package org.dive4elements.river.artifacts; |
|
10 |
|
11 import java.io.Serializable; |
|
12 |
|
13 import org.apache.log4j.Logger; |
|
14 import org.dive4elements.artifacts.CallContext; |
|
15 import org.dive4elements.river.artifacts.model.CalculationResult; |
|
16 import org.dive4elements.river.artifacts.model.WKms; |
|
17 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult; |
|
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
|
19 |
|
20 /** |
|
21 * The default fixation analysis artifact. |
|
22 * |
|
23 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
|
24 */ |
|
25 public class AbstractFixBunduArtifact extends D4EArtifact implements WaterLineArtifact { |
|
26 |
|
27 private static final long serialVersionUID = 1L; |
|
28 |
|
29 /** The log for this class. */ |
|
30 private static Logger log = Logger.getLogger(AbstractFixBunduArtifact.class); |
|
31 |
|
32 /** |
|
33 * The default constructor. |
|
34 */ |
|
35 public AbstractFixBunduArtifact() { |
|
36 log.debug("ctor()"); |
|
37 } |
|
38 |
|
39 /** Calculate waterlines against a cross section. */ |
|
40 @Override |
|
41 public double getWaterLevel(final ComputeType type, final String hash, final String stateId, final double currentKm, final Serializable waterLineIndex, |
|
42 final double nextKm, final double prevKm, final CallContext context) { |
|
43 final FixRealizingResult result = (FixRealizingResult) ((CalculationResult) this.compute(context, ComputeType.ADVANCE, false)).getData(); |
|
44 |
|
45 final int wstIndex = (Integer) waterLineIndex; |
|
46 |
|
47 final WKms wkms = result.getWQKms()[wstIndex]; |
|
48 |
|
49 // Find W at km. |
|
50 final double wAtKm = StaticWKmsArtifact.getWAtKm(wkms, currentKm); |
|
51 |
|
52 if (wAtKm == -1 || Double.isNaN(wAtKm)) { |
|
53 log.warn("Waterlevel at km " + currentKm + " unknown."); |
|
54 return Double.NaN; |
|
55 } |
|
56 |
|
57 return wAtKm; |
|
58 } |
|
59 } |