[PATCH 1 of 2] (issue1755) Do not add empty data facets in BedQuality State

Wald Commits scm-commit at wald.intevation.org
Thu Apr 2 18:37:33 CEST 2015


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1427991721 -7200
# Node ID 7faf1dad15a6509197e5b7b80e8b526bb6296ac0
# Parent  af415396d9cad17b7fbbfc1541df51eef90bf96d
(issue1755) Do not add empty data facets in BedQuality State

diff -r af415396d9ca -r 7faf1dad15a6 artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java	Thu Apr 02 17:40:18 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityState.java	Thu Apr 02 18:22:01 2015 +0200
@@ -122,7 +122,19 @@
         }
 
         generateFacets(context, newFacets, results, getID(), hash);
-        generateDataFacets(context, newFacets, access, getID(), hash);
+        List<Facet> candidates = new ArrayList<Facet>();
+        generateDataFacets(context, candidates, access, getID(), hash);
+        /* Do not create empty facets */
+        for (Facet f: candidates) {
+            DataFacet candidate = (DataFacet)f;
+            Object d = candidate.getData((Artifact)artifact, context);
+            if (d != null) {
+                double [][] data = (double[][]) d;
+                if (data.length > 0 && data[0].length > 0) {
+                    newFacets.add(candidate);
+                }
+            }
+        }
         log.debug("Created " + newFacets.size() + " new Facets.");
         facets.addAll(newFacets);
 


More information about the Dive4Elements-commits mailing list