[PATCH] Punkt 6.2.1 Sprünge auf vollen HM

Wald Commits scm-commit at wald.intevation.org
Wed Jan 9 18:07:57 CET 2019


# HG changeset patch
# User gernotbelger
# Date 1547053671 -3600
# Node ID aa6ee96071b7b2d367785acee0bca03544451ad1
# Parent  1a7cfeb1ff8926d4ffe252e657aea5265f527a87
Punkt 6.2.1 Sprünge auf vollen HM

diff -r 1a7cfeb1ff89 -r aa6ee96071b7 artifacts/src/main/java/org/dive4elements/river/artifacts/common/AbstractCalculationResult.java
--- 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;
diff -r 1a7cfeb1ff89 -r aa6ee96071b7 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/common/AbstractTkhCalculationResult.java
--- 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];
diff -r 1a7cfeb1ff89 -r aa6ee96071b7 artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculationResult.java
--- 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


More information about the Dive4Elements-commits mailing list