Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java @ 9630:8da911b5169c
3 Significant also for Q_1, Q_2...
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Mon, 14 Oct 2019 18:07:31 +0200 |
parents | 677ff7ed9a60 |
children |
rev | line source |
---|---|
9145 | 1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.sinfo.flood_duration; | |
11 | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
12 import java.text.NumberFormat; |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
13 import java.util.ArrayList; |
9145 | 14 import java.util.Collection; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
15 import java.util.Collections; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
16 import java.util.List; |
9612 | 17 import java.util.Map.Entry; |
18 import java.util.Set; | |
9145 | 19 |
9265 | 20 import org.apache.commons.collections.Predicate; |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
21 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
22 import org.dive4elements.river.artifacts.common.AbstractExportContext; |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
23 import org.dive4elements.river.artifacts.common.ExportContextCSV; |
9195 | 24 import org.dive4elements.river.artifacts.common.ExportContextPDF; |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
25 import org.dive4elements.river.artifacts.common.GeneralResultType; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
26 import org.dive4elements.river.artifacts.common.IResultType; |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
27 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; |
9145 | 28 import org.dive4elements.river.artifacts.common.ResultRow; |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
29 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
30 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
9145 | 31 |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
32 import gnu.trove.TDoubleArrayList; |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
33 |
9145 | 34 /** |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
35 * Contains the result of a {@link FloodDurationCalculation}. |
9145 | 36 * |
37 * @author Gernot Belger | |
38 */ | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
39 public final class FloodDurationCalculationResult extends AbstractCalculationExportableResult { |
9145 | 40 |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
41 private final static class IsInfrastructureChoicePredicate implements Predicate { |
9265 | 42 |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
43 private final FloodDurationInfrastructureChoice m_infrastructure; |
9265 | 44 |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
45 public IsInfrastructureChoicePredicate(final FloodDurationInfrastructureChoice infrastructure) { |
9612 | 46 this.m_infrastructure = infrastructure; |
9265 | 47 } |
48 | |
49 @Override | |
50 public boolean evaluate(final Object object) { | |
51 final ResultRow row = (ResultRow) object; | |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
52 final FloodDurationInfrastructureChoice test = new FloodDurationInfrastructureChoice(row); |
9612 | 53 return this.m_infrastructure.equals(test); |
9265 | 54 } |
55 } | |
56 | |
9585 | 57 private final static class HasInfrastructurePredicate implements Predicate { |
58 | |
59 @Override | |
60 public boolean evaluate(final Object object) { | |
61 final ResultRow row = (ResultRow) object; | |
62 | |
63 return row.getValue(SInfoResultType.riverside) != null; | |
64 } | |
65 } | |
66 | |
9145 | 67 private static final long serialVersionUID = 1L; |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
68 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
69 private final boolean isUseWspl; |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
70 |
9285 | 71 private final String[] waterlevelLabels; |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
72 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
73 private final int maxWaterlevelPdf = 3; |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
74 |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
75 private final Set<FloodDurationInfrastructureChoice> m_infrastructures; |
9612 | 76 |
9208 | 77 public interface ValueGetter { |
9215 | 78 double getValue(DurationWaterlevel waterlevel); |
9208 | 79 } |
80 | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
81 private enum ExportMode { |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
82 pdf, csv |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
83 } |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
84 |
9612 | 85 public FloodDurationCalculationResult(final String label, final String[] mainvalueLabels, final Collection<ResultRow> rows, final boolean isUseWspl, |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
86 final Set<FloodDurationInfrastructureChoice> infrastructures) { |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
87 super(label, rows); |
9285 | 88 this.waterlevelLabels = mainvalueLabels; |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
89 this.isUseWspl = isUseWspl; |
9614
d889ffe2fb05
Nachtrag Pos. 20: rename type/part to group/type, group added in Infrastructure class
mschaefer
parents:
9612
diff
changeset
|
90 this.m_infrastructures = infrastructures; |
9612 | 91 } |
92 | |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
93 public Set<FloodDurationInfrastructureChoice> getInfrastructureMap() { |
9614
d889ffe2fb05
Nachtrag Pos. 20: rename type/part to group/type, group added in Infrastructure class
mschaefer
parents:
9612
diff
changeset
|
94 return this.m_infrastructures; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
95 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
96 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
97 /** |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
98 * Collection of the result rows containing only the rows describing an infrastructure |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
99 */ |
9265 | 100 // FIXME: bad to override, instead make new method 'getInfrastructureRows' or similar? |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
101 @Override |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
102 public Collection<ResultRow> getRows() { |
9265 | 103 |
104 final Collection<ResultRow> rows = super.getRows(); | |
105 | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
106 final List<ResultRow> infrasOnlyRows = new ArrayList<>(); |
9265 | 107 for (final ResultRow row : rows) { |
9614
d889ffe2fb05
Nachtrag Pos. 20: rename type/part to group/type, group added in Infrastructure class
mschaefer
parents:
9612
diff
changeset
|
108 if (row.getValue(SInfoResultType.infrastructuregroup) != null && row.getValue(SInfoResultType.infrastructuretype) != null) |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
109 infrasOnlyRows.add(row); |
9265 | 110 } |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
111 return Collections.unmodifiableCollection(infrasOnlyRows); |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
112 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
113 |
9298
0b1a51b0c42e
Included the infrastructure-less stations in the S-Info flood duration long. sections, and the selected wspls in their w/q duration curves
mschaefer
parents:
9297
diff
changeset
|
114 /** |
0b1a51b0c42e
Included the infrastructure-less stations in the S-Info flood duration long. sections, and the selected wspls in their w/q duration curves
mschaefer
parents:
9297
diff
changeset
|
115 * Collection of all result rows |
0b1a51b0c42e
Included the infrastructure-less stations in the S-Info flood duration long. sections, and the selected wspls in their w/q duration curves
mschaefer
parents:
9297
diff
changeset
|
116 */ |
0b1a51b0c42e
Included the infrastructure-less stations in the S-Info flood duration long. sections, and the selected wspls in their w/q duration curves
mschaefer
parents:
9297
diff
changeset
|
117 public Collection<ResultRow> getAllRows() { |
0b1a51b0c42e
Included the infrastructure-less stations in the S-Info flood duration long. sections, and the selected wspls in their w/q duration curves
mschaefer
parents:
9297
diff
changeset
|
118 |
0b1a51b0c42e
Included the infrastructure-less stations in the S-Info flood duration long. sections, and the selected wspls in their w/q duration curves
mschaefer
parents:
9297
diff
changeset
|
119 return super.getRows(); |
0b1a51b0c42e
Included the infrastructure-less stations in the S-Info flood duration long. sections, and the selected wspls in their w/q duration curves
mschaefer
parents:
9297
diff
changeset
|
120 } |
0b1a51b0c42e
Included the infrastructure-less stations in the S-Info flood duration long. sections, and the selected wspls in their w/q duration curves
mschaefer
parents:
9297
diff
changeset
|
121 |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
122 @Override |
9195 | 123 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { |
9294
7a8b9331a946
Moved waterlevel metadata block to global metadata, because its only written once
gernotbelger
parents:
9285
diff
changeset
|
124 /* nothing to do, as we never have several results, everything is written into the general header */ |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
125 } |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
126 |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
127 @Override |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
128 protected String getJasperFile() { |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
129 if (this.getWaterlevelCount() <= 1) |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
130 return "/jasper/templates/sinfo.floodduration.jrxml"; |
9265 | 131 |
132 return "/jasper/templates/sinfo.floodduration2.jrxml"; | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
133 } |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
134 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
135 protected String[] formatRow(final AbstractExportContext exportContextCSV, final ResultRow row, final ExportMode mode) { |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
136 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
137 final Collection<String> lines = new ArrayList<>(20); |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
138 |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
139 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
140 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.riverside)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
141 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDuration)); |
9612 | 142 |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
143 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDischarge)); |
9612 | 144 |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
145 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructureHeight)); |
9614
d889ffe2fb05
Nachtrag Pos. 20: rename type/part to group/type, group added in Infrastructure class
mschaefer
parents:
9612
diff
changeset
|
146 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructuregroup)); |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
147 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructuretype)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
148 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
149 final List<DurationWaterlevel> waterlevelList = (List<DurationWaterlevel>) row.getValue(SInfoResultType.customMultiRowColWaterlevel); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
150 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
151 final int expectedSizetoGaugelabel = lines.size() + (waterlevelList.size() < 2 ? 4 : 12); // removing columns only works for fixed |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
152 // indices |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
153 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
154 final NumberFormat wFormatter = exportContextCSV.getFlowDepthFormatter(); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
155 final NumberFormat qFormatter = exportContextCSV.getQFormatter(); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
156 final NumberFormat durFormatter = exportContextCSV.getFloodDurationFormatter(); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
157 |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
158 for (int i = 0; i < waterlevelList.size(); i++) { |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
159 |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
160 if (i == this.maxWaterlevelPdf && mode == ExportMode.pdf) |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
161 break; |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
162 |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
163 final DurationWaterlevel item = waterlevelList.get(i); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
164 lines.add(item.getWFormatted(wFormatter)); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
165 lines.add(item.getFloodDurDaysPerYearFormatted(durFormatter)); |
9630
8da911b5169c
3 Significant also for Q_1, Q_2...
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9623
diff
changeset
|
166 lines.add(item.getQFormatted3Significant(exportContextCSV.getContext())); |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
167 lines.add(item.getBezeichnung()); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
168 } |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
169 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
170 while (mode == ExportMode.pdf && lines.size() < expectedSizetoGaugelabel) |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
171 lines.add(""); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
172 |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
173 if (isUseWspl() || mode == ExportMode.pdf) |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
174 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.gaugeLabel)); // PDF: necessary, because if removed, location would not be shown! |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
175 |
9312 | 176 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.location)); |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
177 |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
178 return lines.toArray(new String[lines.size()]); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
179 } |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
180 |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
181 @Override |
9195 | 182 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
183 |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
184 final Collection<String> header = new ArrayList<>(20); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
185 |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
186 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
187 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.riverside)); |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
188 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.floodDuration)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
189 header.add(exportContextCSV.msgUnitCSV(SInfoResultType.floodDischarge, SInfoResultType.floodDischarge.getUnit())); |
9297
7100a555607c
Small fixes of the S-Info flood duration outputs
mschaefer
parents:
9294
diff
changeset
|
190 header.add(exportContextCSV.msgUnitCSV(SInfoResultType.infrastructureHeight, river.getWstUnit())); |
9614
d889ffe2fb05
Nachtrag Pos. 20: rename type/part to group/type, group added in Infrastructure class
mschaefer
parents:
9612
diff
changeset
|
191 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.infrastructuregroup)); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
192 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.infrastructuretype)); |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
193 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
194 // add dynamic headers |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
195 final int waterlevelCount = // results. |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
196 getWaterlevelCount(); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
197 for (int i = 0; i < waterlevelCount; i++) { |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
198 final String appendIndex = "_" + Integer.toString(i + 1); |
9297
7100a555607c
Small fixes of the S-Info flood duration outputs
mschaefer
parents:
9294
diff
changeset
|
199 header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderWCsv(), appendIndex, river.getWstUnit())); |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
200 header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderFloodDurPerYearCsv(), appendIndex)); |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
201 header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderQ(), appendIndex)); |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
202 header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderBezeichnCsv(), appendIndex)); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
203 } |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
204 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
205 if (isUseWspl()) |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
206 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
207 |
9312 | 208 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
209 |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
210 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); |
9265 | 211 } |
9145 | 212 |
9265 | 213 public List<Double> getValidDurationChartKilometers() { |
9585 | 214 |
215 // Wunsch BfG (Testung MS3): nur stationen mit infrastruktur | |
216 final Predicate filter = new HasInfrastructurePredicate(); | |
217 return getValues(GeneralResultType.station, filter); | |
9145 | 218 } |
219 | |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
220 @Override |
9195 | 221 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
222 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
223 return this.formatRow(exportContextCSV, row, ExportMode.csv); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
224 } |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
225 |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
226 @Override |
9195 | 227 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
228 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
229 return this.formatRow(exportContextPDF, row, ExportMode.pdf); |
9145 | 230 } |
231 | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
232 @Override |
9195 | 233 protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
234 |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
235 /* column headings */ |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
236 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
237 exportContextPDF.addJRMetadata(source, "riverside_header", SInfoResultType.riverside); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
238 exportContextPDF.addJRMetadata(source, "inundationduration_header", SInfoResultType.floodDuration); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
239 exportContextPDF.addJRMetadata(source, "inundationduration_q_header", SInfoResultType.floodDischarge); |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
240 exportContextPDF.addJRMetadata(source, "infrastructure_height_header", SInfoResultType.infrastructureHeight); |
9622
36d201244529
jasperreports rename infrastructure ..type => ..group and ..part => ..type
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9614
diff
changeset
|
241 exportContextPDF.addJRMetadata(source, "infrastructure_group_header", SInfoResultType.infrastructuregroup); |
36d201244529
jasperreports rename infrastructure ..type => ..group and ..part => ..type
dnt_bjoernsen <d.tironi@bjoernsen.de>
parents:
9614
diff
changeset
|
242 exportContextPDF.addJRMetadata(source, "infrastructure_type_header", SInfoResultType.infrastructuretype); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
243 |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
244 for (int i = 1; i <= this.getWaterlevelCount(); i++) { |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
245 |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
246 final String appendIndex = "_" + Integer.toString(i); |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
247 exportContextPDF.addJRMetadata(source, getPdfHeader("w", i), exportContextPDF.msg(DurationWaterlevel.getHeaderWPdf(), appendIndex)); |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
248 exportContextPDF.addJRMetadata(source, getPdfHeader("duration", i), |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
249 exportContextPDF.msg(DurationWaterlevel.getHeaderFloodDurPerYearPdf(), appendIndex)); |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
250 exportContextPDF.addJRMetadata(source, getPdfHeader("q", i), exportContextPDF.msg(DurationWaterlevel.getHeaderQ(), appendIndex)); |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
251 exportContextPDF.addJRMetadata(source, getPdfHeader("bezeichnung", i), |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
252 exportContextPDF.msg(DurationWaterlevel.getHeaderBezeichnPdf(), appendIndex)); |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
253 } |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
254 |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9312
diff
changeset
|
255 exportContextPDF.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); |
9312 | 256 exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
257 } |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
258 |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
259 private final String getPdfHeader(final String rootStr, final int index) { |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
260 final String hd = "_header"; |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
261 final StringBuilder builder = new StringBuilder(); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
262 return builder.append(rootStr).append("_").append(index).append(hd).toString(); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
263 } |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
264 |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
265 public final int getWaterlevelCount() { |
9285 | 266 return (this.waterlevelLabels != null) ? this.waterlevelLabels.length : 0; |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
267 } |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
268 |
9285 | 269 public String getWaterlevelLabel(final int j) { |
270 if (this.waterlevelLabels != null && j < this.waterlevelLabels.length) | |
271 return this.waterlevelLabels[j]; | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
272 return ""; |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
273 } |
9208 | 274 |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
275 /** |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
276 * Gets the longitudinal section of a result value type for one river side |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
277 */ |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
278 public final double[][] getInfrastructurePoints(final IResultType type, final FloodDurationInfrastructureChoice infrastructure) { |
9612 | 279 |
9620
26e113e8224f
Nachtrag Pos. 20: flood duration calculation for multiple infrastructure groups/types,
mschaefer
parents:
9614
diff
changeset
|
280 return getPoints(GeneralResultType.station, type, new IsInfrastructureChoicePredicate(infrastructure)); |
9229
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
281 } |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
282 |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
283 /** |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
284 * Gets a longitudinal section of W, Q, or flood duration of one of the waterlevels |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
285 */ |
9265 | 286 public final double[][] getMainValueDurationPoints(final ValueGetter valuegetter, final int dataIndex) { |
9208 | 287 |
9298
0b1a51b0c42e
Included the infrastructure-less stations in the S-Info flood duration long. sections, and the selected wspls in their w/q duration curves
mschaefer
parents:
9297
diff
changeset
|
288 final Collection<ResultRow> rows = getAllRows(); |
9208 | 289 |
9265 | 290 final TDoubleArrayList xPoints = new TDoubleArrayList(rows.size()); |
291 final TDoubleArrayList yPoints = new TDoubleArrayList(rows.size()); | |
292 | |
293 for (final ResultRow row : rows) { | |
9208 | 294 |
295 final double station = row.getDoubleValue(GeneralResultType.station); | |
296 | |
297 final List<DurationWaterlevel> waterlevels = (List<DurationWaterlevel>) row.getValue(SInfoResultType.customMultiRowColWaterlevel); | |
298 final DurationWaterlevel waterlevel = waterlevels.get(dataIndex); | |
299 | |
300 final Double value = valuegetter.getValue(waterlevel); | |
301 | |
302 xPoints.add(station); | |
303 yPoints.add(value); | |
304 } | |
305 | |
306 return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() }; | |
307 } | |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
308 |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
309 public boolean isUseWspl() { |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
310 return this.isUseWspl; |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
311 } |
9612 | 312 |
313 public Collection<Entry<String, String>> getUniqueInfrastruktureTypes() { | |
314 // TODO Auto-generated method stub | |
315 return null; | |
316 } | |
9145 | 317 } |