Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationMainValuesQFacet.java @ 9259:66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
author | mschaefer |
---|---|
date | Mon, 16 Jul 2018 08:43:07 +0200 |
parents | ef7b65576d4b |
children | 83ebeb620b5a |
rev | line source |
---|---|
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
3 * |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
7 */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
8 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
9 package org.dive4elements.river.artifacts.sinfo.flood_duration; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
10 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
11 import org.apache.log4j.Logger; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
12 import org.dive4elements.artifactdatabase.state.DefaultFacet; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
13 import org.dive4elements.artifacts.Artifact; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
14 import org.dive4elements.artifacts.CallContext; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
15 import org.dive4elements.river.artifacts.D4EArtifact; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
16 import org.dive4elements.river.artifacts.model.CalculationResult; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
17 import org.dive4elements.river.artifacts.model.WQDay; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
19 import org.dive4elements.river.jfree.RiverAnnotation; |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
20 import org.dive4elements.river.jfree.StickyAxisAnnotation; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
21 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
22 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
23 /** |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
24 * Facet to show Main Q Values. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
25 */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
26 public class FloodDurationMainValuesQFacet extends DefaultFacet { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
27 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
28 /** Own log. */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
29 private static Logger log = Logger.getLogger(FloodDurationMainValuesQFacet.class); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
30 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
31 /** Trivial Constructor. */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
32 public FloodDurationMainValuesQFacet(final String name, final String description) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
33 this.description = description; |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
34 this.name = name; |
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
35 this.index = 1; |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
36 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
37 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
38 /** |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
39 * Set the hit-point in Q where a line drawn from the axis would hit the |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
40 * curve in WQDay (if hit). |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
41 * Employ linear interpolation. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
42 */ |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
43 public static void setHitPoint(final WQDay wqday, final StickyAxisAnnotation annotation) { |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
44 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
45 final float q = annotation.getPos(); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
46 final Double day = wqday.interpolateDayByQ(q); |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
47 if (day != null) |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
48 annotation.setHitPoint(day.floatValue()); |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
49 else |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
50 log.debug("StickyAnnotation does not hit wqday curve: " + q); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
51 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
52 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
53 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
54 /** |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
55 * Returns the data this facet requires. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
56 * |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
57 * @param artifact the owner artifact. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
58 * @param context the CallContext (can be used to find out if in |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
59 * navigable fixation-setting, or durationcurve). |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
60 * |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
61 * @return the data. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
62 */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
63 @Override |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
64 public Object getData(final Artifact artifact, final CallContext context) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
65 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
66 log.debug("Get data for flood duration main value Q data"); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
67 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
68 final D4EArtifact flys = (D4EArtifact) artifact; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
69 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
70 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
71 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
72 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
73 |
9259
66b003701546
Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
9257
diff
changeset
|
74 return new RiverAnnotation(this.description, data.getMainValueQAnnotations()); |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
75 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
76 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
77 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
78 /** |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
79 * Create a deep copy of this Facet. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
80 * @return a deep copy. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
81 */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
82 @Override |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
83 public FloodDurationMainValuesQFacet deepCopy() { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
84 final FloodDurationMainValuesQFacet copy = new FloodDurationMainValuesQFacet(this.name, this.description); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
85 copy.set(this); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
86 return copy; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
87 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
88 } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
diff
changeset
|
89 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |