diff artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java @ 9535:3fa8551c3d1b

Fixed error in bundu bzws missing volume calculation for mean bed height; added various additional output columns (field bed height, field flow depth etc.)
author mschaefer
date Fri, 12 Oct 2018 18:49:38 +0200
parents 55c187a0a31e
children b9c87bbff6a4
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java	Thu Oct 11 18:39:21 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/BezugswstCalculation.java	Fri Oct 12 18:49:38 2018 +0200
@@ -29,7 +29,6 @@
 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult;
 import org.dive4elements.river.artifacts.model.river.RiverInfoProvider;
 import org.dive4elements.river.artifacts.resources.Resources;
-import org.dive4elements.river.artifacts.sinfo.common.SInfoResultType;
 import org.dive4elements.river.artifacts.sinfo.tkhstate.BedHeightsFinder;
 import org.dive4elements.river.artifacts.sinfo.tkhstate.WinfoArtifactWrapper;
 import org.dive4elements.river.artifacts.sinfo.util.CalculationUtils;
@@ -202,11 +201,11 @@
 
         // Set bed and channel bottom height
         final double msh = bedHeightsFinder.getMeanBedHeight(station);
-        row.putValue(SInfoResultType.meanBedHeight, msh);
+        row.putValue(BunduResultType.heightMeanBed, msh);
         if (!Double.isNaN(w) && !Double.isNaN(msh))
-            row.putValue(SInfoResultType.flowdepth, w - msh);
+            row.putValue(BunduResultType.flowdepthMeanBed, w - msh);
         else
-            row.putValue(SInfoResultType.flowdepth, Double.NaN);
+            row.putValue(BunduResultType.flowdepthMeanBed, Double.NaN);
 
         final double channelDepth = channelFinder.getDepth(station);
         row.putValue(BunduResultType.channelDepth, channelDepth);
@@ -288,11 +287,14 @@
         }
         if (first < 0)
             return;
+        // Calculate all kms in missing volume calc range
+        double km;
         int last = this.rows.size() - 1;
         for (int i = first; i <= this.rows.size() - 1; i++) {
-            if (!isKmInMissingVolumeRange(this.rows.get(i).getDoubleValue(GeneralResultType.station)))
+            km = this.rows.get(i).getDoubleValue(GeneralResultType.station);
+            if (!isKmInMissingVolumeRange(km))
                 break;
-            if (this.rows.get(i).getDoubleValue(GeneralResultType.station) > this.missKmTo.doubleValue() - 0.0001)
+            if (km > this.missKmTo.doubleValue() - 0.0001)
                 last = i;
             final List<Double> areas = new ArrayList<>();
             final List<Double> volumes = new ArrayList<>();
@@ -357,6 +359,8 @@
     private double[] computeMeanBedMissingAreaAndVolume(final int current, final int first, final int last) {
 
         final double areaCurr = meanBedMissingArea(current, first, last);
+        if (areaCurr < 0.0001)
+            return new double[] { 0.0, 0.0 };
         final double areaPrev = meanBedMissingArea(current - 1, first, last);
         final double areaNext = meanBedMissingArea(current + 1, first, last);
         final double kmCurr = missingKm(current);
@@ -375,7 +379,7 @@
     private double meanBedMissingArea(final int rowIndex, final int first, final int last) {
         if ((first <= rowIndex) && (rowIndex <= last)) {
             final double dh = this.rows.get(rowIndex).getDoubleValue(BunduResultType.channelDepth)
-                    - this.rows.get(rowIndex).getDoubleValue(SInfoResultType.flowdepth);
+                    - this.rows.get(rowIndex).getDoubleValue(BunduResultType.flowdepthMeanBed);
             if (dh > 0.0)
                 return dh * this.rows.get(rowIndex).getDoubleValue(BunduResultType.channelWidth);
             return 0.0;

http://dive4elements.wald.intevation.org