comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 447:5606ba4139e0

WSTs will now have a header that contains the names of the Ws or Qs that had been defined for the computation. flys-artifacts/trunk@1939 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 18 May 2011 08:04:54 +0000
parents 5d65fe4c08d5
children 9814d4808410
comparison
equal deleted inserted replaced
446:c0bec245f608 447:5606ba4139e0
250 double[] kms = getKms(); 250 double[] kms = getKms();
251 if (kms == null) { 251 if (kms == null) {
252 throw new NullPointerException("No Kms selected."); 252 throw new NullPointerException("No Kms selected.");
253 } 253 }
254 254
255 double[] qs = getQs(); 255 double[] qs = getQs();
256 double[] ws = null;
257 boolean qSel = true;
258
256 if (qs == null) { 259 if (qs == null) {
257 logger.debug("Determine Q values based on a set of W values."); 260 logger.debug("Determine Q values based on a set of W values.");
258 261 qSel = false;
259 double[] ws = getWs(); 262 ws = getWs();
260 qs = getQsForWs(ws); 263 qs = getQsForWs(ws);
261 } 264 }
262 265
263 WstValueTable wst = WstValueTableFactory.getTable(river); 266 WstValueTable wst = WstValueTableFactory.getTable(river);
264 if (wst == null) { 267 if (wst == null) {
265 throw new NullPointerException("No Wst found for selected river."); 268 throw new NullPointerException("No Wst found for selected river.");
266 } 269 }
267 270
271 WQKms[] results = computeWaterlevelData(kms, qs, wst);
272
268 // TODO Introduce a caching mechanism here! 273 // TODO Introduce a caching mechanism here!
269 274
270 return computeWaterlevelData(kms, qs, wst); 275 setWaterlevelNames(results, qSel ? qs : ws, qSel ? "Q" : "W");
276
277 return results;
278 }
279
280
281 /**
282 * Sets the name for waterlevels where each WQKms in <i>r</i> represents a
283 * column.
284 *
285 * @param r The waterlevel columns.
286 * @param v The input values of the computations.
287 * @param wq The WQ mode - can be one of "W" or "Q".
288 */
289 public static void setWaterlevelNames(WQKms[] r, double[] v, String wq) {
290 for (int i = 0; i < v.length; i++) {
291 r[i].setName(wq + "=" + Double.toString(v[i]));
292 }
271 } 293 }
272 294
273 295
274 /** 296 /**
275 * Computes the data of a waterlevel computation based on the interpolation 297 * Computes the data of a waterlevel computation based on the interpolation

http://dive4elements.wald.intevation.org