changeset 9585:aa6ee96071b7

Punkt 6.2.1 Sprünge auf vollen HM
author gernotbelger
date Wed, 09 Jan 2019 18:07:51 +0100
parents 1a7cfeb1ff89
children e02797341885
files artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractCalculationResult.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractTkhCalculationResult.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java
diffstat 3 files changed, 25 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractCalculationResult.java	Wed Jan 09 17:13:25 2019 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractCalculationResult.java	Wed Jan 09 18:07:51 2019 +0100
@@ -86,14 +86,17 @@
         return new double[][] { xPoints.toNativeArray(), yPoints.toNativeArray() };
     }
 
-    protected final <TYPE> List<TYPE> getValues(final IResultType type) {
+    protected final <TYPE> List<TYPE> getValues(final IResultType type, final Predicate rowFilter) {
 
         final List<TYPE> values = new ArrayList<>();
 
         for (final ResultRow row : this.rows) {
-            @SuppressWarnings("unchecked")
-            final TYPE value = (TYPE) row.getValue(type);
-            values.add(value);
+
+            if (rowFilter.evaluate(row)) {
+                @SuppressWarnings("unchecked")
+                final TYPE value = (TYPE) row.getValue(type);
+                values.add(value);
+            }
         }
 
         return values;
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractTkhCalculationResult.java	Wed Jan 09 17:13:25 2019 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractTkhCalculationResult.java	Wed Jan 09 18:07:51 2019 +0100
@@ -12,6 +12,7 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.commons.collections.PredicateUtils;
 import org.dive4elements.river.artifacts.common.AbstractCalculationExportableResult;
 import org.dive4elements.river.artifacts.common.ResultRow;
 import org.dive4elements.river.artifacts.sinfo.tkhcalculation.SoilKind;
@@ -39,7 +40,7 @@
     public final boolean hasTkh() {
         return this.hasTkh;
     }
-    
+
     public boolean isShowRefGauges() {
         return this.wst.isShowRefGauges();
     }
@@ -47,7 +48,7 @@
     public final double[][] getTkhUpPoints() {
 
         final double[][] points = getStationPoints(SInfoResultType.tkhup);
-        final List<SoilKind> kinds = getValues(SInfoResultType.soilkind);
+        final List<SoilKind> kinds = getValues(SInfoResultType.soilkind, PredicateUtils.truePredicate());
 
         final double[] xPoints = points[0];
         final double[] yPoints = points[1];
@@ -58,7 +59,7 @@
     public final double[][] getTkhDownPoints() {
 
         final double[][] points = getStationPoints(SInfoResultType.tkhdown);
-        final List<SoilKind> kinds = getValues(SInfoResultType.soilkind);
+        final List<SoilKind> kinds = getValues(SInfoResultType.soilkind, PredicateUtils.truePredicate());
 
         final double[] xPoints = points[0];
         final double[] yPoints = points[1];
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java	Wed Jan 09 17:13:25 2019 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java	Wed Jan 09 18:07:51 2019 +0100
@@ -53,6 +53,16 @@
         }
     }
 
+    private final static class HasInfrastructurePredicate implements Predicate {
+
+        @Override
+        public boolean evaluate(final Object object) {
+            final ResultRow row = (ResultRow) object;
+
+            return row.getValue(SInfoResultType.riverside) != null;
+        }
+    }
+
     private static final long serialVersionUID = 1L;
 
     private final boolean isUseWspl;
@@ -189,7 +199,10 @@
     }
 
     public List<Double> getValidDurationChartKilometers() {
-        return getValues(GeneralResultType.station);
+
+        // Wunsch BfG (Testung MS3): nur stationen mit infrastruktur
+        final Predicate filter = new HasInfrastructurePredicate();
+        return getValues(GeneralResultType.station, filter);
     }
 
     @Override

http://dive4elements.wald.intevation.org