# HG changeset patch # User gernotbelger # Date 1537444830 -7200 # Node ID 10530f1d7dd53c1b046fe4b38632695d9033a2fc # Parent d7d22ea8573dfc046d4b0eb5329149b83176eee5 Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels diff -r d7d22ea8573d -r 10530f1d7dd5 artifacts/doc/conf/jasper/templates/sinfo.floodduration.jrxml --- a/artifacts/doc/conf/jasper/templates/sinfo.floodduration.jrxml Wed Sep 19 17:53:53 2018 +0200 +++ b/artifacts/doc/conf/jasper/templates/sinfo.floodduration.jrxml Thu Sep 20 14:00:30 2018 +0200 @@ -1,6 +1,6 @@ - - + + @@ -219,7 +219,7 @@ - + @@ -345,7 +345,7 @@ - + diff -r d7d22ea8573d -r 10530f1d7dd5 artifacts/doc/conf/jasper/templates/sinfo.floodduration2.jrxml --- a/artifacts/doc/conf/jasper/templates/sinfo.floodduration2.jrxml Wed Sep 19 17:53:53 2018 +0200 +++ b/artifacts/doc/conf/jasper/templates/sinfo.floodduration2.jrxml Thu Sep 20 14:00:30 2018 +0200 @@ -1,6 +1,6 @@ - - + + @@ -267,7 +267,7 @@ - + @@ -481,7 +481,7 @@ - + diff -r d7d22ea8573d -r 10530f1d7dd5 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java --- 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 rows) { + public FloodDurationCalculationResult(final String label, final String[] mainvalueLabels, final Collection 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 lines = new ArrayList<>(10); + final Collection 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 waterlevelList = (List) 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 diff -r d7d22ea8573d -r 10530f1d7dd5 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java Wed Sep 19 17:53:53 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java Thu Sep 20 14:00:30 2018 +0200 @@ -66,8 +66,8 @@ /** * Calculate the infrastructures flood duration result rows */ - public void execute(final Calculation problems, final String label, final DoubleRange calcRange, final RiversideChoiceKey riverside, - final boolean withWspl, final WINFOArtifact winfo, final FloodDurationCalculationResults results) { + public void execute(final Calculation problems, final String label, final DoubleRange calcRange, final RiversideChoiceKey riverside, final boolean withWspl, + final WINFOArtifact winfo, final FloodDurationCalculationResults results) { // Find all gauges of the calc range, and create the duration finders final Map durFinders = new HashMap<>(); @@ -121,7 +121,7 @@ for (int i = 0; i <= wqkmsArray.length - 1; i++) wstLabels[i] = wqkmsArray[i].getName(); - results.addResult(new FloodDurationCalculationResult(label, wstLabels, this.rows), problems); + results.addResult(new FloodDurationCalculationResult(label, wstLabels, this.rows, withWspl), problems); } /** @@ -145,8 +145,7 @@ if (qpos != null) { ows[j] = wst.interpolateW(station, qpos, problems); oqs[j] = wst.getQ(qpos, station); - } - else { + } else { ows[j] = Double.NaN; oqs[j] = qs[i]; } diff -r d7d22ea8573d -r 10530f1d7dd5 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationExporter.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationExporter.java Wed Sep 19 17:53:53 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationExporter.java Thu Sep 20 14:00:30 2018 +0200 @@ -75,5 +75,8 @@ design.removeColumn("bezOpt"); design.removeColumn("durOpt"); } + + if (!result.isUseWspl()) + design.removeColumn("gauge_header"); } } \ No newline at end of file