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