Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java @ 9585:aa6ee96071b7
Punkt 6.2.1 Sprünge auf vollen HM
author | gernotbelger |
---|---|
date | Wed, 09 Jan 2019 18:07:51 +0100 |
parents | 10530f1d7dd5 |
children | f8308db94634 |
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; |
9145 | 17 |
9265 | 18 import org.apache.commons.collections.Predicate; |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
19 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
20 import org.dive4elements.river.artifacts.common.AbstractExportContext; |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
21 import org.dive4elements.river.artifacts.common.ExportContextCSV; |
9195 | 22 import org.dive4elements.river.artifacts.common.ExportContextPDF; |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
23 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
|
24 import org.dive4elements.river.artifacts.common.IResultType; |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
25 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; |
9145 | 26 import org.dive4elements.river.artifacts.common.ResultRow; |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
27 import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType; |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
28 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; |
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
|
29 import org.dive4elements.river.model.Attribute.AttributeKey; |
9145 | 30 |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
31 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
|
32 |
9145 | 33 /** |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
34 * Contains the result of a {@link FloodDurationCalculation}. |
9145 | 35 * |
36 * @author Gernot Belger | |
37 */ | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
38 public final class FloodDurationCalculationResult extends AbstractCalculationExportableResult { |
9145 | 39 |
9265 | 40 private final static class RiversidePredicate implements Predicate { |
41 | |
42 private final AttributeKey riverside; | |
43 | |
44 public RiversidePredicate(final AttributeKey riverside) { | |
45 this.riverside = riverside; | |
46 } | |
47 | |
48 @Override | |
49 public boolean evaluate(final Object object) { | |
50 final ResultRow row = (ResultRow) object; | |
51 | |
52 return row.getValue(SInfoResultType.riverside) == this.riverside; | |
53 } | |
54 } | |
55 | |
9585 | 56 private final static class HasInfrastructurePredicate implements Predicate { |
57 | |
58 @Override | |
59 public boolean evaluate(final Object object) { | |
60 final ResultRow row = (ResultRow) object; | |
61 | |
62 return row.getValue(SInfoResultType.riverside) != null; | |
63 } | |
64 } | |
65 | |
9145 | 66 private static final long serialVersionUID = 1L; |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
67 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
68 private final boolean isUseWspl; |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
69 |
9285 | 70 private final String[] waterlevelLabels; |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
71 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
72 private final int maxWaterlevelPdf = 3; |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
73 |
9208 | 74 public interface ValueGetter { |
9215 | 75 double getValue(DurationWaterlevel waterlevel); |
9208 | 76 } |
77 | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
78 private enum ExportMode { |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
79 pdf, csv |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
80 } |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
81 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
82 public FloodDurationCalculationResult(final String label, final String[] mainvalueLabels, final Collection<ResultRow> rows, final boolean isUseWspl) { |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
83 super(label, rows); |
9285 | 84 this.waterlevelLabels = mainvalueLabels; |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
85 this.isUseWspl = isUseWspl; |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
86 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
87 |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
88 /** |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
89 * 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
|
90 */ |
9265 | 91 // 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
|
92 @Override |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
93 public Collection<ResultRow> getRows() { |
9265 | 94 |
95 final Collection<ResultRow> rows = super.getRows(); | |
96 | |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
97 final List<ResultRow> infrasOnlyRows = new ArrayList<>(); |
9265 | 98 for (final ResultRow row : rows) { |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
99 if (row.getValue(SInfoResultType.infrastructuretype) != null) |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
100 infrasOnlyRows.add(row); |
9265 | 101 } |
9202
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
102 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
|
103 } |
b4402594213b
More work on calculations and output for S-Info flood duration workflow (chart types 1 and 2)
mschaefer
parents:
9195
diff
changeset
|
104 |
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
|
105 /** |
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
|
106 * 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
|
107 */ |
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
|
108 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
|
109 |
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
|
110 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
|
111 } |
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
|
112 |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
113 @Override |
9195 | 114 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
|
115 /* 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
|
116 } |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
117 |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
118 @Override |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
119 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
|
120 if (this.getWaterlevelCount() <= 1) |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
121 return "/jasper/templates/sinfo.floodduration.jrxml"; |
9265 | 122 |
123 return "/jasper/templates/sinfo.floodduration2.jrxml"; | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
124 } |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
125 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
126 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
|
127 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
128 final Collection<String> lines = new ArrayList<>(20); |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
129 |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
130 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
131 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.riverside)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
132 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDuration)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
133 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.floodDischarge)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
134 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructureHeight)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
135 lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructuretype)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
136 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
137 final List<DurationWaterlevel> waterlevelList = (List<DurationWaterlevel>) row.getValue(SInfoResultType.customMultiRowColWaterlevel); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
138 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
139 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
|
140 // indices |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
141 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
142 final NumberFormat wFormatter = exportContextCSV.getFlowDepthFormatter(); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
143 final NumberFormat qFormatter = exportContextCSV.getQFormatter(); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
144 final NumberFormat durFormatter = exportContextCSV.getFloodDurationFormatter(); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
145 |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
146 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
|
147 |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
148 if (i == this.maxWaterlevelPdf && mode == ExportMode.pdf) |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
149 break; |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
150 |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
151 final DurationWaterlevel item = waterlevelList.get(i); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
152 lines.add(item.getWFormatted(wFormatter)); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
153 lines.add(item.getFloodDurDaysPerYearFormatted(durFormatter)); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
154 lines.add(item.getQFormatted(qFormatter)); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
155 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
|
156 } |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
157 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
158 final int lineSize = lines.size(); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
159 while (mode == ExportMode.pdf && lines.size() < expectedSizetoGaugelabel) |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
160 lines.add(""); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
161 |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
162 if (isUseWspl() || mode == ExportMode.pdf) |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
163 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
|
164 |
9312 | 165 lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.location)); |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
166 |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
167 return lines.toArray(new String[lines.size()]); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
168 } |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
169 |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
170 @Override |
9195 | 171 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
172 |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
173 final Collection<String> header = new ArrayList<>(20); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
174 |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
175 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
176 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.riverside)); |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
177 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.floodDuration)); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
178 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
|
179 header.add(exportContextCSV.msgUnitCSV(SInfoResultType.infrastructureHeight, river.getWstUnit())); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
180 header.add(exportContextCSV.formatCsvHeader(SInfoResultType.infrastructuretype)); |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
181 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
182 // add dynamic headers |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
183 final int waterlevelCount = // results. |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
184 getWaterlevelCount(); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
185 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
|
186 final String appendIndex = "_" + Integer.toString(i + 1); |
9297
7100a555607c
Small fixes of the S-Info flood duration outputs
mschaefer
parents:
9294
diff
changeset
|
187 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
|
188 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
|
189 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
|
190 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
|
191 } |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
192 |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
193 if (isUseWspl()) |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
194 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
195 |
9312 | 196 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
197 |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
198 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); |
9265 | 199 } |
9145 | 200 |
9265 | 201 public List<Double> getValidDurationChartKilometers() { |
9585 | 202 |
203 // Wunsch BfG (Testung MS3): nur stationen mit infrastruktur | |
204 final Predicate filter = new HasInfrastructurePredicate(); | |
205 return getValues(GeneralResultType.station, filter); | |
9145 | 206 } |
207 | |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
208 @Override |
9195 | 209 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
210 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
211 return this.formatRow(exportContextCSV, row, ExportMode.csv); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
212 } |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
213 |
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
214 @Override |
9195 | 215 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
216 |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
217 return this.formatRow(exportContextPDF, row, ExportMode.pdf); |
9145 | 218 } |
219 | |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
220 @Override |
9195 | 221 protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
222 |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
223 /* column headings */ |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
224 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
225 exportContextPDF.addJRMetadata(source, "riverside_header", SInfoResultType.riverside); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
226 exportContextPDF.addJRMetadata(source, "inundationduration_header", SInfoResultType.floodDuration); |
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
227 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
|
228 exportContextPDF.addJRMetadata(source, "infrastructure_height_header", SInfoResultType.infrastructureHeight); |
9176
1614cb14308f
Work on calculations for S-Info flood duration workflow
mschaefer
parents:
9170
diff
changeset
|
229 exportContextPDF.addJRMetadata(source, "infrastructure_type_header", SInfoResultType.infrastructuretype); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
230 |
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
|
231 for (int i = 1; i <= this.getWaterlevelCount(); i++) { |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
232 |
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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 exportContextPDF.msg(DurationWaterlevel.getHeaderBezeichnPdf(), appendIndex)); |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
240 } |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
241 |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9312
diff
changeset
|
242 exportContextPDF.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); |
9312 | 243 exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); |
9150
23945061daec
gigantic refactoring: exporter, result, results
gernotbelger
parents:
9145
diff
changeset
|
244 } |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
245 |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
246 private final String getPdfHeader(final String rootStr, final int index) { |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
247 final String hd = "_header"; |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
248 final StringBuilder builder = new StringBuilder(); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
249 return builder.append(rootStr).append("_").append(index).append(hd).toString(); |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
250 } |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
251 |
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
|
252 public final int getWaterlevelCount() { |
9285 | 253 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
|
254 } |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
255 |
9285 | 256 public String getWaterlevelLabel(final int j) { |
257 if (this.waterlevelLabels != null && j < this.waterlevelLabels.length) | |
258 return this.waterlevelLabels[j]; | |
9205
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
259 return ""; |
3dae6b78e1da
inundationDuration/floodDuration multiple columns+chartLines refactoring
gernotbelger
parents:
9202
diff
changeset
|
260 } |
9208 | 261 |
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
|
262 /** |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
263 * 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
|
264 */ |
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 double[][] getInfrastructurePoints(final IResultType type, final AttributeKey riverside) { |
9265 | 266 return getPoints(GeneralResultType.station, type, new RiversidePredicate(riverside)); |
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 |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
269 /** |
0dcd1cd41915
Different themes/facets for left bank and right bank infrastructures in S-Info flood durations, some fixmes done
mschaefer
parents:
9217
diff
changeset
|
270 * 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
|
271 */ |
9265 | 272 public final double[][] getMainValueDurationPoints(final ValueGetter valuegetter, final int dataIndex) { |
9208 | 273 |
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
|
274 final Collection<ResultRow> rows = getAllRows(); |
9208 | 275 |
9265 | 276 final TDoubleArrayList xPoints = new TDoubleArrayList(rows.size()); |
277 final TDoubleArrayList yPoints = new TDoubleArrayList(rows.size()); | |
278 | |
279 for (final ResultRow row : rows) { | |
9208 | 280 |
281 final double station = row.getDoubleValue(GeneralResultType.station); | |
282 | |
283 final List<DurationWaterlevel> waterlevels = (List<DurationWaterlevel>) row.getValue(SInfoResultType.customMultiRowColWaterlevel); | |
284 final DurationWaterlevel waterlevel = waterlevels.get(dataIndex); | |
285 | |
286 final Double value = valuegetter.getValue(waterlevel); | |
287 | |
288 xPoints.add(station); | |
289 yPoints.add(value); | |
290 } | |
291 | |
292 return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() }; | |
293 } | |
9492
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
294 |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
295 public boolean isUseWspl() { |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
296 return this.isUseWspl; |
10530f1d7dd5
Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels
gernotbelger
parents:
9357
diff
changeset
|
297 } |
9145 | 298 } |