changeset 7658:4fb5e89e7bd3

issue1020: WstWriter: Add flag to ignore Qs alltogether.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 06 Dec 2013 10:51:47 +0100
parents 84573d5935be
children 2e1392067986
files artifacts/src/main/java/org/dive4elements/river/exports/WstWriter.java
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WstWriter.java	Thu Dec 05 22:22:37 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WstWriter.java	Fri Dec 06 10:51:47 2013 +0100
@@ -66,6 +66,9 @@
     /** The last Q values. */
     protected double[] qs;
 
+    /** Workaround for one use of wrongly imported files: ignore the Qs at
+     * all. */
+    protected boolean ignoreQs;
 
     /**
      * This constructor creates a new WstWriter with a number of Q columns.
@@ -73,11 +76,22 @@
      * @param columns The number of columns of the resulting WST.
      */
     public WstWriter(int columns) {
+        this(columns, false);
+    }
+
+    /**
+     * This constructor creates a new WstWriter with a number of Q columns.
+     *
+     * @param columns The number of columns of the resulting WST.
+     * @param workaroundIgnoreQs do not write QLines to shadow broken data.
+     */
+    public WstWriter(int columns, boolean workaroundIgnoreQs) {
         this.cols        = columns;
         this.columnNames = new ArrayList<String>(cols);
         this.lines       = new HashMap<Double, WstLine>();
         this.qs          = new double[cols];
         this.locale      = Locale.US;
+        this.ignoreQs    = workaroundIgnoreQs;
     }
 
 
@@ -217,7 +231,7 @@
         double[] qs  = line.getQs();
         int      num = line.getSize();
 
-        if (dischargesChanged(qs)) {
+        if (!ignoreQs && dischargesChanged(qs)) {
             writeQLine(writer, qs);
         }
 

http://dive4elements.wald.intevation.org