Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationMainValuesWFacet.java @ 9266:465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
author | mschaefer |
---|---|
date | Wed, 18 Jul 2018 12:20:01 +0200 |
parents | 66b003701546 |
children | 83ebeb620b5a |
comparison
equal
deleted
inserted
replaced
9265:e5367900dd6d | 9266:465347d12990 |
---|---|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | 5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
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 | |
11 import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM; | |
10 | 12 |
11 import org.apache.log4j.Logger; | 13 import org.apache.log4j.Logger; |
12 import org.dive4elements.artifactdatabase.state.DefaultFacet; | 14 import org.dive4elements.artifactdatabase.state.DefaultFacet; |
13 import org.dive4elements.artifacts.Artifact; | 15 import org.dive4elements.artifacts.Artifact; |
14 import org.dive4elements.artifacts.CallContext; | 16 import org.dive4elements.artifacts.CallContext; |
69 | 71 |
70 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); | 72 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); |
71 | 73 |
72 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); | 74 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); |
73 | 75 |
76 final double currentKm = getCurrentKm(context); | |
77 | |
74 return new RiverAnnotation(this.description, data.getMainValueWAnnotations()); | 78 return new RiverAnnotation(this.description, data.getMainValueWAnnotations()); |
79 } | |
80 | |
81 /** | |
82 * Returns the current km from the context. | |
83 * If the context is null or doesn't contain a currentKm | |
84 * then a double value of -1 will be returned. | |
85 * | |
86 * @param context | |
87 * The CallContext instance | |
88 * @return the current km as double | |
89 */ | |
90 // FIXME: copied from org.dive4elements.river.artifacts.model.fixings.FixingsFacet | |
91 private double getCurrentKm(final CallContext context) { | |
92 if (context == null) | |
93 return Double.NaN; | |
94 | |
95 final Double dkm = (Double) context.getContextValue(CURRENT_KM); | |
96 if (dkm == null) | |
97 return Double.NaN; | |
98 | |
99 return dkm.doubleValue(); | |
75 } | 100 } |
76 | 101 |
77 | 102 |
78 /** | 103 /** |
79 * Create a deep copy of this Facet. | 104 * Create a deep copy of this Facet. |