changeset 8608:0f6f702742b4

(issue1754) Check if start > end and handle this
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 24 Mar 2015 10:52:23 +0100
parents 2010da0904b7
children 421e5cceac84
files artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java	Tue Mar 24 10:50:46 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java	Tue Mar 24 10:52:23 2015 +0100
@@ -196,6 +196,8 @@
         RangeAccess rangeAccess = new RangeAccess(artifact);
         double from = rangeAccess.getFrom();
         double to = rangeAccess.getTo();
+        double start;
+        double end;
         // Load the Artifacts/facets that we want to subtract and display.
         // Expected format is:
         // [42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;0]#[1231f2-....]
@@ -203,6 +205,17 @@
         log.debug("WDifferencesState has: " + diffids);
         String datas[] = diffids.split("#");
 
+        log.debug("Difference from: " + from + " to: " + to);
+        /* Check if we need to obtain the data in a different order */
+        if ((!Double.isNaN(from) && !Double.isNaN(to)) && from > to) {
+            log.debug("Reordering range.");
+            start = to;
+            end = from;
+        } else {
+            start = from;
+            end = to;
+        }
+
         // Validate the Data-Strings.
         for (String s: datas) {
             if (!WaterlevelSelectState.isValueValid(s)) {
@@ -220,9 +233,9 @@
             // e.g.:
             // 42537f1e-3522-42ef-8968-635b03d8e9c6;longitudinal_section.w;1
             WKms minuendWKms = getWKms(StringUtil.unbracket(datas[i+0]),
-                context, from, to);
+                context, start, end);
             WKms subtrahendWKms = getWKms(StringUtil.unbracket(datas[i+1]),
-                context, from, to);
+                context, start, end);
 
             String facetName = "diff ()";
             String minName = "min";

http://dive4elements.wald.intevation.org