Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationMainValuesQFacet.java @ 9269:83ebeb620b5a
Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
author | mschaefer |
---|---|
date | Thu, 19 Jul 2018 08:07:03 +0200 |
parents | 66b003701546 |
children | f8308db94634 |
comparison
equal
deleted
inserted
replaced
9268:ae9dee74e43e | 9269:83ebeb620b5a |
---|---|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by Intevation GmbH | 2 * Software engineering by |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
3 * | 5 * |
4 * This file is Free Software under the GNU AGPL (>=v3) | 6 * This file is Free Software under the GNU AGPL (>=v3) |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | 7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
6 * documentation coming with Dive4Elements River for details. | 8 * documentation coming with Dive4Elements River for details. |
7 */ | 9 */ |
8 | 10 |
9 package org.dive4elements.river.artifacts.sinfo.flood_duration; | 11 package org.dive4elements.river.artifacts.sinfo.flood_duration; |
10 | 12 |
13 import java.util.List; | |
14 | |
11 import org.apache.log4j.Logger; | 15 import org.apache.log4j.Logger; |
12 import org.dive4elements.artifactdatabase.state.DefaultFacet; | 16 import org.dive4elements.artifactdatabase.state.DefaultFacet; |
13 import org.dive4elements.artifacts.Artifact; | 17 import org.dive4elements.artifacts.Artifact; |
14 import org.dive4elements.artifacts.CallContext; | 18 import org.dive4elements.artifacts.CallContext; |
15 import org.dive4elements.river.artifacts.D4EArtifact; | 19 import org.dive4elements.river.artifacts.D4EArtifact; |
16 import org.dive4elements.river.artifacts.model.CalculationResult; | 20 import org.dive4elements.river.artifacts.model.CalculationResult; |
17 import org.dive4elements.river.artifacts.model.WQDay; | |
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | 21 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
22 import org.dive4elements.river.exports.fixings.FixChartGenerator; | |
19 import org.dive4elements.river.jfree.RiverAnnotation; | 23 import org.dive4elements.river.jfree.RiverAnnotation; |
20 import org.dive4elements.river.jfree.StickyAxisAnnotation; | 24 import org.dive4elements.river.jfree.StickyAxisAnnotation; |
21 | 25 |
22 | 26 |
23 /** | 27 /** |
33 this.description = description; | 37 this.description = description; |
34 this.name = name; | 38 this.name = name; |
35 this.index = 1; | 39 this.index = 1; |
36 } | 40 } |
37 | 41 |
38 /** | |
39 * Set the hit-point in Q where a line drawn from the axis would hit the | |
40 * curve in WQDay (if hit). | |
41 * Employ linear interpolation. | |
42 */ | |
43 public static void setHitPoint(final WQDay wqday, final StickyAxisAnnotation annotation) { | |
44 | |
45 final float q = annotation.getPos(); | |
46 final Double day = wqday.interpolateDayByQ(q); | |
47 if (day != null) | |
48 annotation.setHitPoint(day.floatValue()); | |
49 else | |
50 log.debug("StickyAnnotation does not hit wqday curve: " + q); | |
51 } | |
52 | |
53 | 42 |
54 /** | 43 /** |
55 * Returns the data this facet requires. | 44 * Returns the data this facet requires. |
56 * | |
57 * @param artifact the owner artifact. | |
58 * @param context the CallContext (can be used to find out if in | |
59 * navigable fixation-setting, or durationcurve). | |
60 * | |
61 * @return the data. | |
62 */ | 45 */ |
63 @Override | 46 @Override |
64 public Object getData(final Artifact artifact, final CallContext context) { | 47 public Object getData(final Artifact artifact, final CallContext context) { |
65 | 48 |
66 log.debug("Get data for flood duration main value Q data"); | 49 log.debug("Get data for flood duration main value Q data"); |
69 | 52 |
70 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); | 53 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); |
71 | 54 |
72 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); | 55 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); |
73 | 56 |
74 return new RiverAnnotation(this.description, data.getMainValueQAnnotations()); | 57 final double currentKm = FixChartGenerator.getCurrentKm(context); |
58 | |
59 final List<StickyAxisAnnotation> annotations = new FloodDurationCalculation(context).calcMainValueQAnnotations(currentKm, | |
60 data.getResults().get(0)); | |
61 | |
62 return new RiverAnnotation(this.description, annotations); | |
75 } | 63 } |
76 | 64 |
77 | 65 |
78 /** | 66 /** |
79 * Create a deep copy of this Facet. | 67 * Create a deep copy of this Facet. |
84 final FloodDurationMainValuesQFacet copy = new FloodDurationMainValuesQFacet(this.name, this.description); | 72 final FloodDurationMainValuesQFacet copy = new FloodDurationMainValuesQFacet(this.name, this.description); |
85 copy.set(this); | 73 copy.set(this); |
86 return copy; | 74 return copy; |
87 } | 75 } |
88 } | 76 } |
89 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |