diff gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SalixZone.java @ 9238:1c756bfee472

salix.supraregional table revision -> Anschluss
author gernotbelger
date Tue, 10 Jul 2018 13:27:17 +0200
parents 972e10522ed6
children cbe393451ab0
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SalixZone.java	Tue Jul 10 11:24:12 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SalixZone.java	Tue Jul 10 13:27:17 2018 +0200
@@ -152,4 +152,24 @@
         return basicCompare;
     }
 
+    public static boolean isValidAnschlussRange(final double fromTest, final double toTest, final List<SalixZone> list, final double minKm) {
+        final SalixZone zone = new SalixZone(0, fromTest, toTest);
+        final double lower = zone.getLowerFromTo();
+        final double anschluss = getAnschluss(list, minKm);
+        final double differenceAbs = (lower - anschluss) > 0 ? (lower - anschluss) : (anschluss - lower); // no Math.abs allowed :-(
+        if (differenceAbs > DELTA) {
+            return false;
+        }
+
+        return true;
+    }
+
+    private static double getAnschluss(final List<SalixZone> list, final double minKm) {
+
+        if (list.size() > 0) {
+            return list.get(list.size() - 1).getUpperFromTo();
+        }
+        return minKm;
+    }
+
 }

http://dive4elements.wald.intevation.org