Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstState.java @ 9495:bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
author | gernotbelger |
---|---|
date | Tue, 25 Sep 2018 16:43:51 +0200 |
parents | ecadc9ed0ba0 |
children |
rev | line source |
---|---|
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
2 * Software engineering by |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
3 * Björnsen Beratende Ingenieure GmbH |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
5 * |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
6 * This file is Free Software under the GNU AGPL (>=v3) |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
8 * documentation coming with Dive4Elements River for details. |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
9 */ |
9274 | 10 |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
11 package org.dive4elements.river.artifacts.bundu.bezugswst; |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
12 |
9274 | 13 import java.util.List; |
14 | |
15 import org.apache.log4j.Logger; | |
16 import org.dive4elements.artifactdatabase.state.Facet; | |
17 import org.dive4elements.artifacts.CallContext; | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
18 import org.dive4elements.river.artifacts.ChartArtifact; |
9274 | 19 import org.dive4elements.river.artifacts.D4EArtifact; |
9313 | 20 import org.dive4elements.river.artifacts.bundu.BUNDUArtifact; |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
21 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
22 import org.dive4elements.river.artifacts.model.Calculation; |
9274 | 23 import org.dive4elements.river.artifacts.model.CalculationResult; |
24 import org.dive4elements.river.artifacts.model.DataFacet; | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
25 import org.dive4elements.river.artifacts.model.EmptyFacet; |
9274 | 26 import org.dive4elements.river.artifacts.model.FacetTypes; |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
27 import org.dive4elements.river.artifacts.model.ReportFacet; |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
28 import org.dive4elements.river.artifacts.states.DefaultState; |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
29 import org.dive4elements.river.model.BedHeightValueType; |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
30 |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
31 /** |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
32 * State to compute the bundu bezugswst results. |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
33 */ |
9274 | 34 public class BezugswstState extends DefaultState implements FacetTypes { |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
35 |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
36 private static final long serialVersionUID = 1L; |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
37 |
9274 | 38 /** The log used in this class. */ |
39 private static Logger log = Logger.getLogger(BezugswstState.class); | |
40 | |
9360
ddcd52d239cd
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
gernotbelger
parents:
9318
diff
changeset
|
41 private static final String I18N_WQ_CURVE = "fix.vollmer.wq.curve"; |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
42 |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
43 /** |
9274 | 44 * The default constructor that initializes an empty State object. |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
45 */ |
9274 | 46 public BezugswstState() { |
9072
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
47 } |
02739b8c010d
bundu progress (Klon FixationAnalysis +Vollmer funktioniert; Verzweigung neue Berechnungsart Bezugswst)
gernotbelger
parents:
diff
changeset
|
48 |
9274 | 49 @Override |
50 public Object computeAdvance(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
51 |
9274 | 52 log.debug("BezugswstState.computeAdvance"); |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
53 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
54 if (artifact instanceof ChartArtifact) { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
55 facets.add(new EmptyFacet()); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
56 return null; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
57 } |
9313 | 58 return compute((BUNDUArtifact) artifact, context, hash, facets, old); |
59 } | |
9274 | 60 |
9313 | 61 @Override |
62 public Object computeFeed(final D4EArtifact artifact, final String hash, final CallContext context, final List<Facet> facets, final Object old) { | |
9274 | 63 |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
64 if (artifact instanceof ChartArtifact) { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
65 facets.add(new EmptyFacet()); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
66 return null; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
67 } |
9313 | 68 return compute((BUNDUArtifact) artifact, context, hash, facets, old); |
69 } | |
9274 | 70 |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
71 /** |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
72 * Compute result or returned object from cache, create facets. |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
73 * |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
74 * @param old |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
75 * Object that was cached. |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
76 */ |
9313 | 77 private Object compute(final BUNDUArtifact artifact, final CallContext context, final String hash, final List<Facet> facets, final Object old) { |
9274 | 78 |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
79 final CalculationResult res = doCompute(artifact, context, old); |
9274 | 80 |
9313 | 81 if (facets == null) |
82 return res; | |
9274 | 83 |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
84 final BezugswstCalculationResults results = (BezugswstCalculationResults) res.getData(); |
9313 | 85 |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
86 final List<AbstractCalculationExportableResult> resultList = results.getResults(); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
87 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
88 int facetIndex = 0; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
89 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
90 if (!resultList.isEmpty()) { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
91 final BezugswstMainCalculationResult result = (BezugswstMainCalculationResult) resultList.get(0); |
9495
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
92 |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
93 final boolean hasSounding = results.hasSounding(); |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
94 |
9438
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9432
diff
changeset
|
95 final String nameQ = result.getWstLabel(); |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9432
diff
changeset
|
96 final String nameW = "W(" + nameQ + ")"; |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9432
diff
changeset
|
97 facets.add(new BezugswstFixationFacet(0, LONGITUDINAL_W, nameW, ComputeType.ADVANCE, hash, this.id)); |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9432
diff
changeset
|
98 facets.add(new BezugswstFixationFacet(0, LONGITUDINAL_Q, nameQ, ComputeType.ADVANCE, hash, this.id)); |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
99 |
9495
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
100 if (hasSounding) { |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
101 facets.add(BezugswstHeightProcessor.createChannelminFacet(context, hash, this.id, facetIndex++, 0)); |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
102 facets.add(BezugswstHeightProcessor.createBedheightFacet(context, hash, this.id, facetIndex++, 0, result.getBedHeightLabel())); |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
103 |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
104 for (int i = BedHeightValueType.FIELD_FIRST_INDEX; i <= BedHeightValueType.FIELD_LAST_INDEX; i++) |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
105 facets.add(BezugswstHeightProcessor.createFieldBedheightFacet(context, hash, this.id, facetIndex++, 0, i)); |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
106 |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
107 facets.add(BezugswstDepthProcessor.createFlowdepthFilteredFacet(context, hash, this.id, facetIndex++, 0, result.getBedHeightLabel())); |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
108 facets.add(BezugswstDepthProcessor.createChanneldepthFacet(context, hash, this.id, facetIndex++, 0)); |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
109 for (int i = BedHeightValueType.FIELD_FIRST_INDEX; i <= BedHeightValueType.FIELD_LAST_INDEX; i++) |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
110 facets.add(BezugswstDepthProcessor.createFieldDepthFacet(context, hash, this.id, facetIndex++, 0, i)); |
bb278c927b66
Datenkorb bezugswasserstände längsschnitte + minor fixes
gernotbelger
parents:
9444
diff
changeset
|
111 } |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
112 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
113 final Facet csv = new DataFacet(FacetTypes.CSV, "CSV data", ComputeType.ADVANCE, hash, this.id); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
114 final Facet pdf = new DataFacet(FacetTypes.PDF, "PDF data", ComputeType.ADVANCE, hash, this.id); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
115 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
116 facets.add(csv); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
117 facets.add(pdf); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
118 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
119 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
120 final Calculation report = res.getReport(); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
121 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
122 if (report.hasProblems()) |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
123 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, this.id)); |
9274 | 124 |
125 return res; | |
126 } | |
9313 | 127 |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
128 private CalculationResult doCompute(final BUNDUArtifact uinfo, final CallContext context, final Object old) { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
129 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
130 if (old instanceof CalculationResult) |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
131 return (CalculationResult) old; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
132 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
133 return new BezugswstCalculation(context).calculate(uinfo); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9360
diff
changeset
|
134 } |
9274 | 135 } |