[PATCH 5 of 5] (issue1754) Allow ranges where start > end also for beddifferences

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


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1427191719 -3600
# Node ID 1f6b30310360345f002ff0ec778af775d931c8be
# Parent  421e5cceac842f8c66a2a47cdab8d6db711cc514
(issue1754) Allow ranges where start > end also for beddifferences.

diff -r 421e5cceac84 -r 1f6b30310360 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java	Tue Mar 24 11:06:47 2015 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java	Tue Mar 24 11:08:39 2015 +0100
@@ -37,12 +37,23 @@
 
         this.river     = access.getRiverName();
         this.heightIds = access.extractHeightIds(context);
-        double fromKm  = access.getFrom();
-        double toKm    = access.getTo();
+        double from    = access.getFrom();
+        double to      = access.getTo();
+        double start;
+        double end;
+
+        if ((!Double.isNaN(from) && !Double.isNaN(to)) && from > to) {
+            log.debug("Reordering range.");
+            start = to;
+            end = from;
+        } else {
+            start = from;
+            end = to;
+        }
 
         BedDiffYearResult [] results = new BedDiffYearResult[heightIds.length];
         for (int i = 0; i < heightIds.length; i++) {
-            BedHeightData [] pair = getHeightPair(heightIds[i], fromKm, toKm);
+            BedHeightData [] pair = getHeightPair(heightIds[i], start, end);
             if (pair[0].getYear() == null || pair[1].getYear() == null) {
                 addProblem("beddiff.missing.year");
             }


More information about the Dive4Elements-commits mailing list