Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstMainCalculationResult.java @ 9444:ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
author | mschaefer |
---|---|
date | Tue, 21 Aug 2018 13:41:18 +0200 |
parents | d2f5375ede26 |
children | 7228bd10a8cc |
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(); |
9435 | 97 exportContextCSV.writeCSVSoundingMetadata(this.sounding, "common.export.csv.meta.header.sounding"); |
9323 | 98 |
99 // Reihenfolge in der LV anders; ich finde sie aber so sinnvoller | |
100 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
|
101 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.preprocessing", exportContextCSV.msg(String.valueOf(this.preprocessing))); |
9323 | 102 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.q_period", String.valueOf(this.startYear), String.valueOf(this.endYear)); |
103 if (this.ud != null) | |
104 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.ud", this.ud); | |
105 else if (this.qOfGauges != null) | |
9432
d194c5b24bf8
Added bundu bzws w calculation and longitudinal sections of wspl and depth
mschaefer
parents:
9337
diff
changeset
|
106 exportContextCSV.writeCSVMetaEntry("common.export.waterlevel.csv.meta.q", this.qOfGauges); |
9323 | 107 |
9337 | 108 if (this.missingVolumeFrom != null && this.missingVolumeTo != null) |
109 exportContextCSV.writeCSVMetaEntry("bundu.export.bezugswst.csv.meta.missing_volume_range", this.missingVolumeFrom, this.missingVolumeTo); | |
9323 | 110 |
111 exportContextCSV.writeBlankLine(); | |
9313 | 112 } |
113 | |
114 @Override | |
115 protected String getJasperFile() { | |
116 return JASPER_FILE; | |
117 } | |
118 | |
119 protected String[] formatRow(final IExportContext exportContext, final ResultRow row) { | |
120 | |
121 final Collection<String> lines = new ArrayList<>(10); | |
122 | |
123 lines.add(exportContext.formatRowValue(row, GeneralResultType.station)); | |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
124 lines.add(exportContext.formatRowValue(row, BunduResultType.bezugswst)); |
9313 | 125 lines.add(exportContext.formatRowValue(row, GeneralResultType.dischargeQwithUnit)); |
126 | |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
127 lines.add(exportContext.formatRowValue(row, GeneralResultType.waterlevelLabel)); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
128 lines.add(exportContext.formatRowValue(row, GeneralResultType.gaugeLabel)); |
9313 | 129 lines.add(exportContext.formatRowValue(row, GeneralResultType.location)); |
130 | |
131 return lines.toArray(new String[lines.size()]); | |
132 } | |
133 | |
134 @Override | |
135 public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) { | |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
136 final int colSize = 6; |
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
137 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
|
138 final Collection<String> header = new ArrayList<>(colSize); |
9313 | 139 |
140 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.station)); | |
9330
0a0937f33bb5
bundu.bezugswst first result for missing volume added
gernotbelger
parents:
9323
diff
changeset
|
141 header.add(exportContextCSV.formatCsvHeader(BunduResultType.bezugswst) + " [" + river.getWstUnit() + "]"); |
9313 | 142 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.dischargeQwithUnit)); |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
143 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.waterlevelLabel)); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
144 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); |
9313 | 145 header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); |
146 | |
147 exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); | |
148 | |
149 } | |
150 | |
151 @Override | |
152 protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) { | |
153 | |
154 return this.formatRow(exportContextCSV, row); | |
155 } | |
156 | |
157 @Override | |
158 protected String[] formatPDFRow(final ExportContextPDF exportContextPDF, final ResultRow row) { | |
159 | |
160 return this.formatRow(exportContextPDF, row); | |
161 } | |
162 | |
163 @Override | |
164 protected void addJRTableHeader(final ExportContextPDF exportContextPDF, final MetaAndTableJRDataSource source) { | |
165 /* column headings */ | |
166 exportContextPDF.addJRMetadata(source, "station_header", GeneralResultType.station); | |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
167 exportContextPDF.addJRMetadata(source, "bezugswst_header", BunduResultType.bezugswst); |
9331 | 168 // exportContextPDF.addJRMetadata(source, " [" + river.getWstUnit() + "]"); |
9318
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
169 exportContextPDF.addJRMetadata(source, "discharge_header", GeneralResultType.dischargeQwithUnit); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
170 exportContextPDF.addJRMetadata(source, "waterlevel_name_header", GeneralResultType.waterlevelLabel); |
7b2b086e45f0
collision pdf details, ResultType refactoring, bezugswst result
gernotbelger
parents:
9313
diff
changeset
|
171 exportContextPDF.addJRMetadata(source, "gauge_header", GeneralResultType.gaugeLabel); |
9313 | 172 exportContextPDF.addJRMetadata(source, "location_header", GeneralResultType.location); |
173 | |
174 } | |
9444
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
175 |
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 * 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
|
178 * |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
179 * @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
|
180 * 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
|
181 * @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
|
182 * 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
|
183 */ |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
184 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
|
185 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
186 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
|
187 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
|
188 |
ecadc9ed0ba0
Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents:
9438
diff
changeset
|
189 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
|
190 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
|
191 @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
|
192 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
|
193 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
|
194 } |
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 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
|
197 } |
9313 | 198 } |