changeset 9129:28eec75415d8

Handle case where no default bedheights are defined for a given river
author gernotbelger
date Wed, 06 Jun 2018 14:15:58 +0200
parents 99c6bf20bd92
children f61bc0c63188
files artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/DefaultBedHeights.java artifacts/src/main/resources/messages.properties artifacts/src/main/resources/messages_de.properties
diffstat 3 files changed, 21 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- 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;
     }
 
--- 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}
--- 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}

http://dive4elements.wald.intevation.org