Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCurveFacet.java @ 9268:ae9dee74e43e
Fixed: current station of duration chart was not changed
author | gernotbelger |
---|---|
date | Wed, 18 Jul 2018 18:53:15 +0200 |
parents | 465347d12990 |
children | 83ebeb620b5a |
rev | line source |
---|---|
9252 | 1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.artifacts.sinfo.flood_duration; | |
10 | |
11 import org.apache.log4j.Logger; | |
12 import org.dive4elements.artifactdatabase.state.DefaultFacet; | |
13 import org.dive4elements.artifactdatabase.state.Facet; | |
14 import org.dive4elements.artifacts.Artifact; | |
15 import org.dive4elements.artifacts.CallContext; | |
16 import org.dive4elements.river.artifacts.D4EArtifact; | |
9266
465347d12990
Station specific calculation of flood duration curve and infrastructure annotations
mschaefer
parents:
9265
diff
changeset
|
17 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; |
9268
ae9dee74e43e
Fixed: current station of duration chart was not changed
gernotbelger
parents:
9266
diff
changeset
|
18 import org.dive4elements.river.exports.fixings.FixChartGenerator; |
9252 | 19 |
20 | |
21 /** | |
22 * Data of a duration curve. | |
23 */ | |
24 public class FloodDurationCurveFacet extends DefaultFacet { | |
25 | |
9268
ae9dee74e43e
Fixed: current station of duration chart was not changed
gernotbelger
parents:
9266
diff
changeset
|
26 private static final long serialVersionUID = 1L; |
ae9dee74e43e
Fixed: current station of duration chart was not changed
gernotbelger
parents:
9266
diff
changeset
|
27 |
9252 | 28 private static Logger log = Logger.getLogger(FloodDurationCurveFacet.class); |
29 | |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
30 // /** Blackboard data provider key for durationcurve (wqday) data. */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
31 // public static String BB_DURATIONCURVE = "durationcurve"; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
32 // |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
33 // /** Blackboard data provider key for km of durationcurve. */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
34 // public static String BB_DURATIONCURVE_KM = "durationcurve.km"; |
9252 | 35 |
36 public FloodDurationCurveFacet() { | |
37 } | |
38 | |
39 public FloodDurationCurveFacet(final String name, final String description) { | |
40 super(0, name, description); | |
41 } | |
42 | |
43 | |
44 /** | |
45 * Expose state computation from SINFOArtifact. | |
46 */ | |
47 @Override | |
48 public Object getData(final Artifact artifact, final CallContext context) { | |
49 | |
50 log.debug("Get data for flood duration curve data"); | |
51 | |
52 final D4EArtifact flys = (D4EArtifact) artifact; | |
53 | |
9268
ae9dee74e43e
Fixed: current station of duration chart was not changed
gernotbelger
parents:
9266
diff
changeset
|
54 // TODO: wird das hier noch benötigt? |
ae9dee74e43e
Fixed: current station of duration chart was not changed
gernotbelger
parents:
9266
diff
changeset
|
55 // final CalculationResult res = (CalculationResult) flys.compute(context, ComputeType.ADVANCE, false); |
ae9dee74e43e
Fixed: current station of duration chart was not changed
gernotbelger
parents:
9266
diff
changeset
|
56 // final FloodDurationCalculationResults data = (FloodDurationCalculationResults) res.getData(); |
9265 | 57 |
9268
ae9dee74e43e
Fixed: current station of duration chart was not changed
gernotbelger
parents:
9266
diff
changeset
|
58 final double currentKm = FixChartGenerator.getCurrentKm(context); |
ae9dee74e43e
Fixed: current station of duration chart was not changed
gernotbelger
parents:
9266
diff
changeset
|
59 return new FloodDurationCalculation(context).calcStationCurve(currentKm, (SINFOArtifact) flys); |
9252 | 60 } |
61 | |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
62 // private WQDay getTestData() { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
63 // final int[] days = new int[366]; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
64 // final double[] ws = new double[366]; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
65 // final double[] qs = new double[366]; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
66 // for (int i = 0; i <= 365; i++) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
67 // days[i] = i; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
68 // final double x = (i - 182.5) / 182.5; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
69 // ws[i] = 102.0 - (Math.pow(x, 5) + x); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
70 // qs[i] = 1600.0 - 800 * (Math.pow(x, 9) + x); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
71 // } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
72 // return new WQDay(days, ws, qs); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
73 // } |
9252 | 74 |
9257
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
75 // @Override |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
76 // public List getStaticDataProviderKeys(final Artifact art) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
77 // final List list = new ArrayList(); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
78 // list.add(BB_DURATIONCURVE); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
79 // list.add(BB_DURATIONCURVE_KM); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
80 // return list; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
81 // } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
82 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
83 |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
84 // /** |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
85 // * Can provide whatever getData returns and additionally the location. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
86 // * @param key will respond on BB_DURATIONCURVE +KM |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
87 // * @param param ignored |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
88 // * @param context ignored |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
89 // * @return whatever getData delivers or location. |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
90 // */ |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
91 // @Override |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
92 // public Object provideBlackboardData(final Artifact artifact, |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
93 // final Object key, |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
94 // final Object param, |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
95 // final CallContext context |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
96 // ) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
97 // if (key.equals(BB_DURATIONCURVE)) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
98 // return getData(artifact, context); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
99 // } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
100 // else if (key.equals(BB_DURATIONCURVE_KM)) { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
101 // return ((D4EArtifact)artifact).getDataAsString("ld_locations"); |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
102 // } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
103 // else { |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
104 // return null; |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
105 // } |
ef7b65576d4b
Added W and Q main values to S-Info flood duration curve chart
mschaefer
parents:
9252
diff
changeset
|
106 // } |
9252 | 107 |
108 | |
109 /** Create a deep copy. */ | |
110 @Override | |
111 public Facet deepCopy() { | |
112 final FloodDurationCurveFacet copy = new FloodDurationCurveFacet(); | |
113 copy.set(this); | |
114 return copy; | |
115 } | |
116 } | |
117 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |