[PATCH] Historical Result

Wald Commits scm-commit at wald.intevation.org
Thu Jul 12 14:15:47 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1531397736 -7200
# Node ID 600e1ac42049bc99502e4deb24d5e3032f325d82
# Parent  9e6b70cce3376ebe5d618be7ea3051167dd04e57
Historical Result

diff -r 9e6b70cce337 -r 600e1ac42049 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/commons/UInfoResultType.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/commons/UInfoResultType.java	Thu Jul 12 13:27:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/commons/UInfoResultType.java	Thu Jul 12 14:15:36 2018 +0200
@@ -137,23 +137,6 @@
         }
     };
 
-    public static final UInfoResultType salixlinescen = new UInfoResultType(null, "uinfo.export.salix_line.csv.header.scen") {
-        private static final long serialVersionUID = 1L;
-
-        @Override
-        public String exportValue(final CallContext context, final Object value) {
-            final double doubleValue = asDouble(value);
-            return exportDoubleValue(context, doubleValue);
-        }
-
-        @Override
-        protected NumberFormat createFormatter(final CallContext context) {
-            // REMARK: other modules use Formatter.getWaterlevelW(context) instead, but that format with a variable number of
-            // digits.
-            return Formatter.getSalixLine(context);
-        }
-    };
-
     public static final UInfoResultType vegname = new UInfoResultType(null, "uinfo.export.csv.meta.header.veg.name") {
         private static final long serialVersionUID = 1L;
 
diff -r 9e6b70cce337 -r 600e1ac42049 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java	Thu Jul 12 13:27:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculation.java	Thu Jul 12 14:15:36 2018 +0200
@@ -135,8 +135,10 @@
                 result = new SalixLineCalculationSupraRegionalResult("Ergebnis 1 supra regional test", null, rows);
 
             } else if (scenario.equals("scenarioType.option3")) { // HISTORICAL
-                row1.putValue(UInfoResultType.salixlinehist, 2).//
-                        putValue(UInfoResultType.salixlinescen, 82);
+                row1.putValue(UInfoResultType.salixlinehist, 66).//
+                        putValue(UInfoResultType.salix_line_scenario_dwspl, 88);
+                rows.add(row1);
+                result = new SalixLineCalculationHistoricalResult("Ergebnis 1 historical test", null, rows);
             }
         }
         results.addResult(result, problems);
diff -r 9e6b70cce337 -r 600e1ac42049 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationHistoricalResult.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineCalculationHistoricalResult.java	Thu Jul 12 14:15:36 2018 +0200
@@ -0,0 +1,89 @@
+/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+package org.dive4elements.river.artifacts.uinfo.salix;
+
+import java.text.NumberFormat;
+import java.util.Collection;
+
+import org.dive4elements.river.artifacts.common.ExportContextCSV;
+import org.dive4elements.river.artifacts.common.IExportContext;
+import org.dive4elements.river.artifacts.common.ResultRow;
+import org.dive4elements.river.artifacts.sinfo.util.RiverInfo;
+import org.dive4elements.river.artifacts.sinfo.util.WstInfo;
+import org.dive4elements.river.artifacts.uinfo.commons.UInfoResultType;
+
+/**
+ * @author Domenico Nardi Tironi
+ */
+final class SalixLineCalculationHistoricalResult extends SalixLineCalculationNoScenarioResult {
+
+    private static final long serialVersionUID = 1L;
+
+    public SalixLineCalculationHistoricalResult(final String label, final WstInfo wst, final Collection<ResultRow> rows) {
+        super(label, wst, rows);
+
+    }
+
+    @Override
+    public void writeCSVHeader(final ExportContextCSV exportContextCSV, final RiverInfo river) {
+
+        final Collection<String> header = super.writeNoScenarioHeader(exportContextCSV);
+
+        header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salixlinehist));
+        header.add(exportContextCSV.formatCsvHeader(UInfoResultType.salix_line_scenario_dwspl));
+
+        exportContextCSV.writeCSVLine(header.toArray(new String[header.size()]));
+    }
+
+    @Override
+    protected void writeCSVResultMetadata(final ExportContextCSV exportContextCSV) {
+        writeHistoricalViewCSVMetadata(exportContextCSV);
+        exportContextCSV.writeBlankLine();
+
+    }
+
+    @Override
+    protected String[] formatCSVRow(final ExportContextCSV exportContextCSV, final ResultRow row) {
+
+        return formatRow(exportContextCSV, row);
+    }
+
+    private String[] formatRow(final IExportContext context, final ResultRow row) {
+
+        final Collection<String> lines = super.getNoScenarioFormat(row, context);
+
+        if (context instanceof ExportContextCSV) { // enum gespart - pdf-export hat ja nur die drei spalten
+            final NumberFormat formatter = ((ExportContextCSV) context).getSalixScenFormatter();
+
+            lines.add(context.formatRowValue(row, UInfoResultType.salixlinehist));
+            lines.add(context.formatRowValue(row, UInfoResultType.salix_line_scenario_dwspl));
+
+        }
+        return lines.toArray(new String[lines.size()]);
+    }
+
+    // TODO: move to historical class and delete here
+    private void writeHistoricalViewCSVMetadata(final ExportContextCSV exportContextCSV) {
+        final String main = "uinfo.export.csv.meta.header.salix.historical";
+        // "##Historische Betrachtung"
+        exportContextCSV.writeCSVMetaEntry(main);
+
+        final String mainSub = "uinfo.export.csv.meta.header.salix";
+        // "# Szenariotyp: "
+        exportContextCSV.writeCSVMetaEntry(mainSub + ".szenariotyp");
+        // "# Teilabschnitt: "
+        exportContextCSV.writeCSVMetaEntry(mainSub + ".teilabschnitt");
+
+        // "# Art des Zeitraums: "
+        exportContextCSV.writeCSVMetaEntry(main + ".zeitart");
+        // "# Historischer Zeitpunkt: "
+        exportContextCSV.writeCSVMetaEntry(main + ".zeitpunkt");
+    }
+}
\ No newline at end of file
diff -r 9e6b70cce337 -r 600e1ac42049 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineExporter.java	Thu Jul 12 13:27:34 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineExporter.java	Thu Jul 12 14:15:36 2018 +0200
@@ -12,7 +12,6 @@
 import org.dive4elements.river.artifacts.common.AbstractCommonExporter;
 import org.dive4elements.river.artifacts.common.ExportContextCSV;
 import org.dive4elements.river.artifacts.common.ExportContextPDF;
