[PATCH 2 of 2] issue1457: Handle symbolic discharge of -1 as 'no discharge'
Wald Commits
scm-commit at wald.intevation.org
Tue Sep 10 11:41:26 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1378806541 -7200
# Node ID 2fed93751ecb453bfcf96a1197d0732a551d5f0e
# Parent 07e31234d29410f8eb39811a9020d9c995d2f9f0
issue1457: Handle symbolic discharge of -1 as 'no discharge'.
diff -r 07e31234d294 -r 2fed93751ecb artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Mon Sep 09 16:05:31 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Tue Sep 10 11:49:01 2013 +0200
@@ -305,24 +305,23 @@
/**
- * Return true if all values in data[0] are zero or very close to it.
+ * Return true if all values in data[0] are smaller than zero
+ * (in imported data they are set to -1 symbolically).
* Return false if data is null or empty
*/
- private boolean zeroQ(double[][] data) {
+ private boolean hasNoDischarge(double[][] data) {
if (data == null || data.length == 0) {
return false;
}
- boolean allZero = true;
-
double[] qs = data[0];
for (double q: qs) {
- if (Math.abs(q) >= 0.01d) {
- allZero = false;
+ if (q > 0d) {
+ return false;
}
}
- return allZero;
+ return true;
}
@@ -342,8 +341,8 @@
double translate = getCurrentGaugeDatum();
- // If no Q values (all zero) foud, add annotations
- if (zeroQ(data)) {
+ // If no Q values (i.e. all -1) found, add annotations.
+ if (hasNoDischarge(data)) {
List<StickyAxisAnnotation> xy = new ArrayList<StickyAxisAnnotation>();
for (double y: data[1]) {
More information about the Dive4elements-commits
mailing list