Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java @ 9040:5294114b1df4
Fixed/changed some FIXMEs/TODOs
author | gernotbelger |
---|---|
date | Wed, 02 May 2018 12:19:31 +0200 |
parents | b194fa64506a |
children | 23945061daec |
rev | line source |
---|---|
8854 | 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.flowdepth; | |
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.model.Calculation; | |
18 import org.dive4elements.river.artifacts.model.CalculationResult; | |
19 import org.dive4elements.river.artifacts.model.DataFacet; | |
20 import org.dive4elements.river.artifacts.model.EmptyFacet; | |
21 import org.dive4elements.river.artifacts.model.FacetTypes; | |
22 import org.dive4elements.river.artifacts.model.ReportFacet; | |
23 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact; | |
8940
82998242ba84
Preparing for additional outputs of SINFO-Tkh
gernotbelger
parents:
8916
diff
changeset
|
24 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthProcessor; |
8916 | 25 import org.dive4elements.river.artifacts.sinfo.common.TkhProcessor; |
8854 | 26 import org.dive4elements.river.artifacts.states.DefaultState; |
27 | |
28 /** State in which a waterlevel has been calculated. */ | |
8884 | 29 public class FlowDepthState extends DefaultState { |
30 | |
8854 | 31 /// ** The log that is used in this state. */ |
32 // private static Logger log = Logger.getLogger(FlowDepthState.class); | |
33 | |
8877 | 34 private static final long serialVersionUID = 1L; |
35 | |
8854 | 36 /** |
37 * From this state can only be continued trivially. | |
38 */ | |
39 @Override | |
40 protected String getUIProvider() { | |
41 return "continue"; | |
42 } | |
43 | |
44 @Override | |
8884 | 45 public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { |
8879 | 46 if (artifact instanceof ChartArtifact) { |
47 facets.add(new EmptyFacet()); | |
48 return null; | |
49 } | |
50 | |
51 return compute((SINFOArtifact) artifact, context, hash, facets, old); | |
52 } | |
53 | |
54 @Override | |
8884 | 55 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { |
8854 | 56 if (artifact instanceof ChartArtifact) { |
57 facets.add(new EmptyFacet()); | |
58 return null; | |
59 } | |
60 return compute((SINFOArtifact) artifact, context, hash, facets, old); | |
61 } | |
62 | |
63 /** | |
64 * Compute result or returned object from cache, create facets. | |
8884 | 65 * |
66 * @param old | |
67 * Object that was cached. | |
8854 | 68 */ |
8884 | 69 private Object compute(final SINFOArtifact sinfo, final CallContext context, final String hash, final List<Facet> facets, final Object old) { |
8879 | 70 |
8914
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
71 final CalculationResult res = doCompute(sinfo, context, old); |
8854 | 72 |
8914
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
73 if (facets == null) |
8854 | 74 return res; |
75 | |
8884 | 76 final FlowDepthCalculationResults results = (FlowDepthCalculationResults) res.getData(); |
8854 | 77 |
78 /* add themes for chart, for each result */ | |
79 final List<FlowDepthCalculationResult> resultList = results.getResults(); | |
80 for (int index = 0; index < resultList.size(); index++) { | |
81 | |
8879 | 82 final FlowDepthCalculationResult result = resultList.get(index); |
83 | |
84 /* filtered (zoom dependent mean) flow depth */ | |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8940
diff
changeset
|
85 facets.add(FlowDepthProcessor.createFlowDepthFilteredFacet(context, hash, this.id, result, index)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8940
diff
changeset
|
86 facets.add(FlowDepthProcessor.createFlowDepthRawFacet(context, hash, this.id, result, index)); |
8879 | 87 |
8884 | 88 if (results.isUseTkh()) { |
89 /* filtered (zoom dependent mean) flow depth including tkh */ | |
8980
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8940
diff
changeset
|
90 facets.add(FlowDepthProcessor.createFlowDepthTkhFilteredFacet(context, hash, this.id, result, index)); |
b194fa64506a
SINFO - show results themes according to spec, either raw data or floating mean values.
gernotbelger
parents:
8940
diff
changeset
|
91 facets.add(FlowDepthProcessor.createFlowDepthTkhRawFacet(context, hash, this.id, result, index)); |
8884 | 92 |
8916 | 93 facets.add(TkhProcessor.createTkhFacet(context, hash, this.id, result, index)); |
8884 | 94 } |
8879 | 95 } |
8854 | 96 |
8884 | 97 if (!resultList.isEmpty()) { |
98 final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id); | |
99 final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id); | |
8854 | 100 |
101 facets.add(csv); | |
102 facets.add(pdf); | |
103 } | |
104 | |
105 final Calculation report = res.getReport(); | |
106 | |
107 if (report.hasProblems()) { | |
8879 | 108 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id)); |
8854 | 109 } |
110 | |
111 return res; | |
112 } | |
8914
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
113 |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
114 private CalculationResult doCompute(final SINFOArtifact sinfo, final CallContext context, final Object old) { |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
115 if (old instanceof CalculationResult) |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
116 return (CalculationResult) old; |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
117 |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
118 return new FlowDepthCalculation(context).calculate(sinfo); |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
119 } |
8854 | 120 } |