[PATCH] Bezugspegel Winfo.Wspl + Fix.Awspl fix

Wald Commits scm-commit at wald.intevation.org
Mon Sep 17 16:00:01 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1537192800 -7200
# Node ID dd05a5eef2106dc958ce5fb74111119e238ccd3d
# Parent  c81cf7e2a7708ecf012450796548e33831741afa
Bezugspegel Winfo.Wspl + Fix.Awspl fix

diff -r c81cf7e2a770 -r dd05a5eef210 artifacts/src/main/java/org/dive4elements/river/exports/FixWaterlevelExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/FixWaterlevelExporter.java	Mon Sep 17 10:20:08 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/FixWaterlevelExporter.java	Mon Sep 17 16:00:00 2018 +0200
@@ -51,9 +51,9 @@
     private final Map<String, Double> gaugeQ_W_Map = new HashMap<>();
 
     @Override
-    protected void writeRow4(final CSVWriter writer, final double wqkm[], final D4EArtifact flys, final Gauge gauge) {
-        if (!isQ()) {
-            super.writeRow4(writer, wqkm, flys, gauge);
+    protected void writeRow4(final CSVWriter writer, final double wqkm[], final D4EArtifact flys, final Gauge gauge, final boolean isQ) {
+        if (!isQ) {
+            super.writeRow4(writer, wqkm, flys, gauge, isQ);
         } else {
             final NumberFormat kmf = getKmFormatter();
             final NumberFormat wf = getWFormatter();
@@ -68,9 +68,10 @@
 
     /** Write an csv-row at gauge location. */
     @Override
-    protected void writeRow6(final CSVWriter writer, final double wqkm[], final String wOrQDesc, final D4EArtifact flys, final Gauge gauge) {
-        if (!isQ()) {
-            super.writeRow6(writer, wqkm, wOrQDesc, flys, gauge);
+    protected void writeRow6(final CSVWriter writer, final double wqkm[], final String wOrQDesc, final D4EArtifact flys, final String gaugeName,
+            final Gauge gauge, final boolean isQ) {
+        if (!isQ) {
+            super.writeRow6(writer, wqkm, wOrQDesc, flys, gaugeName, gauge, isQ);
         } else {
             final NumberFormat kmf = getKmFormatter();
             final NumberFormat wf = getWFormatter();
@@ -79,7 +80,7 @@
             final String waterlevel = getWaterlevel(wqkm[1], gauge);
 
             writer.writeNext(new String[] { kmf.format(wqkm[2]), wf.format(wqkm[0]), waterlevel, qf.format(RiverUtils.roundQ(wqkm[1])), wOrQDesc,
-                    RiverUtils.getLocationDescription(flys, wqkm[2]), gauge.getName() });
+                    RiverUtils.getLocationDescription(flys, wqkm[2]), gaugeName });
         }
     }
 
@@ -118,7 +119,7 @@
 
     @Override
     protected void writeCSVHeader(final CSVWriter writer, final boolean atGauge, final boolean isQ) {
-        if (!isQ()) {
+        if (!isQ) {
             super.writeCSVHeader(writer, atGauge, isQ);
         } else {
             log.info("WaterlevelExporter.writeCSVHeader");
diff -r c81cf7e2a770 -r dd05a5eef210 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Mon Sep 17 10:20:08 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Mon Sep 17 16:00:00 2018 +0200
@@ -75,8 +75,6 @@
 
     public static final String CSV_Q_HEADER = "common.export.csv.header.q";
 
-    private Boolean IS_Q = null;
-
     /**
      * @deprecated Use {@link WaterlevelDescriptionBuilder} instead.
      */
@@ -311,12 +309,8 @@
     }
 
     protected final boolean isQ() {
-        if (this.IS_Q == null) {
-            final WQ_MODE mode = RiverUtils.getWQMode((D4EArtifact) this.master);
-            final boolean isQ = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.QFREE;
-            this.IS_Q = isQ;
-        }
-        return this.IS_Q != null ? this.IS_Q : true;
+        final WQ_MODE mode = RiverUtils.getWQMode((D4EArtifact) this.master);
+        return mode == WQ_MODE.QGAUGE || mode == WQ_MODE.QFREE;
     }
 
     @Override
@@ -324,9 +318,9 @@
         log.info("WaterlevelExporter.writeData");
         final WQ_MODE mode = RiverUtils.getWQMode((D4EArtifact) this.master);
         final boolean atGauge = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.WGAUGE;
+        final boolean isQ = isQ();
 
         final RiverUtils.WQ_INPUT input = RiverUtils.getWQInputMode((D4EArtifact) this.master);
-        final boolean isQ = isQ();
         writeCSVMeta(writer);
         writeCSVHeader(writer, atGauge, isQ);
 
@@ -521,7 +515,7 @@
         return null;
     }
 
-    protected void writeRow4(final CSVWriter writer, final double wqkm[], final D4EArtifact flys, final Gauge gauge) {
+    protected void writeRow4(final CSVWriter writer, final double wqkm[], final D4EArtifact flys, final Gauge gauge, final boolean isQ) {
         final NumberFormat kmf = getKmFormatter();
         final NumberFormat wf = getWFormatter();
         final NumberFormat qf = getQFormatter();
@@ -530,13 +524,14 @@
     }
 
     /** Write an csv-row at gauge location. */
-    protected void writeRow6(final CSVWriter writer, final double wqkm[], final String wOrQDesc, final D4EArtifact flys, final Gauge gauge) {
+    protected void writeRow6(final CSVWriter writer, final double wqkm[], final String wOrQDesc, final D4EArtifact flys, final String gaugeName,
+            final Gauge gauge, final boolean isQ) {
         final NumberFormat kmf = getKmFormatter();
         final NumberFormat wf = getWFormatter();
         final NumberFormat qf = getQFormatter();
 
         writer.writeNext(new String[] { kmf.format(wqkm[2]), wf.format(wqkm[0]), qf.format(RiverUtils.roundQ(wqkm[1])), wOrQDesc,
-                RiverUtils.getLocationDescription(flys, wqkm[2]), gauge.getName() });
+                RiverUtils.getLocationDescription(flys, wqkm[2]), gaugeName });
     }
 
     /**
@@ -587,10 +582,6 @@
             return;
         }
 
-        final NumberFormat kmf = getKmFormatter();
-        final NumberFormat wf = getWFormatter();
-        final NumberFormat qf = getQFormatter();
-
         final int size = wqkms.size();
         double[] result = new double[3];
 
@@ -655,12 +646,12 @@
                     // TODO issue1114: Take correct gauge
                     gaugeN = km >= a && km <= b ? gaugeName : notinrange;
                 }
-                writeRow6(writer, result, desc, flys, gauge);
+                writeRow6(writer, result, desc, flys, gaugeN, gauge, isQ);
             }
         } else { // Not at gauge.
             for (int i = 0; i < size; ++i) {
                 result = wqkms.get(i, result);
-                writeRow4(writer, result, flys, gauge);
+                writeRow4(writer, result, flys, gauge, isQ);
             }
         }
 


More information about the Dive4Elements-commits mailing list