[PATCH] TKH calculation now takes the stations of the bed heights for the waterlevel calculation instead of letting the user define a km-step

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


# HG changeset patch
# User gernotbelger
# Date 1528287438 -7200
# Node ID 0a19a79663ddbe8bac2665b1b081b5d45f366b81
# Parent  f61bc0c63188ba5ce2ce5467d56f7810b1efbeac
TKH calculation now takes the stations of the bed heights for the waterlevel calculation instead of letting the user define a km-step

diff -r f61bc0c63188 -r 0a19a79663dd artifacts/doc/conf/artifacts/sinfo.xml
--- a/artifacts/doc/conf/artifacts/sinfo.xml	Wed Jun 06 14:16:28 2018 +0200
+++ b/artifacts/doc/conf/artifacts/sinfo.xml	Wed Jun 06 14:17:18 2018 +0200
@@ -309,13 +309,19 @@
 
 
     <!-- Calculation Mode: Überflutungsdauern Infrastrukturen BWaStr -->
-    <!-- Schrittweite benötigt für wq-state -->
+    <!-- Schrittweite benötigt für wq-state: TODO: vermutlich hier auch nicht? -->
     <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
       <from state="state.sinfo.calculation_mode" />
       <to state="state.sinfo.distance" />
       <condition data="calculation_mode" value="sinfo_calc_flood_duration" operator="equal" />
     </transition>
 
+    <state id="state.sinfo.distance" description="state.sinfo.distance" state="org.dive4elements.river.artifacts.states.DistanceSelect" helpText="help.state.sinfo.distance">
+      <data name="ld_from" type="Double" />
+      <data name="ld_to" type="Double" />
+      <data name="ld_step" type="Double" />
+    </state>
+
     <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
       <from state="state.sinfo.distance" />
       <to state="state.sinfo.riverside" />
@@ -401,21 +407,12 @@
     <!-- Calculation Mode: Transportkörperhöhen -->
     <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
       <from state="state.sinfo.calculation_mode" />
-      <to state="state.sinfo.distance" />
+      <to state="state.sinfo.distance_only" />
       <condition data="calculation_mode" value="sinfo_calc_transport_bodies_heights" operator="equal" />
     </transition>
 
-    <state id="state.sinfo.distance" description="state.sinfo.distance" state="org.dive4elements.river.artifacts.states.DistanceSelect" helpText="help.state.sinfo.distance">
-      <data name="ld_from" type="Double" />
-      <data name="ld_to" type="Double" />
-      <data name="ld_step" type="Double" />
-    </state>
-
-
-
-
     <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
-      <from state="state.sinfo.distance" />
+      <from state="state.sinfo.distance_only" />
       <to state="state.sinfo.wq" />
       <condition data="calculation_mode" value="sinfo_calc_transport_bodies_heights" operator="equal" />
     </transition>
diff -r f61bc0c63188 -r 0a19a79663dd artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java	Wed Jun 06 14:16:28 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java	Wed Jun 06 14:17:18 2018 +0200
@@ -63,11 +63,20 @@
         final RiverInfo riverInfo = new RiverInfo(river);
         final DoubleRange calcRange = access.getRange();
 
+        final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name());
+        final String user = CalculationUtils.findArtifactUser(this.context, sinfo);
+
         final Calculation problems = new Calculation();
 
         /* find relevant bed-heights */
         final List<BedHeight> defaultBedHeights = new DefaultBedHeights(river).getBedHeights(problems);
         final Collection<BedHeightsFinder> bedHeights = BedHeightsFinder.createTkhBedHeights(problems, calcRange, defaultBedHeights);
+
+        if (defaultBedHeights.isEmpty()) {
+            final TkhCalculationResults results = new TkhCalculationResults(calcModeLabel, user, riverInfo, calcRange, "");
+            return new CalculationResult(results, problems);
+        }
+
         final double[] stations = extractStations(bedHeights);
 
         /* misuse winfo-artifact to calculate waterlevels in the same way */
@@ -78,10 +87,6 @@
 
         final RiverInfoProvider infoProvider = RiverInfoProvider.forRange(this.context, river, calcRange);
 
-        final String user = CalculationUtils.findArtifactUser(this.context, sinfo);
-
-        final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name());
-
         final WaterlevelDescriptionBuilder descBuilder = new WaterlevelDescriptionBuilder(winfo, this.context);
         final String descriptionHeader = descBuilder.getColumnHeader();
 
@@ -126,10 +131,7 @@
 
     private WQKms[] calculateWaterlevels(final WINFOArtifact winfo, final double[] stations, final Calculation problems) {
 
-        // FIXME: we take kms from step, but instead we would like to take kms from bedheights
-        // FIXME: this will definitely break the serialization of the winfo artifact
-
-        final CalculationResult waterlevelData = winfo.getWaterlevelData(this.context);
+        final CalculationResult waterlevelData = winfo.computeWaterlevelData(stations);
 
         /* copy all problems */
         final Calculation winfoProblems = waterlevelData.getReport();


More information about the Dive4Elements-commits mailing list