changeset 8954:183f42641ab6

Fixed: flowd depth calculation without transport bodies heights did not work any more
author gernotbelger
date Mon, 19 Mar 2018 14:13:37 +0100
parents c40db8e8dcae
children 798d9dcbccdd
files artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthExporter.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java
diffstat 3 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthExporter.java	Mon Mar 19 14:01:21 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthExporter.java	Mon Mar 19 14:13:37 2018 +0100
@@ -31,6 +31,10 @@
 // REMARK: must be public because its registered in generators.xml
 public class FlowDepthExporter extends AbstractSInfoExporter<FlowDepthCalculationResult, FlowDepthCalculationResults> {
 
+    private static enum ExportMode {
+        pdf, csv
+    }
+
     /** The log used in this exporter. */
     private static Logger log = Logger.getLogger(FlowDepthExporter.class);
 
@@ -94,22 +98,24 @@
 
     @Override
     protected String[] formatCSVRow(final FlowDepthCalculationResults results, final FlowDepthCalculationResult result, final SInfoResultRow row) {
-        return formatRow(row);
+        return formatRow(row, ExportMode.csv);
     }
 
     /**
      * Format a row of a flow depth result into an array of string, both used by csv and pdf
      *
+     * @param pdf
+     *
      * @param useTkh
      */
-    private String[] formatRow(final SInfoResultRow row) {
+    private String[] formatRow(final SInfoResultRow row, final ExportMode mode) {
 
         final Collection<String> lines = new ArrayList<>(11);
 
         lines.add(row.exportValue(this.context, SInfoResultType.station));
         lines.add(row.exportValue(this.context, SInfoResultType.flowdepth));
 
-        if (getData().isUseTkh()) {
+        if (mode == ExportMode.pdf || getData().isUseTkh()) {
             lines.add(row.exportValue(this.context, SInfoResultType.flowdepthtkh));
             lines.add(row.exportValue(this.context, SInfoResultType.tkh));
         }
@@ -152,6 +158,6 @@
 
     @Override
     protected String[] formatPDFRow(final FlowDepthCalculationResults results, final SInfoResultRow row) {
-        return formatRow(row);
+        return formatRow(row, ExportMode.pdf);
     }
 }
\ No newline at end of file
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.java	Mon Mar 19 14:01:21 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/TkhCalculator.java	Mon Mar 19 14:13:37 2018 +0100
@@ -122,6 +122,9 @@
     private SoilKind getSoilKind(final double km) {
 
         try {
+            if (this.soilKindFinder == null)
+                return null;
+
             return this.soilKindFinder.findSoilKind(km);
         }
         catch (final ArgumentOutsideDomainException e) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java	Mon Mar 19 14:01:21 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java	Mon Mar 19 14:13:37 2018 +0100
@@ -146,7 +146,7 @@
 
             final double station = wkms.getKm(i);
 
-            /* find the right calculator (i.e. bedheigh) depending on station, there should only be one maximal */
+            /* find the right calculator (i.e. bed height) depending on station, there should only be one maximal */
             final TkhCalculator tkhCalculator = findCalculator(calculatorsByRanges, station);
             if (tkhCalculator == null)
                 continue;

http://dive4elements.wald.intevation.org