Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java @ 9583:2a67d05a1af0
Punkt 10.4 Sohlhöhe (rechts)/(links)
author | gernotbelger |
---|---|
date | Wed, 09 Jan 2019 14:48:53 +0100 |
parents | 7228bd10a8cc |
children | 93389a05119e |
rev | line source |
---|---|
9313 | 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.bundu.bezugswst; | |
11 | |
12 import java.util.ArrayList; | |
13 import java.util.Collection; | |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
14 import java.util.List; |
9313 | 15 |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
16 import org.dive4elements.river.artifacts.bundu.BunduResultType; |
9313 | 17 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult; |
18 import org.dive4elements.river.artifacts.common.ExportContextCSV; | |
19 import org.dive4elements.river.artifacts.common.ExportContextPDF; | |
20 import org.dive4elements.river.artifacts.common.GeneralResultType; | |
21 import org.dive4elements.river.artifacts.common.IExportContext; | |
22 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource; | |
23 import org.dive4elements.river.artifacts.common.ResultRow; | |
9438
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
24 import org.dive4elements.river.artifacts.model.WQKms; |
9313 | 25 import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo; |
26 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
27 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; | |
28 | |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
29 import gnu.trove.TDoubleArrayList; |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
30 |
9313 | 31 /** |
32 * Contains the results of a //TODO LINK{@link BezugswstCalculation}. | |
33 * | |
34 * @author Gernot Belger | |
35 */ | |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
36 final class BezugswstMainCalculationResult extends AbstractCalculationExportableResult { |
9313 | 37 |
38 private static final long serialVersionUID = 1L; | |
39 | |
40 private static final String JASPER_FILE = "/jasper/templates/bundu.bezugswst.jrxml"; | |
41 | |
9323 | 42 private final WstInfo wst; |
43 private final BedHeightInfo sounding; | |
44 private final String function; | |
45 private final boolean preprocessing; | |
46 private final int startYear; | |
47 private final int endYear; | |
48 private final Double missingVolumeFrom; | |
49 private final Double missingVolumeTo; | |
50 private final Integer ud; | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
51 private final String qOfGauges; |
9313 | 52 |
9438
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
53 private final WQKms wqkms; |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
54 |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
55 public BezugswstMainCalculationResult(final String label, final Collection<ResultRow> rows, final BedHeightInfo sounding, final WstInfo wst, |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
56 final String function, final boolean preprocessing, final int startYear, final int endYear, final Integer ud, final String qOfGauges, |
9438
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
57 final WQKms wqkms, final Double missingVolumeFrom, final Double missingVolumeTo) { |
9313 | 58 super(label, rows); |
9323 | 59 this.wst = wst; |
60 this.sounding = sounding; | |
61 this.function = function; | |
62 this.preprocessing = preprocessing; | |
63 this.startYear = startYear; | |
64 this.endYear = endYear; | |
65 this.missingVolumeTo = missingVolumeTo; | |
66 this.missingVolumeFrom = missingVolumeFrom; | |
67 this.ud = ud; | |
68 this.qOfGauges = qOfGauges; | |
9438
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
69 this.wqkms = wqkms; |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
70 } |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
71 |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
72 public WQKms getWQKms() { |
d2f5375ede26
Replaced own W and Q facets in bundu bzws by subclass of FixWaterlevelFacet, added annotations and datacage
mschaefer
parents:
9435
diff
changeset
|
73 return this.wqkms; |
9313 | 74 } |
75 | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
76 public String getWstLabel() { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
77 if (this.ud != null) |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
78 return Integer.toString(this.endYear) + "; UD=" + Integer.toString(this.ud); // FIXME per WaterlevelDescriptionBuilder o.ä. zentralisieren |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
79 return Integer.toString(this.endYear) + "; " + this.wst.getLabel(); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
80 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
81 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
82 public String getBedHeightLabel() { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
83 if (this.sounding != null) |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
84 return this.sounding.getDescription(); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
85 return ""; |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
86 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
87 |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
88 public boolean getIsMissingVolume() { |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
89 return !Double.isNaN(this.missingVolumeFrom); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
90 } |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
91 |
9313 | 92 @Override |
93 protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) { | |
94 | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
95 exportContextCSV.writeCSVWaterlevelMetadata(this.wst); |
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
96 exportContextCSV.writeBlankLine(); |
9480
7228bd10a8cc
Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents:
9444
diff
changeset
|
97 if (this.sounding != null) |
7228bd10a8cc
Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents:
9444
diff
changeset
|
98 exportContextCSV.writeCSVSoundingMetadata(this.sounding, "common.export.csv.meta.header.sounding"); |
9323 | 99 |
100 // Reihenfolge in der LV anders; ich finde sie aber so sinnvoller | |
101 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.function", this.function); | |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
102 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.preprocessing", exportContextCSV.msg(String.valueOf(this.preprocessing))); |
9323 | 103 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.q_period", String.valueOf(this.startYear), String.valueOf(this.endYear)); |
104 if (this.ud != null) | |
105 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.ud", this.ud); | |
106 else if (this.qOfGauges != null) | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
107 exportContextCSV.writeCSVMetaEntry("common.export.waterlevel.csv.meta.q", this.qOfGauges); |
9323 | 108 |
9337 | 109 if (this.missingVolumeFrom != null && this.missingVolumeTo != null) |
110 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.missing_volume_range", this.missingVolumeFrom, this.missingVolumeTo); | |
9323 | 111 |
112 exportContextCSV.writeBlankLine(); | |
9313 | 113 } |
114 | |
115 @Override | |
116 protected String getJasperFile() { | |
117 return JASPER_FILE; | |
118 } | |
119 | |
120 protected String[] formatRow(final IExportContext exportContext, final ResultRow row) { | |
121 | |
122 final Collection<String> lines = new ArrayList<>(10); | |
123 | |
124 lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); | |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
125 lines.add(exportContext.formatRowValue(row, BunduResultType.bezugswst)); |
9313 | 126 lines.add(exportContext.formatRowValue(row, GeneralResultType.dischargeQwithUnit)); |
127 | |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
128 lines.add(exportContext.formatRowValue(row, GeneralResultType.waterlevelLabel)); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
129 lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabel)); |
9313 | 130 lines.add(exportContext.formatRowValue(row, GeneralResultType.location)); |
131 | |
132 return lines.toArray(new String[lines.size()]); | |
133 } | |
134 | |
135 @Override | |
136 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { | |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
137 final int colSize = 6; |
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
138 exportContextCSV.writeTitleForTabs("bundu.export.csv.title.bezugswst.overview", colSize); // Voraussetzung für Tabs ist, dass der Titel vor den Headern |
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
139 final Collection<String> header = new ArrayList<>(colSize); |
9313 | 140 |
141 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
142 header.add(exportContextCSV.formatCsvHeader(BunduResultType.bezugswst) + " [" + river.getWstUnit() + "]"); |
9313 | 143 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.dischargeQwithUnit)); |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
144 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.waterlevelLabel)); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
145 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); |
9313 | 146 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); |
147 | |
148 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
149 | |
150 } | |
151 | |
152 @Override | |
153 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { | |
154 | |
155 return this.formatRow(exportContextCSV, row); | |
156 } | |
157 | |
158 @Override | |
159 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { | |
160 | |
161 return this.formatRow(exportContextPDF, row); | |
162 } | |
163 | |
164 @Override | |
165 protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { | |
166 /* column headings */ | |
167 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); | |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
168 exportContextPDF.addJRMetadata(source, "bezugswst_header", BunduResultType.bezugswst); |
9331 | 169 // exportContextPDF.addJRMetadata(source, " [" + river.getWstUnit() + "]"); |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
170 exportContextPDF.addJRMetadata(source, "discharge_header", GeneralResultType.dischargeQwithUnit); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
171 exportContextPDF.addJRMetadata(source, "waterlevel_name_header", GeneralResultType.waterlevelLabel); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
172 exportContextPDF.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); |
9313 | 173 exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); |
174 | |
175 } | |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
176 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
177 /** |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
178 * Gets a longitudinal section of a result type value of a cross section field |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
179 * |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
180 * @param fieldIndex |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
181 * 1-based field index |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
182 * @param type |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
183 * result type like bedHeightField |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
184 */ |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
185 public final double[][] getFieldValuePoints(final int fieldIndex, final BunduResultType type) { |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
186 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
187 final TDoubleArrayList x = new TDoubleArrayList(this.getRows().size()); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
188 final TDoubleArrayList y = new TDoubleArrayList(this.getRows().size()); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
189 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
190 for (final ResultRow row : this.getRows()) { |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
191 x.add(row.getDoubleValue(GeneralResultType.station)); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
192 @SuppressWarnings("unchecked") |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
193 final List<Double> fieldHeights = (List<Double>) row.getValue(type); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
194 y.add(fieldHeights.get(fieldIndex - 1)); |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
195 } |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
196 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
197 return new double[][] { x.toNativeArray(), y.toNativeArray() }; |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
198 } |
9313 | 199 } |