-import org.dive4elements.river.artifacts.common.I18NStrings;
 import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource;
 
 /**
@@ -24,12 +23,7 @@
     @Override
     protected void writeCSVGlobalMetadata(final ExportContextCSV exportContextCSV, final SalixLineCalculationResults results) {
         /* write as csv */
-        exportContextCSV.writeCSVGlobalMetadataDefaults(); // ggf auslagern innerhalb dieser Klasse
-
-        // break line ?
-
-        // "# Höhensystem des Flusses: "
-        exportContextCSV.writeCSVMetaEntry(I18NStrings.CSV_META_HEIGHT_UNIT_RIVER, results.getRiver().getWstUnit());
+        exportContextCSV.writeCSVGlobalMetadataDefaults();
 
         // Add Auswerter, Bezugspegel, Jahr/Zeitraum der Wasserspiegellage
 
@@ -39,9 +33,7 @@
         exportContextCSV.writeCSVMetaEntry("uinfo.export.salix_line.csv.meta.header.waterlevel.gauge", "wst.getGauge()");
 
         // "# Jahr/Zeitraum der Wasserspiegellage: "
-        // final int year = wst.getYear();
-        // if (year > 0)
-        exportContextCSV.writeCSVMetaEntry("uinfo.export.salix_line.csv.meta.header.waterlevel.year", "Integer.toString(year)");
+        exportContextCSV.writeCSVMetaEntry("uinfo.export.salix_line.csv.meta.header.waterlevel.year", "TODO...");
 
     }
 
diff -r 9e6b70cce337 -r 600e1ac42049 artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties	Thu Jul 12 13:27:34 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties	Thu Jul 12 14:15:36 2018 +0200
@@ -1094,8 +1094,7 @@
 uinfo.export.salix_line.csv.header.scenario_dwspl = \u0394MW [cm]
 uinfo.export.salix_line.csv.header.scenario = Salix-Linie_Szenario [m]
 uinfo.export.salix_line.csv.header.salix_line = Salix-Linie [m]
-uinfo.export.salix_line.csv.header.delta_mw =  (MW-MNW)x(-1) [m]
-uinfo.export.salix_line.csv.header.scen =  Salix-Linie [m] Szenario dMW={0} cm
+uinfo.export.salix_line.csv.header.delta_mw =  (MW-MNW)x(-1) [m] 
 uinfo.export.salix_line.csv.header.hist =  Salix-Linie [m] historisch
 uinfo.export.salix_line.csv.meta.header.evaluator = # Auswerter: {0}
 uinfo.export.salix_line.csv.meta.header.waterlevel.year = # Jahr/Zeitraum der Wasserspiegellage: {0}
diff -r 9e6b70cce337 -r 600e1ac42049 artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties	Thu Jul 12 13:27:34 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Thu Jul 12 14:15:36 2018 +0200
@@ -1094,8 +1094,7 @@
 uinfo.export.salix_line.csv.header.scenario_dwspl = \u0394MW [cm]
 uinfo.export.salix_line.csv.header.scenario = Salix-Linie_Szenario [m]
 uinfo.export.salix_line.csv.header.salix_line = Salix-Linie [m]
-uinfo.export.salix_line.csv.header.delta_mw =  (MW-MNW)x(-1) [m]
-uinfo.export.salix_line.csv.header.scen =  Salix-Linie [m] Szenario dMW={0} cm
+uinfo.export.salix_line.csv.header.delta_mw =  (MW-MNW)x(-1) [m] 
 uinfo.export.salix_line.csv.header.hist =  Salix-Linie [m] historisch
 uinfo.export.salix_line.csv.meta.header.evaluator = # Auswerter: {0}
 uinfo.export.salix_line.csv.meta.header.waterlevel.year = # Jahr/Zeitraum der Wasserspiegellage: {0}


More information about the Dive4Elements-commits mailing list