comparison artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java @ 6981:2fed93751ecb

issue1457: Handle symbolic discharge of -1 as 'no discharge'.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 10 Sep 2013 11:49:01 +0200
parents 765cf5fe26c3
children fa4fbd66e752
comparison
equal deleted inserted replaced
6980:07e31234d294 6981:2fed93751ecb
303 addAnnotations(flysAnno); 303 addAnnotations(flysAnno);
304 } 304 }
305 305
306 306
307 /** 307 /**
308 * Return true if all values in data[0] are zero or very close to it. 308 * Return true if all values in data[0] are smaller than zero
309 * (in imported data they are set to -1 symbolically).
309 * Return false if data is null or empty 310 * Return false if data is null or empty
310 */ 311 */
311 private boolean zeroQ(double[][] data) { 312 private boolean hasNoDischarge(double[][] data) {
312 if (data == null || data.length == 0) { 313 if (data == null || data.length == 0) {
313 return false; 314 return false;
314 } 315 }
315 316
316 boolean allZero = true;
317
318 double[] qs = data[0]; 317 double[] qs = data[0];
319 for (double q: qs) { 318 for (double q: qs) {
320 if (Math.abs(q) >= 0.01d) { 319 if (q > 0d) {
321 allZero = false; 320 return false;
322 } 321 }
323 } 322 }
324 323
325 return allZero; 324 return true;
326 } 325 }
327 326
328 327
329 /** 328 /**
330 * Add WQ Data to plot. 329 * Add WQ Data to plot.
340 double [][] data = (double [][]) wq; 339 double [][] data = (double [][]) wq;
341 String title = aaf.getFacetDescription(); 340 String title = aaf.getFacetDescription();
342 341
343 double translate = getCurrentGaugeDatum(); 342 double translate = getCurrentGaugeDatum();
344 343
345 // If no Q values (all zero) foud, add annotations 344 // If no Q values (i.e. all -1) found, add annotations.
346 if (zeroQ(data)) { 345 if (hasNoDischarge(data)) {
347 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>(); 346 List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>();
348 347
349 for (double y: data[1]) { 348 for (double y: data[1]) {
350 if (translate != 0d) { 349 if (translate != 0d) {
351 y = (y-translate)*100d; 350 y = (y-translate)*100d;

http://dive4elements.wald.intevation.org