changeset 8728:f51b9305d338

(issue1801) Reference gauge for waterlevel calculation depends on direction of calculation or flow direction.
author Tom Gottfried <tom@intevation.de>
date Wed, 29 Apr 2015 18:20:23 +0200
parents 20b543616e6d
children 88b831b7bead
files artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java
diffstat 1 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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.

http://dive4elements.wald.intevation.org