changeset 9465:be9bd06a1e3f

bezugswst sounding select for miss'vol only (calc crashes)
author gernotbelger
date Thu, 30 Aug 2018 10:54:40 +0200
parents c77255da734b
children a41f5f7c0b4a
files artifacts/doc/conf/artifacts/bundu.xml artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java
diffstat 3 files changed, 15 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/bundu.xml	Thu Aug 30 10:53:40 2018 +0200
+++ b/artifacts/doc/conf/artifacts/bundu.xml	Thu Aug 30 10:54:40 2018 +0200
@@ -475,7 +475,7 @@
 
     <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
       <from state="state.bundu.wst.load.missing_volume"/>
-      <to state="state.bundu.wst.soundings"/>
+      <to state="state.bundu.wst"/>
       <condition data="missing_volume" value="false" operator="equal"/>
     </transition>
 
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java	Thu Aug 30 10:53:40 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java	Thu Aug 30 10:54:40 2018 +0200
@@ -68,7 +68,6 @@
         this.rows = new ArrayList<>();
     }
 
-
     /**
      * Calculates the result rows of a bundu bzws workflow
      */
@@ -92,7 +91,7 @@
         final Calculation problems = new Calculation();
 
         // Calculate the wspl for the selected river range as in fixa awspl
-        bunduartifact.addStringData("wq_isq", "true"); // macht doch Sinn hier, sorry!
+        bunduartifact.addStringData("wq_isq", "true");
         final WinfoArtifactWrapper winfo = new WinfoArtifactWrapper(bunduartifact);
         final RiverInfoProvider riverInfoProvider = RiverInfoProvider.forRange(this.context, river, access.getRange(), true);
         final FixRealizingResult fixResult = calculateWspl(bunduartifact, problems);
@@ -103,10 +102,8 @@
         final WstInfo wstInfo = new WstInfo(wqkms.getName(), 0, riverInfoProvider.getReferenceGauge(), true);
 
         // Fetch the bed heights of the selected sounding
-        final int bedHeightId = access.getBedHeightID();
-        final BedHeightsFinder bedHeightsFinder = BedHeightsFinder.forId(problems, bedHeightId, access.getRange());
-        if (bedHeightsFinder == null)
-            return new CalculationResult(results, problems);
+        final Integer bedHeightId = access.getBedHeightID(); // TODO: REMOVE BEDHEIGHTFINDER FROM CALCULATION - HOW?
+        final BedHeightsFinder bedHeightsFinder = bedHeightId == null ? null : BedHeightsFinder.forId(problems, bedHeightId, access.getRange());
 
         // Fetch the river channel data
         final ChannelFinder channelFinder = ChannelFinder.loadValues(problems, river, access.getBezugsJahr());
@@ -115,11 +112,14 @@
 
         // Compute the result rows
         for (int i = 0; i <= wqkms.size() - 1; i++) {
+            // TODO: REMOVE BEDHEIGHTFINDER FROM CALCULATION - HOW?
             this.rows.add(createRow(wqkms.getKm(i), wqkms.getW(i), wqkms.getQ(i), bedHeightsFinder, channelFinder, riverInfoProvider, wstInfo));
         }
 
         // Compute the missing volumes
         if (access.isCalculateMissingValue()) {
+            if (bedHeightsFinder == null)
+                return new CalculationResult(results, problems);
             computeMissingVolumes(problems);
             final BedQualityCalculator bqCalculator = computeDensities(problems, bunduartifact, access, river);
             computeMissingMasses(problems, bqCalculator);
@@ -191,12 +191,15 @@
         row.putValue(BunduResultType.sounding, bedHeightsFinder.getInfo().getDescription());
 
         // Set bed and channel bottom height
+
+        // TODO: REMOVE BEDHEIGHTFINDER FROM CALCULATION - HOW?
         final double msh = bedHeightsFinder.getMeanBedHeight(station);
         row.putValue(SInfoResultType.meanBedHeight, msh);
         if (!Double.isNaN(w) && !Double.isNaN(msh))
             row.putValue(SInfoResultType.flowdepth, Formatter.roundFlowDepth(w).subtract(Formatter.roundFlowDepth(msh)).doubleValue());
         else
             row.putValue(SInfoResultType.flowdepth, Double.NaN);
+
         final double channelDepth = channelFinder.getDepth(station);
         row.putValue(BunduResultType.channelDepth, channelDepth);
         double channelHeight;
@@ -239,8 +242,7 @@
             row.putValue(BunduResultType.missDepthFields, fieldMissDepths);
             row.putValue(BunduResultType.missWidthFields, fieldMissWidths);
             row.putValue(BunduResultType.hasMissingDepth, (missFieldCnt >= 1));
-        }
-        else {
+        } else {
             row.putValue(BunduResultType.missDepthFields, fieldNulls);
             row.putValue(BunduResultType.missWidthFields, fieldNulls);
             row.putValue(BunduResultType.hasMissingDepth, null);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java	Thu Aug 30 10:53:40 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BunduAccess.java	Thu Aug 30 10:54:40 2018 +0200
@@ -89,15 +89,14 @@
         return getBoolean("missing_volume");
     }
 
-    public int getBedHeightID() {
+    public Integer getBedHeightID() {
 
         final String data = getString("soundings");
 
-        if (data == null) {
+        if (data == null || !isCalculateMissingValue()) {
             log.warn("No 'soundings' parameter specified!");
-            return 0;
-        }
-        else {
+            return null;
+        } else {
             log.debug("getBedHeightIDs(): data=" + data);
         }
 

http://dive4elements.wald.intevation.org