comparison flys-artifacts/src/main/java/de/intevation/flys/exports/WstWriter.java @ 749:72bcbc308501

The WST export contains the corrected W values now. flys-artifacts/trunk@2257 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 27 Jun 2011 16:07:24 +0000
parents 5606ba4139e0
children d9fb3a178be4
comparison
equal deleted inserted replaced
748:30be4b71c36c 749:72bcbc308501
60 public WstWriter(int cols) { 60 public WstWriter(int cols) {
61 this.columnNames = new ArrayList<String>(cols); 61 this.columnNames = new ArrayList<String>(cols);
62 this.lines = new HashMap<Double, WstLine>(); 62 this.lines = new HashMap<Double, WstLine>();
63 this.qs = new double[cols]; 63 this.qs = new double[cols];
64 this.locale = Locale.US; 64 this.locale = Locale.US;
65 this.cols = cols;
66
67 } 65 }
68 66
69 67
70 /** 68 /**
71 * This method is used to create the WST from the data that has been 69 * This method is used to create the WST from the data that has been
76 74
77 PrintWriter writer = new PrintWriter( 75 PrintWriter writer = new PrintWriter(
78 new BufferedWriter( 76 new BufferedWriter(
79 new OutputStreamWriter(out))); 77 new OutputStreamWriter(out)));
80 78
79 this.qs = new double[cols];
80
81 writeHeader(writer); 81 writeHeader(writer);
82 82
83 Collection<WstLine> collection = new TreeMap(lines).values(); 83 Collection<WstLine> collection = new TreeMap(lines).values();
84 84
85 for (WstLine line: collection) { 85 for (WstLine line: collection) {
108 108
109 line.add(wqkms[0], wqkms[1]); 109 line.add(wqkms[0], wqkms[1]);
110 } 110 }
111 111
112 112
113 public void addCorrected(double[] wqckms) {
114 Double km = wqckms[2];
115
116 WstLine line = lines.get(km);
117
118 if (line == null) {
119 line = new WstLine(km.doubleValue());
120 lines.put(km, line);
121 }
122
123 line.add(wqckms[3], wqckms[1]);
124 }
125
126
113 /** 127 /**
114 * Adds a further column name. 128 * Adds a further column name.
115 * 129 *
116 * @param name The name of the new column. 130 * @param name The name of the new column.
117 */ 131 */
118 public void addColumn(String name) { 132 public void addColumn(String name) {
119 if (name != null) { 133 if (name != null) {
134 cols++;
135
136 String basename = name;
137
138 int i = 0;
139 while (columnNames.contains(name)) {
140 name = basename + "_" + i++;
141
142 if (name.length() > 9) {
143 name = name.substring(name.length() - 9);
144 }
145 }
146
120 columnNames.add(name); 147 columnNames.add(name);
121 } 148 }
122 } 149 }
123 150
124 151
176 * @param qs the Q values for the next range. 203 * @param qs the Q values for the next range.
177 */ 204 */
178 protected void writeQLine(PrintWriter writer, double[] qs) { 205 protected void writeQLine(PrintWriter writer, double[] qs) {
179 writer.write("*\u001f "); 206 writer.write("*\u001f ");
180 207
181 for (int i = 0; i < cols; i++) { 208 for (int i = 0; i < qs.length; i++) {
182 this.qs[i] = qs[i]; 209 this.qs[i] = qs[i];
183 210
184 writer.printf(locale, "%9.2f", qs[i]); 211 writer.printf(locale, "%9.2f", qs[i]);
185 } 212 }
186 213

http://dive4elements.wald.intevation.org