changeset 8768:ef0ec2498dd0

issue1841 Only include loads where value != NaN in info service
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 20 Aug 2015 19:14:56 +0200
parents d0f2250b5521
children 8f3a1ff48f72
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java
diffstat 2 files changed, 19 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Thu Aug 20 14:21:54 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Thu Aug 20 19:14:56 2015 +0200
@@ -222,22 +222,24 @@
             this.station = station;
         }
 
-        public void allLoads(Collection<Load> loads) {
+        public void allLoadsWithValue(Collection<Load> loads) {
             for (List<Value> values: grainFractions) {
                 if (values != null) {
                     for (Value value: values) {
-                        loads.add(value.getLoad());
+                        if (!Double.isNaN(value.getValue())) {
+                            loads.add(value.getLoad());
+                        }
                     }
                 }
             }
         }
 
-        public void allNonEpochLoads(Collection<Load> loads) {
+        public void allNonEpochLoadsWithValue(Collection<Load> loads) {
             for (List<Value> values: grainFractions) {
                 if (values != null) {
                     for (Value value: values) {
                         Load load = value.getLoad();
-                        if (load.isEpoch()) {
+                        if (load.isEpoch() || Double.isNaN(value.getValue())) {
                             continue;
                         }
                         loads.add(value.getLoad());
@@ -246,26 +248,16 @@
             }
         }
 
-        public void allOfficialLoads(Collection<Load> loads) {
-            for (List<Value> values: grainFractions) {
-                if (values != null) {
-                    for (Value value: values) {
-                        Load load = value.getLoad();
-                        if (load.getKind() == 1) {
-                            loads.add(value.getLoad());
-                        }
-                    }
-                }
-            }
-        }
-
-        public void allLoads(Collection<Load> loads, Integer sqRelationTimeInterval) {
+        public void allLoadsWithValue(Collection<Load> loads, Integer sqRelationTimeInterval) {
 
             for (List<Value> values: grainFractions) {
                 if (values == null) {
                     continue;
                 }
                 for (Value value: values) {
+                    if (Double.isNaN(value.getValue())) {
+                        continue;
+                    }
                     Load load = value.getLoad();
                     Integer sqId = load.getSQRelationTimeIntervalId();
                     if ((sqRelationTimeInterval == null)
@@ -519,13 +511,13 @@
     };
 
     /** Find all loads in the range a/b with the according sq_time_interval */
-    public Collection<Load> findLoads(double a, double b, final Integer sqRelationTimeInterval) {
+    public Collection<Load> findLoadsWithValue(double a, double b, final Integer sqRelationTimeInterval) {
         final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP);
 
         findStations(a, b, new Visitor() {
             @Override
             public void visit(Station station) {
-                station.allLoads(loads, sqRelationTimeInterval);
+                station.allLoadsWithValue(loads, sqRelationTimeInterval);
             }
         });
 
@@ -536,26 +528,26 @@
      *
      * This is mainly a convenience function for the SedimentLoadInfoService.
      */
-    public Collection<Load> findDistinctSQTimeIntervalNonEpochLoads(double a, double b) {
+    public Collection<Load> findDistinctSQTimeIntervalNonEpochLoadsWithValue(double a, double b) {
         final TreeSet<Load> loads = new TreeSet<Load>(LOAD_SQ_TI_CMP);
 
         findStations(a, b, new Visitor() {
             @Override
             public void visit(Station station) {
-                station.allNonEpochLoads(loads);
+                station.allNonEpochLoadsWithValue(loads);
             }
         });
 
         return loads;
     }
 
-    public Collection<Load> findLoads(double a, double b) {
+    public Collection<Load> findLoadsWithValue(double a, double b) {
         final TreeSet<Load> loads = new TreeSet<Load>(LOAD_ID_CMP);
 
         findStations(a, b, new Visitor() {
             @Override
             public void visit(Station station) {
-                station.allLoads(loads);
+                station.allLoadsWithValue(loads);
             }
         });
 
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java	Thu Aug 20 14:21:54 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/SedimentLoadInfoService.java	Thu Aug 20 19:14:56 2015 +0200
@@ -85,7 +85,7 @@
         log.debug("Requested type: " + type + " with sq_ti_id: " + sq_ti_id);
         Collection <Load> loads;
         if (type.equals("sq_time_intervals")) {
-            loads = allLoadData.findDistinctSQTimeIntervalNonEpochLoads(fromD, toD);
+            loads = allLoadData.findDistinctSQTimeIntervalNonEpochLoadsWithValue(fromD, toD);
 
             for (Iterator<Load> it = loads.iterator(); it.hasNext();) {
                 /* Skip loads without time interval for this info type. */
@@ -97,9 +97,9 @@
         } else {
             if (!sq_ti_id.isEmpty()) {
                 Integer id = Integer.parseInt(sq_ti_id);
-                loads = allLoadData.findLoads(fromD, toD, id);
+                loads = allLoadData.findLoadsWithValue(fromD, toD, id);
             } else {
-                loads = allLoadData.findLoads(fromD, toD);
+                loads = allLoadData.findLoadsWithValue(fromD, toD);
             }
             for (Iterator<Load> it = loads.iterator(); it.hasNext();) {
                 /* Skip epochs . */

http://dive4elements.wald.intevation.org