annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationInfrastructureFacet.java @ 9376:f318359b81a2

S-Info flood duration theme rename, and more infrastructure themes in the duration curve
author mschaefer
date Fri, 03 Aug 2018 17:02:38 +0200
parents 83ebeb620b5a
children f8308db94634
rev   line source
9259
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
2 * Software engineering by
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
5 *
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
9 */
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
10
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
11 package org.dive4elements.river.artifacts.sinfo.flood_duration;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
12
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
13 import java.util.List;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
14
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
15 import org.apache.log4j.Logger;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
16 import org.dive4elements.artifactdatabase.state.DefaultFacet;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
17 import org.dive4elements.artifacts.Artifact;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
18 import org.dive4elements.artifacts.CallContext;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
19 import org.dive4elements.river.artifacts.D4EArtifact;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
20 import org.dive4elements.river.artifacts.model.CalculationResult;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
21 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
9269
83ebeb620b5a Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents: 9266
diff changeset
22 import org.dive4elements.river.exports.fixings.FixChartGenerator;
9259
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
23 import org.dive4elements.river.jfree.RiverAnnotation;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
24 import org.dive4elements.river.jfree.StickyAxisAnnotation;
9376
f318359b81a2 S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents: 9269
diff changeset
25 import org.dive4elements.river.model.Attribute.AttributeKey;
9259
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
26
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
27
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
28 /**
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
29 * Facet to show W and Q annotation lines of an infrastructure height.
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
30 */
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
31 public class FloodDurationInfrastructureFacet extends DefaultFacet {
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
32
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
33 /** Own log. */
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
34 private static Logger log = Logger.getLogger(FloodDurationInfrastructureFacet.class);
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
35
9376
f318359b81a2 S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents: 9269
diff changeset
36 private final AttributeKey riverBankKey;
f318359b81a2 S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents: 9269
diff changeset
37
f318359b81a2 S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents: 9269
diff changeset
38 private final boolean isW;
f318359b81a2 S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents: 9269
diff changeset
39
f318359b81a2 S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents: 9269
diff changeset
40 public FloodDurationInfrastructureFacet(final String name, final String description, final AttributeKey riverside, final boolean isW) {
9259
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
41 this.description = description;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
42 this.name = name;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
43 this.index = 0;
9376
f318359b81a2 S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents: 9269
diff changeset
44 this.riverBankKey = riverside;
f318359b81a2 S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents: 9269
diff changeset
45 this.isW = isW;
9259
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
46 }
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
47
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
48
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
49 /**
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
50 * Returns the data this facet requires.
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
51 */
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
52 @Override
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
53 public Object getData(final Artifact artifact, final CallContext context) {
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
54
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
55 log.debug("Get data for flood duration curve infrastructure");
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
56
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
57 final D4EArtifact flys = (D4EArtifact) artifact;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
58
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
59 final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false);
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
60
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
61 final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData();
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
62
9269
83ebeb620b5a Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents: 9266
diff changeset
63 final double currentKm = FixChartGenerator.getCurrentKm(context);
9266
465347d12990 Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents: 9259
diff changeset
64
465347d12990 Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents: 9259
diff changeset
65 final List<StickyAxisAnnotation> annotations = new FloodDurationCalculation(context).calcInfrastructureAnnotations(currentKm,
9376
f318359b81a2 S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents: 9269
diff changeset
66 this.riverBankKey, this.isW, data.getResults().get(this.index));
9259
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
67
9269
83ebeb620b5a Station specific main value annotations in S-Info flood duration curve, corrected infrastructure flood duration calculation
mschaefer
parents: 9266
diff changeset
68 return new RiverAnnotation(this.description, annotations);
9266
465347d12990 Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents: 9259
diff changeset
69 }
465347d12990 Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents: 9259
diff changeset
70
9259
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
71
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
72 /**
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
73 * Create a deep copy of this Facet.
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
74 * @return a deep copy.
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
75 */
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
76 @Override
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
77 public FloodDurationInfrastructureFacet deepCopy() {
9376
f318359b81a2 S-Info flood duration theme rename, and more infrastructure themes in the duration curve
mschaefer
parents: 9269
diff changeset
78 final FloodDurationInfrastructureFacet copy = new FloodDurationInfrastructureFacet(this.name, this.description, this.riverBankKey, this.isW);
9259
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
79 copy.set(this);
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
80 return copy;
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
81 }
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
82 }
66b003701546 Added infrastructure height and Q annotation to S-Info flood duration curve chart
mschaefer
parents:
diff changeset
83

http://dive4elements.wald.intevation.org