changeset 3204:19ce06eb56c3

FixA: Only emit analysis period / discharge sectors which really contain data. flys-artifacts/trunk@4821 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 28 Jun 2012 13:07:27 +0000
parents 1b9f791937c3
children bbb488b145ce
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java
diffstat 3 files changed, 42 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Jun 28 08:16:20 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jun 28 13:07:27 2012 +0000
@@ -1,3 +1,12 @@
+2012-06-28	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixResult.java:
+	  Added method to figure out which discharge sectors of the
+	  the analysis periods really contains data.
+
+	* src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java:
+	  Only emit analysis period / discharge sectors which really contain data.
+
 2012-06-28	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	Moved FixationArtifactAccess into own package access because there are
@@ -24,7 +33,7 @@
 	  src/main/java/de/intevation/flys/artifacts/access,
 	  src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java,
 	  src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java:
-	  Addjusted imports.
+	  Adjusted imports.
 
 	* src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java:
 	  Removed superfluous imports.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixResult.java	Thu Jun 28 08:16:20 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixResult.java	Thu Jun 28 13:07:27 2012 +0000
@@ -29,6 +29,21 @@
         this.analysisPeriods = analysisPeriods;
     }
 
+    public int getUsedSectorsInAnalysisPeriods() {
+        int result = 0;
+        for (KMIndex.Entry<AnalysisPeriod []> entry: analysisPeriods) {
+            for (AnalysisPeriod period: entry.getValue()) {
+                for (int i = 0; i < 4; ++i) {
+                    result |= period.getQSectorAverage(i) != null
+                        ? (1 << i)
+                        : 0;
+                }
+                // XXX: Stop early on result == ~(~0 << 4)) ?
+            }
+        }
+        return result;
+    }
+
     public Parameters getParameters() {
         return parameters;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java	Thu Jun 28 08:16:20 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/fixation/FixationCompute.java	Thu Jun 28 13:07:27 2012 +0000
@@ -25,6 +25,7 @@
 import de.intevation.flys.artifacts.model.fixings.FixLongitudinalReferenceFacet;
 import de.intevation.flys.artifacts.model.fixings.FixOutlierFacet;
 import de.intevation.flys.artifacts.model.fixings.FixReferenceEventsFacet;
+import de.intevation.flys.artifacts.model.fixings.FixResult;
 import de.intevation.flys.artifacts.model.fixings.FixWQCurveFacet;
 
 import de.intevation.flys.artifacts.resources.Resources;
@@ -105,13 +106,9 @@
 
         if (old instanceof CalculationResult) {
             res = (CalculationResult)old;
-            log.debug("---------- Using result from Cache --------");
         }
         else {
-            log.debug("+++++++++ Recalculating +++++++");
-            FixCalculation calc =
-                new FixCalculation(access);
-
+            FixCalculation calc = new FixCalculation(access);
             res = calc.calculate();
         }
 
@@ -122,6 +119,13 @@
         if (res.getReport().hasProblems()) {
             facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
         }
+
+        FixResult fr = (FixResult)res.getData();
+
+        if (fr == null) {
+            return res;
+        }
+
         facets.add(
             new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
 
@@ -129,6 +133,8 @@
 
         int count = access.getAnalysisPeriods().length;
 
+        int sectorMask = fr.getUsedSectorsInAnalysisPeriods();
+
         for (int i = 0; i < count; i++) {
             DateRange period = access.getAnalysisPeriods()[i];
             DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
@@ -139,6 +145,11 @@
                  j <= access.getQSectorEnd().intValue();
                  j++) {
 
+                // Only emit facet for sectors that really have data.
+                if ((sectorMask & (1 << j)) == 0) {
+                    continue;
+                }
+
                 String sector = "";
                 switch (j) {
                     case 0: sector = "[0 - (MNQ+MQ)/2)"; break;
@@ -164,6 +175,7 @@
                     new FixLongitudinalAnalysisFacet(facetNdx,
                                          FIX_SECTOR_AVERAGE_LS + "_" + sectorNdx,
                                          description));
+                // TODO: i18n
                 String dev = "Abweichung: " + description;
                 facets.add(
                     new FixLongitudinalAnalysisFacet(facetNdx,

http://dive4elements.wald.intevation.org