Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCurveFacet.java @ 9265:e5367900dd6d
Small cleanup concerning getPoints
Adding validStations as dataItem to flood duration calculation
Flood duration now km aware
author | gernotbelger |
---|---|
date | Tue, 17 Jul 2018 19:48:28 +0200 |
parents | ef7b65576d4b |
children | 465347d12990 |
comparison
equal
deleted
inserted
replaced
9264:baef46792354 | 9265:e5367900dd6d |
---|---|
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 java.util.ArrayList; | 11 import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM; |
12 //import java.util.List; | |
13 | 12 |
14 import org.apache.log4j.Logger; | 13 import org.apache.log4j.Logger; |
15 import org.dive4elements.artifactdatabase.state.DefaultFacet; | 14 import org.dive4elements.artifactdatabase.state.DefaultFacet; |
16 import org.dive4elements.artifactdatabase.state.Facet; | 15 import org.dive4elements.artifactdatabase.state.Facet; |
17 import org.dive4elements.artifacts.Artifact; | 16 import org.dive4elements.artifacts.Artifact; |
18 import org.dive4elements.artifacts.CallContext; | 17 import org.dive4elements.artifacts.CallContext; |
19 import org.dive4elements.river.artifacts.D4EArtifact; | 18 import org.dive4elements.river.artifacts.D4EArtifact; |
20 import org.dive4elements.river.artifacts.model.CalculationResult; | 19 import org.dive4elements.river.artifacts.model.CalculationResult; |
21 //import org.dive4elements.river.artifacts.model.WQDay; | |
22 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | 20 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
23 | 21 |
24 | 22 |
25 /** | 23 /** |
26 * Data of a duration curve. | 24 * Data of a duration curve. |
55 | 53 |
56 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); | 54 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); |
57 | 55 |
58 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); | 56 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); |
59 | 57 |
58 final double currentKm = getCurrentKm(context); | |
59 // TODO: entweder in data.getDurationCurve() reingeben, oder bei FloodDurationCalculationResults auswerten... | |
60 // TODO: was ist aus perfromanz/speicher-sicht besser? | |
61 | |
60 return data.getDurationCurve(); | 62 return data.getDurationCurve(); |
61 // return getTestData(); | 63 } |
64 | |
65 /** | |
66 * Returns the current km from the context. | |
67 * If the context is null or doesn't contain a currentKm | |
68 * then a double value of -1 will be returned. | |
69 * | |
70 * @param context | |
71 * The CallContext instance | |
72 * @return the current km as double | |
73 */ | |
74 // FIXME: copied from org.dive4elements.river.artifacts.model.fixings.FixingsFacet | |
75 private double getCurrentKm(final CallContext context) { | |
76 if (context == null) | |
77 return Double.NaN; | |
78 | |
79 final Double dkm = (Double) context.getContextValue(CURRENT_KM); | |
80 if (dkm == null) | |
81 return Double.NaN; | |
82 | |
83 return dkm.doubleValue(); | |
62 } | 84 } |
63 | 85 |
64 // private WQDay getTestData() { | 86 // private WQDay getTestData() { |
65 // final int[] days = new int[366]; | 87 // final int[] days = new int[366]; |
66 // final double[] ws = new double[366]; | 88 // final double[] ws = new double[366]; |
71 // ws[i] = 102.0 - (Math.pow(x, 5) + x); | 93 // ws[i] = 102.0 - (Math.pow(x, 5) + x); |
72 // qs[i] = 1600.0 - 800 * (Math.pow(x, 9) + x); | 94 // qs[i] = 1600.0 - 800 * (Math.pow(x, 9) + x); |
73 // } | 95 // } |
74 // return new WQDay(days, ws, qs); | 96 // return new WQDay(days, ws, qs); |
75 // } | 97 // } |
76 | |
77 | 98 |
78 // @Override | 99 // @Override |
79 // public List getStaticDataProviderKeys(final Artifact art) { | 100 // public List getStaticDataProviderKeys(final Artifact art) { |
80 // final List list = new ArrayList(); | 101 // final List list = new ArrayList(); |
81 // list.add(BB_DURATIONCURVE); | 102 // list.add(BB_DURATIONCURVE); |