Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCurveFacet.java @ 9268:ae9dee74e43e
Fixed: current station of duration chart was not changed
author | gernotbelger |
---|---|
date | Wed, 18 Jul 2018 18:53:15 +0200 |
parents | 465347d12990 |
children | 83ebeb620b5a |
comparison
equal
deleted
inserted
replaced
9267:c7e5285d434f | 9268:ae9dee74e43e |
---|---|
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.sinfo.flood_duration; | 9 package org.dive4elements.river.artifacts.sinfo.flood_duration; |
10 | 10 |
11 import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM; | |
12 | |
13 import org.apache.log4j.Logger; | 11 import org.apache.log4j.Logger; |
14 import org.dive4elements.artifactdatabase.state.DefaultFacet; | 12 import org.dive4elements.artifactdatabase.state.DefaultFacet; |
15 import org.dive4elements.artifactdatabase.state.Facet; | 13 import org.dive4elements.artifactdatabase.state.Facet; |
16 import org.dive4elements.artifacts.Artifact; | 14 import org.dive4elements.artifacts.Artifact; |
17 import org.dive4elements.artifacts.CallContext; | 15 import org.dive4elements.artifacts.CallContext; |
18 import org.dive4elements.river.artifacts.D4EArtifact; | 16 import org.dive4elements.river.artifacts.D4EArtifact; |
19 import org.dive4elements.river.artifacts.model.CalculationResult; | |
20 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; | 17 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; |
21 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | 18 import org.dive4elements.river.exports.fixings.FixChartGenerator; |
22 | 19 |
23 | 20 |
24 /** | 21 /** |
25 * Data of a duration curve. | 22 * Data of a duration curve. |
26 */ | 23 */ |
27 public class FloodDurationCurveFacet extends DefaultFacet { | 24 public class FloodDurationCurveFacet extends DefaultFacet { |
25 | |
26 private static final long serialVersionUID = 1L; | |
28 | 27 |
29 private static Logger log = Logger.getLogger(FloodDurationCurveFacet.class); | 28 private static Logger log = Logger.getLogger(FloodDurationCurveFacet.class); |
30 | 29 |
31 // /** Blackboard data provider key for durationcurve (wqday) data. */ | 30 // /** Blackboard data provider key for durationcurve (wqday) data. */ |
32 // public static String BB_DURATIONCURVE = "durationcurve"; | 31 // public static String BB_DURATIONCURVE = "durationcurve"; |
50 | 49 |
51 log.debug("Get data for flood duration curve data"); | 50 log.debug("Get data for flood duration curve data"); |
52 | 51 |
53 final D4EArtifact flys = (D4EArtifact) artifact; | 52 final D4EArtifact flys = (D4EArtifact) artifact; |
54 | 53 |
55 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); | 54 // TODO: wird das hier noch benötigt? |
55 // final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); | |
56 // final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); | |
56 | 57 |
57 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); | 58 final double currentKm = FixChartGenerator.getCurrentKm(context); |
58 | |
59 final double currentKm = getCurrentKm(context); | |
60 // TODO: entweder in data.getDurationCurve() reingeben, oder bei FloodDurationCalculationResults auswerten... | |
61 // TODO: was ist aus perfromanz/speicher-sicht besser? | |
62 | |
63 // return data.getDurationCurve(); | |
64 return new FloodDurationCalculation(context).calcStationCurve(currentKm, (SINFOArtifact) flys); | 59 return new FloodDurationCalculation(context).calcStationCurve(currentKm, (SINFOArtifact) flys); |
65 } | |
66 | |
67 /** | |
68 * Returns the current km from the context. | |
69 * If the context is null or doesn't contain a currentKm | |
70 * then a double value of -1 will be returned. | |
71 * | |
72 * @param context | |
73 * The CallContext instance | |
74 * @return the current km as double | |
75 */ | |
76 // FIXME: copied from org.dive4elements.river.artifacts.model.fixings.FixingsFacet | |
77 private double getCurrentKm(final CallContext context) { | |
78 if (context == null) | |
79 return Double.NaN; | |
80 | |
81 final Double dkm = (Double) context.getContextValue(CURRENT_KM); | |
82 if (dkm == null) | |
83 return Double.NaN; | |
84 | |
85 return dkm.doubleValue(); | |
86 } | 60 } |
87 | 61 |
88 // private WQDay getTestData() { | 62 // private WQDay getTestData() { |
89 // final int[] days = new int[366]; | 63 // final int[] days = new int[366]; |
90 // final double[] ws = new double[366]; | 64 // final double[] ws = new double[366]; |