[PATCH] Handle case where no default bedheights are defined for a given river

Wald Commits scm-commit at wald.intevation.org
Wed Jun 6 14:16:04 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1528287358 -7200
# Node ID 28eec75415d88b7edd2caa79f96db77248f8f762
# Parent  99c6bf20bd92fd49088e03d4beaaae4b678bddb3
Handle case where no default bedheights are defined for a given river

diff -r 99c6bf20bd92 -r 28eec75415d8 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/DefaultBedHeights.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/DefaultBedHeights.java	Wed Jun 06 13:56:48 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/DefaultBedHeights.java	Wed Jun 06 14:15:58 2018 +0200
@@ -47,6 +47,25 @@
         final Collection<String> bedHeightNames = loadBedHeightDefaultsForRiver(this.river, problems);
 
         final List<BedHeight> defaultBedHeights = loadBedHeightsByName(this.river, bedHeightNames, problems);
+        if (defaultBedHeights.isEmpty()) {
+            problems.addProblem("sinfo.bedheightsfinder.nobedheightsforriver", this.river.getName());
+            return Collections.emptyList();
+        }
+
+        /* check for overlapping ranges, N2-search, but we expect only have small numbers of bed heights */
+        final List<BedHeight> result = new ArrayList<>(defaultBedHeights.size());
+
+        for (int i = 0; i < defaultBedHeights.size(); i++) {
+            final BedHeight bedHeight = defaultBedHeights.get(i);
+
+            final Range range = bedHeight.getRange();
+            final NumberRange bedRange = new NumberRange(range.getA(), range.getB());
+
+            if (overlapsRange(bedRange, defaultBedHeights, i + 1)) {
+                problems.addProblem("sinfo.bedheightsfinder.overlappingrange", bedHeight.getDescription());
+            } else
+                result.add(bedHeight);
+        }
 
         final List<BedHeight> validBedHeights = new ArrayList<>(defaultBedHeights.size());
 
@@ -61,21 +80,6 @@
                 validBedHeights.add(bedHeight);
         }
 
-        /* check for overlapping ranges, N2-search, but we expect only have small numbers of bed heights */
-        final List<BedHeight> result = new ArrayList<>(defaultBedHeights.size());
-
-        for (int i = 0; i < defaultBedHeights.size(); i++) {
-            final BedHeight bedHeight = validBedHeights.get(i);
-
-            final Range range = bedHeight.getRange();
-            final NumberRange bedRange = new NumberRange(range.getA(), range.getB());
-
-            if (overlapsRange(bedRange, validBedHeights, i + 1)) {
-                problems.addProblem("sinfo.bedheightsfinder.overlappingrange", bedHeight.getDescription());
-            } else
-                result.add(bedHeight);
-        }
-
         return result;
     }
 
diff -r 99c6bf20bd92 -r 28eec75415d8 artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties	Wed Jun 06 13:56:48 2018 +0200
+++ b/artifacts/src/main/resources/messages.properties	Wed Jun 06 14:15:58 2018 +0200
@@ -798,6 +798,7 @@
 sinfo_calc_flow_depth.warning.waterlevel_discretisation  = Wasserspiegel {0}: r\u00e4umliche Aufl\u00f6sung betr\u00e4gt mehr als 1000m
 sinfo_calc_flow_depth.warning.year_difference = {0}: Sie verwenden als Differenzenpaar eine Wasserspiegellage aus dem Jahr {1} und eine Peilung aus dem Jahr {2}. Dies kann zu unplausiblen Werten f\u00fchren.
 
+sinfo.bedheightsfinder.nobedheightsforriver = No default bed heights for river {0}
 sinfo.bedheightsfinder.badrange = Invalid range for bed heights {0}.
 sinfo.bedheightsfinder.overlappingrange = Range of bed height {0} overlaps with other ranges.
 sinfo.bedheightsfinder.missingdescription = River {0} has no bed heights with description {1}
diff -r 99c6bf20bd92 -r 28eec75415d8 artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties	Wed Jun 06 13:56:48 2018 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Wed Jun 06 14:15:58 2018 +0200
@@ -798,6 +798,7 @@
 sinfo_calc_flow_depth.warning.waterlevel_discretisation  = Wasserspiegel {0}: r\u00e4umliche Aufl\u00f6sung betr\u00e4gt mehr als 1000m
 sinfo_calc_flow_depth.warning.year_difference = {0}: Sie verwenden als Differenzenpaar eine Wasserspiegellage aus dem Jahr {1} und eine Peilung aus dem Jahr {2}. Dies kann zu unplausiblen Werten f\u00fchren.
 
+sinfo.bedheightsfinder.nobedheightsforriver = F\u00fcr {0} sind keine Standardgel\u00e4ndeh\u00f6hen definiert
 sinfo.bedheightsfinder.badrange = Ung\u00fcltige -range- f\u00fcr Sohlh\u00f6hen {0}.
 sinfo.bedheightsfinder.overlappingrange = -Range- der Sohlh\u00f6hen {0} \u00fcberlappt andere Sohlh\u00f6hen.
 sinfo.bedheightsfinder.missingdescription = Gew\u00e4sser {0} hat keine Sohlh\u00f6he mit Bezeichnung {1}


More information about the Dive4Elements-commits mailing list