changeset 8610:1f6b30310360

(issue1754) Allow ranges where start > end also for beddifferences.
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 24 Mar 2015 11:08:39 +0100
parents 421e5cceac84
children e331a5ad2554
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java
diffstat 1 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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");
             }

http://dive4elements.wald.intevation.org