Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthState.java @ 9617:1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Thu, 10 Oct 2019 15:29:02 +0200 |
parents | a4121ec450d6 |
children |
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; | |
9617
1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9195
diff
changeset
|
24 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthDischargeProcessor; |
8940
82998242ba84
Preparing for additional outputs of SINFO-Tkh
gernotbelger
parents:
8916
diff
changeset
|
25 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthProcessor; |
9617
1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9195
diff
changeset
|
26 import org.dive4elements.river.artifacts.sinfo.common.FlowDepthWaterlevelProcessor; |
8916 | 27 import org.dive4elements.river.artifacts.sinfo.common.TkhProcessor; |
8854 | 28 import org.dive4elements.river.artifacts.states.DefaultState; |
29 | |
30 /** State in which a waterlevel has been calculated. */ | |
8884 | 31 public class FlowDepthState extends DefaultState { |
32 | |
8854 | 33 /// ** The log that is used in this state. */ |
34 // private static Logger log = Logger.getLogger(FlowDepthState.class); | |
35 | |
8877 | 36 private static final long serialVersionUID = 1L; |
37 | |
8854 | 38 /** |
39 * From this state can only be continued trivially. | |
40 */ | |
41 @Override | |
42 protected String getUIProvider() { | |
43 return "continue"; | |
44 } | |
45 | |
46 @Override | |
8884 | 47 public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { |
8879 | 48 if (artifact instanceof ChartArtifact) { |
49 facets.add(new EmptyFacet()); | |
50 return null; | |
51 } | |
52 | |
53 return compute((SINFOArtifact) artifact, context, hash, facets, old); | |
54 } | |
55 | |
56 @Override | |
8884 | 57 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { |
8854 | 58 if (artifact instanceof ChartArtifact) { |
59 facets.add(new EmptyFacet()); | |
60 return null; | |
61 } | |
62 return compute((SINFOArtifact) artifact, context, hash, facets, old); | |
63 } | |
64 | |
65 /** | |
66 * Compute result or returned object from cache, create facets. | |
8884 | 67 * |
68 * @param old | |
69 * Object that was cached. | |
8854 | 70 */ |
8884 | 71 private Object compute(final SINFOArtifact sinfo, final CallContext context, final String hash, final List<Facet> facets, final Object old) { |
8879 | 72 |
8914
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
73 final CalculationResult res = doCompute(sinfo, context, old); |
8854 | 74 |
8914
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
75 if (facets == null) |
8854 | 76 return res; |
77 | |
8884 | 78 final FlowDepthCalculationResults results = (FlowDepthCalculationResults) res.getData(); |
8854 | 79 |
80 /* add themes for chart, for each result */ | |
9195 | 81 final List<FlowDepthCalculationResult> resultList = results.getResults(); |
8854 | 82 for (int index = 0; index < resultList.size(); index++) { |
83 | |
9195 | 84 final FlowDepthCalculationResult result = resultList.get(index); |
8879 | 85 |
9617
1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9195
diff
changeset
|
86 /* Discharge */ |
1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9195
diff
changeset
|
87 facets.add(FlowDepthDischargeProcessor.createFlowDepthDischargeFacet(context, hash, this.id, result, index, result.getWstLabel())); |
1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9195
diff
changeset
|
88 /* Result Type Wasserspiegellage, Mittl. Sohlhöhe */ |
1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9195
diff
changeset
|
89 final String unit = results.getRiver().getWstUnit(); |
1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9195
diff
changeset
|
90 facets.add(FlowDepthWaterlevelProcessor.createFlowDepthWaterlevelFacet(context, hash, this.id, result, index, unit, result.getWstLabel())); |
1d4262a68f1f
#12 Minuend/Subtrahend + MergeConflict #19 CollisionCalculation
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9195
diff
changeset
|
91 facets.add(FlowDepthWaterlevelProcessor.createFlowDepthMeanBedheightFacet(context, hash, this.id, result, index, unit, result.getSoundingLabel())); |
8879 | 92 /* 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
|
93 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
|
94 facets.add(FlowDepthProcessor.createFlowDepthRawFacet(context, hash, this.id, result, index)); |
8879 | 95 |
8884 | 96 if (results.isUseTkh()) { |
97 /* 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
|
98 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
|
99 facets.add(FlowDepthProcessor.createFlowDepthTkhRawFacet(context, hash, this.id, result, index)); |
8884 | 100 |
8916 | 101 facets.add(TkhProcessor.createTkhFacet(context, hash, this.id, result, index)); |
8884 | 102 } |
8879 | 103 } |
8854 | 104 |
8884 | 105 if (!resultList.isEmpty()) { |
106 final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id); | |
107 final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id); | |
8854 | 108 |
109 facets.add(csv); | |
110 facets.add(pdf); | |
111 } | |
112 | |
113 final Calculation report = res.getReport(); | |
114 | |
115 if (report.hasProblems()) { | |
8879 | 116 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id)); |
8854 | 117 } |
118 | |
119 return res; | |
120 } | |
8914
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
121 |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
122 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
|
123 if (old instanceof CalculationResult) |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
124 return (CalculationResult) old; |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
125 |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
126 return new FlowDepthCalculation(context).calculate(sinfo); |
e3519c3e7a0a
Workflow for SINFO-Transport bodies heights inclduing winfo calculation
gernotbelger
parents:
8884
diff
changeset
|
127 } |
8854 | 128 } |