Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractSInfoExporter.java @ 8956:ee5ce13016ed
Work on SINFO-Fließtiefenentwicklung
author | gernotbelger |
---|---|
date | Tue, 20 Mar 2018 13:30:07 +0100 |
parents | c40db8e8dcae |
children | 7c1611b5a59e |
rev | line source |
---|---|
8928 | 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.common; | |
11 | |
12 import java.io.OutputStream; | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
13 import java.text.DateFormat; |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
14 import java.text.NumberFormat; |
8928 | 15 import java.util.Collection; |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
16 import java.util.Date; |
8928 | 17 import java.util.HashMap; |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
18 import java.util.Locale; |
8928 | 19 import java.util.Map; |
20 | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
21 import org.apache.commons.lang.math.DoubleRange; |
8928 | 22 import org.apache.log4j.Logger; |
23 import org.dive4elements.artifacts.CallMeta; | |
24 import org.dive4elements.artifacts.common.utils.Config; | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
25 import org.dive4elements.river.FLYS; |
8928 | 26 import org.dive4elements.river.artifacts.model.CalculationResult; |
27 import org.dive4elements.river.artifacts.resources.Resources; | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
28 import org.dive4elements.river.artifacts.sinfo.SInfoI18NStrings; |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
29 import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo; |
8928 | 30 import org.dive4elements.river.artifacts.sinfo.util.MetaAndTableJRDataSource; |
31 import org.dive4elements.river.artifacts.sinfo.util.RiverInfo; | |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
32 import org.dive4elements.river.artifacts.sinfo.util.WstInfo; |
8928 | 33 import org.dive4elements.river.exports.AbstractExporter; |
34 | |
35 import au.com.bytecode.opencsv.CSVWriter; | |
36 import net.sf.jasperreports.engine.JRDataSource; | |
37 import net.sf.jasperreports.engine.JRException; | |
38 import net.sf.jasperreports.engine.JasperExportManager; | |
39 import net.sf.jasperreports.engine.JasperFillManager; | |
40 import net.sf.jasperreports.engine.JasperPrint; | |
41 | |
42 /** | |
43 * @author Gernot Belger | |
44 */ | |
8948 | 45 public abstract class AbstractSInfoExporter<RESULT extends AbstractSInfoCalculationResult, RESULTS extends AbstractSInfoCalculationResults<RESULT>> extends AbstractExporter { |
8928 | 46 |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
47 private static final String CSV_META_HEADER_SOUNDING = "sinfo.export.flow_depth.csv.meta.header.sounding"; |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
48 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
49 private static final String CSV_META_HEADER_SOUNDING_YEAR = "sinfo.export.flow_depth.csv.meta.header.sounding.year"; |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
50 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
51 private static final String CSV_META_HEADER_SOUNDING_TYPE = "sinfo.export.flow_depth.csv.meta.header.sounding.type"; |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
52 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
53 private static final String CSV_META_HEADER_SOUNDING_EVALUATOR = "sinfo.export.flow_depth.csv.meta.header.sounding.evaluator"; |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
54 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
55 private static final String CSV_META_HEADER_SOUNDING_PRJ = "sinfo.export.flow_depth.csv.meta.header.sounding.prj"; |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
56 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
57 private static final String CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL = "sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel"; |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
58 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
59 private static final String CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL_ORIGINAL = "sinfo.export.flow_depth.csv.meta.header.sounding.elevationmodel.original"; |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
60 |
8928 | 61 /** The storage that contains the current calculation result. */ |
62 private RESULTS data = null; | |
63 | |
64 protected abstract Logger getLog(); | |
65 | |
66 public RESULTS getData() { | |
67 return this.data; | |
68 } | |
69 | |
70 @Override | |
71 protected final void addData(final Object d) { | |
72 /* reset */ | |
73 this.data = null; | |
74 | |
75 if (d instanceof CalculationResult) { | |
76 | |
77 final Object dat = ((CalculationResult) d).getData(); | |
8938
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
78 if (dat != null) { |
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
79 @SuppressWarnings("unchecked") |
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
80 final RESULTS result = (RESULTS) dat; |
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
81 this.data = result; |
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
82 } |
8928 | 83 } |
84 } | |
85 | |
8953
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
86 /** |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
87 * Formats header with unit and label: msg [unit] (label) |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
88 */ |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
89 protected final String msgUnitLabel(final String key, final String unit, final String label) { |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
90 final String msg = msg(key); |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
91 return String.format("%s [%s] (%s)", msg, unit, label); |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
92 } |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
93 |
8928 | 94 @Override |
95 protected final void writeCSVData(final CSVWriter writer) { | |
96 getLog().info("writeCSVData"); | |
97 | |
98 /* fetch calculation results */ | |
99 final RESULTS results = this.data; | |
100 | |
101 final RiverInfo river = results.getRiver(); | |
102 | |
103 /* write as csv */ | |
8938
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
104 writeCSVGlobalMetadata(writer, results); |
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
105 writeCSVHeader(writer, results, river); |
8928 | 106 |
107 for (final RESULT result : results.getResults()) { | |
8938
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
108 writeCSVResult(writer, results, result); |
8928 | 109 } |
110 } | |
111 | |
8938
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
112 protected abstract void writeCSVHeader(final CSVWriter writer, final RESULTS results, final RiverInfo river); |
8928 | 113 |
8938
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
114 /** |
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
115 * Add metadata that is once written to the top of the file. |
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
116 */ |
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
117 protected abstract void writeCSVGlobalMetadata(final CSVWriter writer, final RESULTS results); |
8928 | 118 |
119 protected final void writeCSVMetaEntry(final CSVWriter writer, final String message, final Object... messageArgs) { | |
120 | |
121 final CallMeta meta = this.context.getMeta(); | |
122 | |
123 writer.writeNext(new String[] { Resources.getMsg(meta, message, message, messageArgs) }); | |
124 } | |
125 | |
8938
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
126 protected final void writeCSVResult(final CSVWriter writer, final RESULTS results, final RESULT result) { |
8928 | 127 |
8938
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
128 writeCSVResultMetadata(writer, results, result); |
8928 | 129 |
130 /* nwo the value rows */ | |
8948 | 131 final Collection<SInfoResultRow> rows = result.getRows(); |
132 for (final SInfoResultRow row : rows) { | |
133 writeCSVRow(writer, results, result, row); | |
8928 | 134 } |
135 } | |
136 | |
8938
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
137 /** |
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
138 * Add metadata that is written once per result set. |
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
139 */ |
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
140 protected abstract void writeCSVResultMetadata(CSVWriter writer, RESULTS results, RESULT result); |
8928 | 141 |
8948 | 142 protected final void writeCSVRow(final CSVWriter writer, final RESULTS results, final RESULT result, final SInfoResultRow row) { |
8928 | 143 getLog().debug("writeCSVFlowDepthRow"); |
144 | |
8948 | 145 final String[] formattedRow = formatCSVRow(results, result, row); |
8928 | 146 writer.writeNext(formattedRow); |
147 } | |
148 | |
8948 | 149 protected abstract String[] formatCSVRow(RESULTS results, RESULT result, final SInfoResultRow row); |
8928 | 150 |
151 @Override | |
152 protected final void writePDF(final OutputStream outStream) { | |
153 getLog().debug("write PDF"); | |
154 | |
155 final JRDataSource source = createJRData(); | |
156 | |
157 final String confPath = Config.getConfigDirectory().toString(); | |
158 | |
159 // FIXME: distinguish between with and without tkh: we need two jasper reports! | |
160 | |
161 final Map<String, Object> parameters = new HashMap<>(); | |
162 parameters.put("ReportTitle", "Exported Data"); | |
163 | |
164 try { | |
165 final String jasperPath = confPath + getJasperFile(); | |
166 | |
167 final JasperPrint print = JasperFillManager.fillReport(jasperPath, parameters, source); | |
168 JasperExportManager.exportReportToPdfStream(print, outStream); | |
169 } | |
170 catch (final JRException je) { | |
171 getLog().warn("Error generating PDF Report!", je); | |
172 } | |
173 } | |
174 | |
175 protected abstract String getJasperFile(); | |
176 | |
177 private JRDataSource createJRData() { | |
178 | |
179 /* fetch calculation results */ | |
180 final RESULTS results = this.data; | |
181 | |
182 final MetaAndTableJRDataSource source = new MetaAndTableJRDataSource(); | |
183 | |
184 addJRMetaData(source, results); | |
185 | |
186 for (final RESULT result : results.getResults()) { | |
8938
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
187 addJRTableData(source, results, result); |
8928 | 188 } |
189 | |
190 return source; | |
191 } | |
192 | |
193 protected abstract void addJRMetaData(final MetaAndTableJRDataSource source, final RESULTS results); | |
194 | |
8938
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
195 protected final void addJRTableData(final MetaAndTableJRDataSource source, final RESULTS results, final RESULT result) { |
8928 | 196 |
8948 | 197 final Collection<SInfoResultRow> rows = result.getRows(); |
8928 | 198 |
8948 | 199 for (final SInfoResultRow row : rows) { |
8928 | 200 |
8938
9c02733a1b3c
Work on Sinfo-tkh - exports; using same logic for wst-description as winfo
gernotbelger
parents:
8928
diff
changeset
|
201 final String[] formattedRow = formatPDFRow(results, row); |
8928 | 202 source.addData(formattedRow); |
203 } | |
204 } | |
205 | |
8948 | 206 protected abstract String[] formatPDFRow(RESULTS results, final SInfoResultRow row); |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
207 |
8948 | 208 protected final void writeCSVGlobalMetadataDefaults(final CSVWriter writer, final AbstractSInfoCalculationResults<?> results) { |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
209 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
210 final String calcModeLabel = results.getCalcModeLabel(); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
211 final RiverInfo river = results.getRiver(); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
212 final DoubleRange calcRange = results.getCalcRange(); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
213 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
214 writeCSVMetaEntry(writer, SInfoI18NStrings.CSV_META_HEADER_RESULT, msg(SInfoI18NStrings.CSV_META_HEADER_RESULT_LABEL), river.getName(), calcModeLabel); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
215 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
216 // "# FLYS-Version: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
217 writeCSVMetaEntry(writer, SInfoI18NStrings.CSV_META_VERSION, msg(SInfoI18NStrings.CSV_META_VERSION_LABEL), FLYS.VERSION); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
218 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
219 // "# Bearbeiter: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
220 writeCSVMetaEntry(writer, SInfoI18NStrings.CSV_META_USER, msg(SInfoI18NStrings.CSV_META_USER_LABEL), results.getUser()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
221 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
222 // "# Datum der Erstellung: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
223 final Locale locale = Resources.getLocale(this.context.getMeta()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
224 final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
225 writeCSVMetaEntry(writer, SInfoI18NStrings.CSV_META_CREATION, msg(SInfoI18NStrings.CSV_META_CREATION_LABEL), df.format(new Date())); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
226 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
227 // "# Gewässer: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
228 writeCSVMetaEntry(writer, SInfoI18NStrings.CSV_META_RIVER, msg(SInfoI18NStrings.CSV_META_RIVER_LABEL), river.getName()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
229 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
230 // "# Höhensystem des Flusses: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
231 writeCSVMetaEntry(writer, SInfoI18NStrings.CSV_META_HEIGHT_UNIT_RIVER, river.getWstUnit()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
232 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
233 // "# Ort/Bereich (km): " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
234 writeCSVMetaEntry(writer, SInfoI18NStrings.CSV_META_RANGE, msg(SInfoI18NStrings.CSV_META_RANGE_LABEL), |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
235 getKmFormatter().format(calcRange.getMinimumDouble()), getKmFormatter().format(calcRange.getMaximumDouble())); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
236 } |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
237 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
238 protected final void writeCSVSoundingMetadata(final CSVWriter writer, final BedHeightInfo sounding) { |
8953
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
239 writeCSVSoundingMetadata(writer, sounding, CSV_META_HEADER_SOUNDING); |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
240 } |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
241 |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
242 protected final void writeCSVSoundingMetadata(final CSVWriter writer, final BedHeightInfo sounding, final String mainLabel) { |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
243 // "##METADATEN PEILUNG" |
8953
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
244 writeCSVMetaEntry(writer, mainLabel); |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
245 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
246 // "# Jahr der Peilung: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
247 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_YEAR, Integer.toString(sounding.getYear())); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
248 // "# Aufnahmeart: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
249 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_TYPE, sounding.getType()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
250 // "# Auswerter: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
251 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_EVALUATOR, sounding.getEvaluationBy()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
252 // "# Lagesystem: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
253 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_PRJ, sounding.getLocationSystem()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
254 // "# Höhensystem: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
255 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL, sounding.getCurElevationModelUnit()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
256 // "# ursprüngliches Höhensystem: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
257 writeCSVMetaEntry(writer, CSV_META_HEADER_SOUNDING_ELEVATIOIN_MODEL_ORIGINAL, sounding.getOldElevationModelUnit()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
258 } |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
259 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
260 protected final void writeCSVWaterlevelMetadata(final CSVWriter writer, final WstInfo wst) { |
8953
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
261 writeCSVWaterlevelMetadata(writer, wst, SInfoI18NStrings.CSV_META_HEADER_WATERLEVEL); |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
262 } |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
263 |
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
264 protected final void writeCSVWaterlevelMetadata(final CSVWriter writer, final WstInfo wst, final String mainLabel) { |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
265 // "##METADATEN WASSERSPIEGELLAGE" |
8953
c40db8e8dcae
SINFO - Flow depth development - implemented exporters
gernotbelger
parents:
8948
diff
changeset
|
266 writeCSVMetaEntry(writer, mainLabel); |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
267 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
268 // "# Bezeichnung der Wasserspiegellage: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
269 writeCSVMetaEntry(writer, SInfoI18NStrings.CSV_META_HEADER_WATERLEVEL_NAME, wst.getLabel()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
270 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
271 // "# Bezugspegel: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
272 writeCSVMetaEntry(writer, SInfoI18NStrings.CSV_META_HEADER_WATERLEVEL_GAUGE, wst.getGauge()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
273 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
274 // "# Jahr/Zeitraum der Wasserspiegellage: " |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
275 final int year = wst.getYear(); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
276 if (year > 0) |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
277 writeCSVMetaEntry(writer, SInfoI18NStrings.CSV_META_HEADER_WATERLEVEL_YEAR, Integer.toString(year)); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
278 } |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
279 |
8948 | 280 protected final void addJRMetaDataDefaults(final MetaAndTableJRDataSource source, final AbstractSInfoCalculationResults<?> results) { |
8946
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
281 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
282 final RiverInfo river = results.getRiver(); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
283 final String wstUnitName = river.getWstUnit(); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
284 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
285 source.addMetaData("header", msg(SInfoI18NStrings.CSV_META_HEADER_RESULT_LABEL)); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
286 source.addMetaData("calcMode", results.getCalcModeLabel()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
287 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
288 source.addMetaData("version_label", msg(SInfoI18NStrings.CSV_META_VERSION_LABEL)); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
289 source.addMetaData("version", FLYS.VERSION); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
290 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
291 source.addMetaData("user_label", msg(SInfoI18NStrings.CSV_META_USER_LABEL)); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
292 source.addMetaData("user", results.getUser()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
293 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
294 final Locale locale = Resources.getLocale(this.context.getMeta()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
295 final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
296 source.addMetaData("date_label", msg(SInfoI18NStrings.CSV_META_CREATION_LABEL)); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
297 source.addMetaData("date", df.format(new Date())); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
298 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
299 source.addMetaData("river_label", msg(SInfoI18NStrings.CSV_META_RIVER_LABEL)); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
300 source.addMetaData("river", river.getName()); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
301 source.addMetaData("river_unit", wstUnitName); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
302 |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
303 final DoubleRange calcRange = results.getCalcRange(); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
304 final NumberFormat kmFormatter = getKmFormatter(); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
305 final String rangeValue = String.format("%s - %s", kmFormatter.format(calcRange.getMinimumDouble()), kmFormatter.format(calcRange.getMaximumDouble())); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
306 source.addMetaData("range_label", msg(SInfoI18NStrings.CSV_META_RANGE_LABEL)); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
307 source.addMetaData("range", rangeValue); |
5d5d482da3e9
Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents:
8938
diff
changeset
|
308 } |
8928 | 309 } |