comparison artifacts/src/main/java/org/dive4elements/river/exports/WstWriter.java @ 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 ad5238e3e736
children 7c89a545617a
comparison
equal deleted inserted replaced
7657:84573d5935be 7658:4fb5e89e7bd3
64 protected int cols; 64 protected int cols;
65 65
66 /** The last Q values. */ 66 /** The last Q values. */
67 protected double[] qs; 67 protected double[] qs;
68 68
69 /** Workaround for one use of wrongly imported files: ignore the Qs at
70 * all. */
71 protected boolean ignoreQs;
69 72
70 /** 73 /**
71 * This constructor creates a new WstWriter with a number of Q columns. 74 * This constructor creates a new WstWriter with a number of Q columns.
72 * 75 *
73 * @param columns The number of columns of the resulting WST. 76 * @param columns The number of columns of the resulting WST.
74 */ 77 */
75 public WstWriter(int columns) { 78 public WstWriter(int columns) {
79 this(columns, false);
80 }
81
82 /**
83 * This constructor creates a new WstWriter with a number of Q columns.
84 *
85 * @param columns The number of columns of the resulting WST.
86 * @param workaroundIgnoreQs do not write QLines to shadow broken data.
87 */
88 public WstWriter(int columns, boolean workaroundIgnoreQs) {
76 this.cols = columns; 89 this.cols = columns;
77 this.columnNames = new ArrayList<String>(cols); 90 this.columnNames = new ArrayList<String>(cols);
78 this.lines = new HashMap<Double, WstLine>(); 91 this.lines = new HashMap<Double, WstLine>();
79 this.qs = new double[cols]; 92 this.qs = new double[cols];
80 this.locale = Locale.US; 93 this.locale = Locale.US;
94 this.ignoreQs = workaroundIgnoreQs;
81 } 95 }
82 96
83 97
84 /** 98 /**
85 * This method is used to create the WST from the data that has been 99 * This method is used to create the WST from the data that has been
215 protected void writeWLine(PrintWriter writer, WstLine line) { 229 protected void writeWLine(PrintWriter writer, WstLine line) {
216 double km = line.getKm(); 230 double km = line.getKm();
217 double[] qs = line.getQs(); 231 double[] qs = line.getQs();
218 int num = line.getSize(); 232 int num = line.getSize();
219 233
220 if (dischargesChanged(qs)) { 234 if (!ignoreQs && dischargesChanged(qs)) {
221 writeQLine(writer, qs); 235 writeQLine(writer, qs);
222 } 236 }
223 237
224 writer.printf(locale, "%8.3f", km); 238 writer.printf(locale, "%8.3f", km);
225 239

http://dive4elements.wald.intevation.org