[PATCH] salix.supraregional table revision -> Anschluss

Wald Commits scm-commit at wald.intevation.org
Tue Jul 10 13:27:26 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1531222037 -7200
# Node ID 1c756bfee472f2a8a7f1b48ac0838c7d8cd69d0a
# Parent  972e10522ed6e8d5492a176dbe28d1cd95bedb43
salix.supraregional table revision -> Anschluss

diff -r 972e10522ed6 -r 1c756bfee472 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixZone.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixZone.java	Tue Jul 10 11:24:12 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixZone.java	Tue Jul 10 13:27:17 2018 +0200
@@ -105,7 +105,7 @@
         if (((upper - lower) > DELTA) && list.size() == 0)
             return true;
 
-        final TreeSet<SalixZone> treeList = new TreeSet<SalixZone>();
+        final TreeSet<SalixZone> treeList = new TreeSet<>();
         treeList.addAll(list);
         double lowerCompare = lower + DELTA;
         for (final SalixZone zone : treeList) {
@@ -151,4 +151,24 @@
         return basicCompare;
     }
 
-}
\ No newline at end of file
+    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;
+    }
+
+}
diff -r 972e10522ed6 -r 1c756bfee472 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java	Tue Jul 10 11:24:12 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java	Tue Jul 10 13:27:17 2018 +0200
@@ -1566,4 +1566,6 @@
     String uinfo_salix_km_overlap();
 
     String uinfo_salix_km_has_gaps();
+
+    String uinfo_salix_km_anschluss();
 }
\ No newline at end of file
diff -r 972e10522ed6 -r 1c756bfee472 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Tue Jul 10 11:24:12 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Tue Jul 10 13:27:17 2018 +0200
@@ -834,6 +834,7 @@
 uinfo_salix_km_limit_exceed = Die Zahl ist au\u00dferhalb des g\u00fcltigen km-Bereichs.
 uinfo_salix_km_overlap = Km-Bereiche \u00fcperlappen.
 uinfo_salix_km_has_gaps = Der Km-Bereich ist nicht vollst. belegt.
+uinfo_salix_km_anschluss = Der eingegebene Bereich schlie\u00dft nicht an den letzten Wert an.
 
 bundu = Betrieb und Unterhaltung 
 
diff -r 972e10522ed6 -r 1c756bfee472 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Tue Jul 10 11:24:12 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Tue Jul 10 13:27:17 2018 +0200
@@ -834,6 +834,7 @@
 uinfo_salix_km_limit_exceed = Die Zahl ist au\u00dferhalb des g\u00fcltigen km-Bereichs.
 uinfo_salix_km_overlap = Km-Bereiche \u00fcperlappen.
 uinfo_salix_km_has_gaps = Der Km-Bereich ist nicht vollst. belegt.
+uinfo_salix_km_anschluss = Der eingegebene Bereich schlie\u00dft nicht an den letzten Wert an.
 
 bundu = Betrieb und Unterhaltung
 
diff -r 972e10522ed6 -r 1c756bfee472 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SupraRegionalTablePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SupraRegionalTablePanel.java	Tue Jul 10 11:24:12 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SupraRegionalTablePanel.java	Tue Jul 10 13:27:17 2018 +0200
@@ -393,6 +393,11 @@
 
             if (from < this.minKm || from > this.maxKm || to > this.maxKm || to < this.minKm)
                 return this.MSG.uinfo_salix_km_limit_exceed();
+
+            // range anschluss
+            if (!SalixZone.isValidAnschlussRange(from, to, getSalixZones(this.table.getRecords()), this.minKm)) {
+                return this.MSG.uinfo_salix_km_anschluss();
+            }
             return null;
         }
         catch (final NumberFormatException e) {
diff -r 972e10522ed6 -r 1c756bfee472 gwt-client/src/main/java/org/dive4elements/river/client/shared/model/SalixZone.java
--- 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;
+    }
+
 }


More information about the Dive4Elements-commits mailing list