Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java Wed Sep 19 17:53:53 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java Thu Sep 20 14:00:30 2018 +0200 @@ -55,6 +55,8 @@ private static final long serialVersionUID = 1L; + private final boolean isUseWspl; + private final String[] waterlevelLabels; private final int maxWaterlevelPdf = 3; @@ -67,9 +69,10 @@ pdf, csv } - public FloodDurationCalculationResult(final String label, final String[] mainvalueLabels, final Collection<ResultRow> rows) { + public FloodDurationCalculationResult(final String label, final String[] mainvalueLabels, final Collection<ResultRow> rows, final boolean isUseWspl) { super(label, rows); this.waterlevelLabels = mainvalueLabels; + this.isUseWspl = isUseWspl; } /** @@ -112,7 +115,7 @@ protected String[] formatRow(final AbstractExportContext exportContextCSV, final ResultRow row, final ExportMode mode) { - final Collection<String> lines = new ArrayList<>(10); + final Collection<String> lines = new ArrayList<>(20); lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.station)); lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.riverside)); @@ -122,25 +125,33 @@ lines.add(exportContextCSV.formatRowValue(row, SInfoResultType.infrastructuretype)); final List<DurationWaterlevel> waterlevelList = (List<DurationWaterlevel>) row.getValue(SInfoResultType.customMultiRowColWaterlevel); - if (waterlevelList != null) { - final NumberFormat wFormatter = exportContextCSV.getFlowDepthFormatter(); - final NumberFormat qFormatter = exportContextCSV.getQFormatter(); - final NumberFormat durFormatter = exportContextCSV.getFloodDurationFormatter(); - - for (int i = 0; i < waterlevelList.size(); i++) { - if (i == this.maxWaterlevelPdf && mode == ExportMode.pdf) - break; + final int expectedSizetoGaugelabel = lines.size() + (waterlevelList.size() < 2 ? 4 : 12); // removing columns only works for fixed + // indices - final DurationWaterlevel item = waterlevelList.get(i); - lines.add(item.getWFormatted(wFormatter)); - lines.add(item.getFloodDurDaysPerYearFormatted(durFormatter)); - lines.add(item.getQFormatted(qFormatter)); - lines.add(item.getBezeichnung()); - } + final NumberFormat wFormatter = exportContextCSV.getFlowDepthFormatter(); + final NumberFormat qFormatter = exportContextCSV.getQFormatter(); + final NumberFormat durFormatter = exportContextCSV.getFloodDurationFormatter(); + + for (int i = 0; i < waterlevelList.size(); i++) { + + if (i == this.maxWaterlevelPdf && mode == ExportMode.pdf) + break; + + final DurationWaterlevel item = waterlevelList.get(i); + lines.add(item.getWFormatted(wFormatter)); + lines.add(item.getFloodDurDaysPerYearFormatted(durFormatter)); + lines.add(item.getQFormatted(qFormatter)); + lines.add(item.getBezeichnung()); } - lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.gaugeLabel)); + final int lineSize = lines.size(); + while (mode == ExportMode.pdf && lines.size() < expectedSizetoGaugelabel) + lines.add(""); + + if (isUseWspl() || mode == ExportMode.pdf) + lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.gaugeLabel)); // PDF: necessary, because if removed, location would not be shown! + lines.add(exportContextCSV.formatRowValue(row, GeneralResultType.location)); return lines.toArray(new String[lines.size()]); @@ -169,7 +180,9 @@ header.add(exportContextCSV.msg(DurationWaterlevel.getHeaderBezeichnCsv(), appendIndex)); } - header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); + if (isUseWspl()) + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.gaugeLabel)); + header.add(exportContextCSV.formatCsvHeader(GeneralResultType.location)); exportContextCSV.writeCSVLine(header.toArray(new String[header.size()])); @@ -265,4 +278,8 @@ return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() }; } + + public boolean isUseWspl() { + return this.isUseWspl; + } } \ No newline at end of file