changeset 9308:9055afc19ec6

Fixed capturing invalid heights/discharges in S-Info flood duration calculation
author mschaefer
date Wed, 25 Jul 2018 19:28:54 +0200
parents 45bbd2c232f8
children 9a9f076d5716
files artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java	Wed Jul 25 19:27:25 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java	Wed Jul 25 19:28:54 2018 +0200
@@ -449,18 +449,21 @@
         final double[] qs = wst.findQsForW(infrastructure.getStation().doubleValue(), infrastructure.getHeight().doubleValue(), problems);
         // TODO Fehlerbehandlung (kein Q gefunden)
         final double q = (qs.length >= 1) ? qs[0] : Double.NaN;
+        // Set the result row
+        row.putValue(SInfoResultType.riverside, infrastructure.getAttributeKey());
+        row.putValue(SInfoResultType.floodDischarge, q);
+        row.putValue(SInfoResultType.infrastructureHeight, infrastructure.getHeight());
+        row.putValue(SInfoResultType.infrastructuretype, infrastructure.getInfrastructure().getType().getName());
         // Determine the relative column position of the Q of the infrastructure height
         final QPosition qPos = wst.getQPosition(infrastructure.getStation().doubleValue(), q);
+        if (qPos == null)
+            return;
         // Get the Q for the found column position for the station of the gauge
         final double qGauge = wst.getQ(qPos, gauge.getStation().doubleValue());
         // Interpolate the Q-D-table of the gauge
         final double dur = underflowDaysToOverflowDays(durFinders.get(gauge).getDuration(qGauge));
-        // Set the result row
-        row.putValue(SInfoResultType.riverside, infrastructure.getAttributeKey());
+        // Set D in the result row
         row.putValue(SInfoResultType.floodDuration, dur);
-        row.putValue(SInfoResultType.floodDischarge, q);
-        row.putValue(SInfoResultType.infrastructureHeight, infrastructure.getHeight());
-        row.putValue(SInfoResultType.infrastructuretype, infrastructure.getInfrastructure().getType().getName());
     }
 
     /**

http://dive4elements.wald.intevation.org