[PATCH 3 of 5] (issue1754) Check if start > end and handle this

Wald Commits scm-commit at wald.intevation.org
Tue Mar 24 11:09:22 CET 2015


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1427190743 -3600
# Node ID 0f6f702742b4e09da89e66feae6c4c3d38d26ef0
# Parent  2010da0904b700964b7b6ffd5eb7565b4255e47e
(issue1754) Check if start > end and handle this

diff -r 2010da0904b7 -r 0f6f702742b4 artifacts/src/main/java/org/dive4elements/river/artifacts/states/WDifferencesState.java
--- 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";


More information about the Dive4Elements-commits mailing list