[PATCH] Meilenstein-2-Rücklauf Punkt 2.2.4 Angabe des Bezugspegels

Wald Commits scm-commit at wald.intevation.org
Thu Sep 20 14:00:29 CEST 2018


# 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 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 4.5.0  -->
-<!-- 2018-07-31T13:53:40 -->
+<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 4.5.0  -->
+<!-- 2018-09-20T13:25:41 -->
 <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="flysreport" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="762" leftMargin="60" rightMargin="20" topMargin="20" bottomMargin="20">
 	<property name="ireport.zoom" value="1.0"/>
 	<property name="ireport.x" value="0"/>
@@ -219,7 +219,7 @@
 				<textFieldExpression><![CDATA[$F{meta:bezeichnung_1_header}]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true">
-				<reportElement key="" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="600" y="0" width="70" height="24"/>
+				<reportElement key="gauge_header" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="600" y="0" width="70" height="24"/>
 				<box padding="5"/>
 				<textElement textAlignment="Left" verticalAlignment="Bottom"/>
 				<textFieldExpression><![CDATA[$F{meta:gauge_header}]]></textFieldExpression>
@@ -345,7 +345,7 @@
 				<textFieldExpression><![CDATA[$F{data:9}]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
-				<reportElement key="" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="600" y="0" width="70" height="15"/>
+				<reportElement key="gauge_header" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="600" y="0" width="70" height="15"/>
 				<box topPadding="2" leftPadding="5" bottomPadding="0" rightPadding="5">
 					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
 					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
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 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Created with Jaspersoft Studio version 6.5.1.final using JasperReports Library version 4.5.0  -->
-<!-- 2018-07-31T13:53:38 -->
+<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 4.5.0  -->
+<!-- 2018-09-20T13:27:46 -->
 <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="flysreport" language="groovy" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="762" leftMargin="60" rightMargin="20" topMargin="20" bottomMargin="20">
 	<property name="ireport.zoom" value="1.0"/>
 	<property name="ireport.x" value="0"/>
@@ -267,7 +267,7 @@
 				<textFieldExpression><![CDATA[$F{meta:bezeichnung_3_header}]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true">
-				<reportElement key="" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="684" y="0" width="50" height="24"/>
+				<reportElement key="gauge_header" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="684" y="0" width="50" height="24"/>
 				<box padding="2"/>
 				<textElement textAlignment="Left" verticalAlignment="Bottom"/>
 				<textFieldExpression><![CDATA[$F{meta:gauge_header}]]></textFieldExpression>
@@ -481,7 +481,7 @@
 				<textFieldExpression><![CDATA[$F{data:17}]]></textFieldExpression>
 			</textField>
 			<textField isStretchWithOverflow="true" isBlankWhenNull="true">
-				<reportElement key="" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="684" y="0" width="50" height="15"/>
+				<reportElement key="gauge_header" style="htmlStyle" positionType="Float" stretchType="RelativeToBandHeight" x="684" y="0" width="50" height="15"/>
 				<box padding="2">
 					<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
 					<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
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<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++) {
+        final int expectedSizetoGaugelabel = lines.size() + (waterlevelList.size() < 2 ? 4 : 12); // removing columns only works for fixed
+        // indices
 
-                if (i == this.maxWaterlevelPdf && mode == ExportMode.pdf)
-                    break;
+        final NumberFormat wFormatter = exportContextCSV.getFlowDepthFormatter();
+        final NumberFormat qFormatter = exportContextCSV.getQFormatter();
+        final NumberFormat durFormatter = exportContextCSV.getFloodDurationFormatter();
 
-                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());
-            }
+        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<Gauge, GaugeDurationValuesFinder> 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


More information about the Dive4Elements-commits mailing list