[PATCH 2 of 2] (issue1801) Reference gauge for waterlevel calculation depends on direction of calculation or flow direction
Wald Commits
scm-commit at wald.intevation.org
Wed Apr 29 18:21:32 CEST 2015
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1430324423 -7200
# Node ID f51b9305d338d1da31aecdb72a4a4f8781570fe3
# Parent 20b543616e6d4326740a180edc01578eee836109
(issue1801) Reference gauge for waterlevel calculation depends on direction of calculation or flow direction.
diff -r 20b543616e6d -r f51b9305d338 artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java Wed Apr 29 18:17:53 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java Wed Apr 29 18:20:23 2015 +0200
@@ -258,7 +258,8 @@
log.debug("'free' calculation (km " + refKm + ")");
}
else {
- Gauge gauge = river.determineGaugeByPosition(range[0]);
+ Gauge gauge = determineRefGauge(range, river);
+
if (gauge == null) {
return error(
new WQKms[0], "no.gauge.found.for.km", range[0]);
@@ -654,8 +655,7 @@
/**
- * Returns the Qs for a number of Ws. This method makes use of
- * DischargeTables.getQForW().
+ * Returns the Qs for a number of Ws.
*
* @param ws An array of W values.
*
@@ -730,7 +730,7 @@
log.debug("range: " + Arrays.toString(range));
}
- Gauge g = r.determineGaugeByPosition(range[0]);
+ Gauge g = determineRefGauge(range, rangeAccess.getRiver());
if (g == null) {
log.warn("no gauge found for km: " + range[0]);
return null;
@@ -782,6 +782,21 @@
/**
+ * Determine reference gauge dependent on direction of calculation
+ * for a range calculation, otherwise dependent on flow direction.
+ */
+ public Gauge determineRefGauge(double[] range, River river) {
+ if (isRange()) {
+ return river.determineGaugeByPosition(
+ range[0],
+ range[0] > range[1]);
+ }
+ else {
+ return river.determineGaugeByPosition(range[0]);
+ }
+ }
+
+ /**
* Determines the selected mode of distance/range input.
*
* @return true, if the range mode is selected otherwise false.
More information about the Dive4Elements-commits
mailing list