comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkh/TkhState.java @ 8914:e3519c3e7a0a

Workflow for SINFO-Transport bodies heights inclduing winfo calculation
author gernotbelger
date Tue, 27 Feb 2018 18:06:52 +0100
parents
children
comparison
equal deleted inserted replaced
8913:924cd9943337 8914:e3519c3e7a0a
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.tkh;
10
11 import java.util.List;
12
13 import org.dive4elements.artifactdatabase.state.Facet;
14 import org.dive4elements.artifacts.CallContext;
15 import org.dive4elements.river.artifacts.ChartArtifact;
16 import org.dive4elements.river.artifacts.D4EArtifact;
17 import org.dive4elements.river.artifacts.WINFOArtifact;
18 import org.dive4elements.river.artifacts.model.Calculation;
19 import org.dive4elements.river.artifacts.model.CalculationResult;
20 import org.dive4elements.river.artifacts.model.EmptyFacet;
21 import org.dive4elements.river.artifacts.model.WQKms;
22 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
23 import org.dive4elements.river.artifacts.states.DefaultState;
24
25 /** State in which a waterlevel has been calculated. */
26 public class TkhState extends DefaultState {
27
28 /// ** The log that is used in this state. */
29 // private static Logger log = Logger.getLogger(FlowDepthState.class);
30
31 private static final long serialVersionUID = 1L;
32
33 private static final String I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth.filtered.description";
34
35 private static final String I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION = "sinfo.facet.flow_depth.tkh.filtered.description";
36
37 private static final String I18N_FACET_TKH_DESCRIPTION = "sinfo.facet.tkh.description";
38
39 private static final String SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL = "sinfo.chart.flow_depth.yaxis.label";
40
41 private static final String SINFO_CHART_TKX_YAXIS_LABEL = "sinfo.chart.tkh.yaxis.label";
42
43 /**
44 * From this state can only be continued trivially.
45 */
46 @Override
47 protected String getUIProvider() {
48 return "continue";
49 }
50
51 @Override
52 public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) {
53 // FIXME: why is this necessary?
54 if (artifact instanceof ChartArtifact) {
55 facets.add(new EmptyFacet());
56 return null;
57 }
58
59 return compute((SINFOArtifact) artifact, context, hash, facets, old);
60 }
61
62 @Override
63 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) {
64 if (artifact instanceof ChartArtifact) {
65 facets.add(new EmptyFacet());
66 return null;
67 }
68 return compute((SINFOArtifact) artifact, context, hash, facets, old);
69 }
70
71 /**
72 * Compute result or returned object from cache, create facets.
73 *
74 * @param old
75 * Object that was cached.
76 */
77 private Object compute(final SINFOArtifact sinfo, final CallContext context, final String hash, final List<Facet> facets, final Object old) {
78
79 final CalculationResult res = doCompute(sinfo, context, old);
80
81 if (facets == null)
82 return res;
83
84 // final FlowDepthCalculationResults results = (FlowDepthCalculationResults) res.getData();
85 //
86 // /* add themes for chart, for each result */
87 // final List<FlowDepthCalculationResult> resultList = results.getResults();
88 // for (int index = 0; index < resultList.size(); index++) {
89 //
90 // final FlowDepthCalculationResult result = resultList.get(index);
91 //
92 // /* filtered (zoom dependent mean) flow depth */
93 // final String facetFlowDepthFilteredDescription = Resources.getMsg(context.getMeta(),
94 // I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION,
95 // I18N_FACET_FLOW_DEPTH_FILTERED_DESCRIPTION, result.getLabel());
96 // facets.add(new FlowDepthFacet(index, FlowDepthProcessor.FACET_FLOW_DEPTH_FILTERED, facetFlowDepthFilteredDescription,
97 // SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, ComputeType.ADVANCE, this.id, hash));
98 //
99 // if (results.isUseTkh()) {
100 // /* filtered (zoom dependent mean) flow depth including tkh */
101 // final String facetFlowDepthTkhFilteredDescription = Resources.getMsg(context.getMeta(),
102 // I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION,
103 // I18N_FACET_FLOW_DEPTH_TKH_FILTERED_DESCRIPTION, result.getLabel());
104 // facets.add(new FlowDepthFacet(index, FlowDepthProcessor.FACET_FLOW_DEPTH_TKH_FILTERED,
105 // facetFlowDepthTkhFilteredDescription,
106 // SINFO_CHART_FLOW_DEPTH_YAXIS_LABEL, ComputeType.ADVANCE, this.id, hash));
107 //
108 // // FIXME: add other themes
109 // // - Streckenfavoriten
110 //
111 // // FIXME:
112 // // - Gemittelte Linie der Fließtiefe mitsamt TKH
113 // // - Transportkörperhöhen (oben/unten/schraffur)
114 // final String facetTkhDescription = Resources.getMsg(context.getMeta(), I18N_FACET_TKH_DESCRIPTION,
115 // I18N_FACET_TKH_DESCRIPTION,
116 // result.getLabel());
117 // facets.add(new FlowDepthFacet(index, TkhProcessor.FACET_TKH, facetTkhDescription, SINFO_CHART_TKX_YAXIS_LABEL,
118 // ComputeType.ADVANCE, this.id,
119 // hash));
120 // }
121 //
122 // // FIXME: Datenkorbkonfiguration
123 // }
124 //
125 // if (!resultList.isEmpty()) {
126 // final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id);
127 // final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id);
128 //
129 // facets.add(csv);
130 // facets.add(pdf);
131 // }
132 //
133 // final Calculation report = res.getReport();
134 //
135 // if (report.hasProblems()) {
136 // facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id));
137 // }
138 //
139 // return res;
140 return null;
141 }
142
143 private CalculationResult doCompute(final SINFOArtifact sinfo, final CallContext context, final Object old) {
144 if (old instanceof CalculationResult)
145 return (CalculationResult) old;
146
147 // res = new FlowDepthCalculation(context).calculate(sinfo);
148
149 final WINFOArtifact winfo = new WinfoArtifactWrapper(sinfo);
150
151 final CalculationResult waterlevelData = winfo.getWaterlevelData(context);
152 final Calculation winfoProblems = waterlevelData.getReport();
153
154 final WQKms[] kms = (WQKms[]) waterlevelData.getData();
155
156 final Object result = new Object();
157 final Calculation problems = new Calculation();
158
159 return new CalculationResult(result, problems);
160 }
161 }

http://dive4elements.wald.intevation.org