comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationInfrastructureFacet.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
8 * documentation coming with Dive4Elements River for details. 8 * documentation coming with Dive4Elements River for details.
9 */ 9 */
10 10
11 package org.dive4elements.river.artifacts.sinfo.flood_duration; 11 package org.dive4elements.river.artifacts.sinfo.flood_duration;
12 12
13 import java.util.ArrayList; 13 import static org.dive4elements.river.exports.injector.InjectorConstants.CURRENT_KM;
14
14 import java.util.List; 15 import java.util.List;
15 16
16 import org.apache.log4j.Logger; 17 import org.apache.log4j.Logger;
17 import org.dive4elements.artifactdatabase.state.DefaultFacet; 18 import org.dive4elements.artifactdatabase.state.DefaultFacet;
18 import org.dive4elements.artifacts.Artifact; 19 import org.dive4elements.artifacts.Artifact;
58 59
59 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); 60 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false);
60 61
61 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); 62 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData();
62 63
63 final List<StickyAxisAnnotation> annotations = new ArrayList<>(); 64 // final List<StickyAxisAnnotation> annotations = new ArrayList<>();
64 annotations.add(data.getInfrastructureWAnnotation()); 65 // annotations.add(data.getInfrastructureWAnnotation());
65 annotations.add(data.getInfrastructureQAnnotation()); 66 // annotations.add(data.getInfrastructureQAnnotation());
66 if (annotations.get(0) != null) { 67
67 this.description = annotations.get(0).getText(); // TODO Diagramm-Aktualisierung auslösen 68 final double currentKm = getCurrentKm(context);
69
70 final List<StickyAxisAnnotation> annotations = new FloodDurationCalculation(context).calcInfrastructureAnnotations(currentKm,
71 data.getResults().get(this.index));
72 if (annotations != null) {
68 return new RiverAnnotation(this.description, annotations); 73 return new RiverAnnotation(this.description, annotations);
69 } 74 }
70 else 75 else
71 return null; 76 return null;
77 }
78
79 /**
80 * Returns the current km from the context.
81 * If the context is null or doesn't contain a currentKm
82 * then a double value of -1 will be returned.
83 *
84 * @param context
85 * The CallContext instance
86 * @return the current km as double
87 */
88 // FIXME: copied from org.dive4elements.river.artifacts.model.fixings.FixingsFacet
89 private double getCurrentKm(final CallContext context) {
90 if (context == null)
91 return Double.NaN;
92
93 final Double dkm = (Double) context.getContextValue(CURRENT_KM);
94 if (dkm == null)
95 return Double.NaN;
96
97 return dkm.doubleValue();
72 } 98 }
73 99
74 100
75 /** 101 /**
76 * Create a deep copy of this Facet. 102 * Create a deep copy of this Facet.

http://dive4elements.wald.intevation.org