changeset 3784:9f9d5ada96ca

Merged revisions 5498-5499 via svnmerge from file:///home/clients/bsh/bsh-generischer-viewer/Material/SVN/flys-artifacts/trunk ........ r5498 | rrenkert | 2012-09-17 16:38:47 +0200 (Mo, 17 Sep 2012) | 3 lines Refactor MINFO bed quality resultsets and facets. ........ r5499 | rrenkert | 2012-09-17 16:47:05 +0200 (Mo, 17 Sep 2012) | 2 lines Fixed date range in minfo bed quality result. ........ flys-artifacts/tags/2.9.1@5530 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 19 Sep 2012 14:56:13 +0000
parents 4a973fa25125
children a5f65e8983be
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedBedQualityResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDensityFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiameterFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiameterResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedLoadBedQualityResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedParametersResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedPorosityFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityDiameterResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedloadDiameterFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedloadDiameterResult.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java
diffstat 15 files changed, 466 insertions(+), 285 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Sep 17 10:12:32 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Sep 19 14:56:13 2012 +0000
@@ -1,3 +1,44 @@
+2012-09-17  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityResult.java:
+	  Added setter for date range.
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java
+	  Set correct date range for result.
+
+2012-09-17  Raimund Renkert <raimund.renkert@intevation.de>
+
+	Refactor MINFO bed quality resultsets and facets.
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedLoadBedQualityResult.java,
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedBedQualityResult.java:
+	  Removed.
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityResult.java:
+	  Container wrapping the single calculation results.
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiameterResult.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedloadDiameterResult.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityDiameterResult.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedParametersResult.java:
+	  New. Results containing calculated average diameter, porosity and density.
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedPorosityFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedloadDiameterFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiameterFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/minfo/BedDensityFacet.java:
+	  Facets now return the concrete datatype using the facet index.
+
+	* src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java:
+	  Create a facet for each resultset.
+
+	* src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java:
+	  Use the classes containing the results.
+
+	* src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java:
+	  Use new classes for results and calculate porosity and density once
+	  each period.
+
 2012-09-17  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/resources/messages.properties,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedBedQualityResult.java	Mon Sep 17 10:12:32 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-package de.intevation.flys.artifacts.model.minfo;
-
-import gnu.trove.TDoubleArrayList;
-import de.intevation.flys.artifacts.model.DateRange;
-
-public class BedBedQualityResult
-extends BedQualityResult {
-
-    protected TDoubleArrayList diameterCap;
-    protected TDoubleArrayList diameterSub;
-    protected TDoubleArrayList porosityCap;
-    protected TDoubleArrayList porositySub;
-    protected TDoubleArrayList loadDensityCap;
-    protected TDoubleArrayList loadDensitySub;
-
-    public BedBedQualityResult(
-        String type,
-        TDoubleArrayList diameterCap,
-        TDoubleArrayList diameterSub,
-        TDoubleArrayList km,
-        DateRange range,
-        TDoubleArrayList porosityCap,
-        TDoubleArrayList porositySub,
-        TDoubleArrayList loadDensityCap,
-        TDoubleArrayList loadDensitySub
-    ) {
-        super(type, null, km, range);
-        this.diameterCap = diameterCap;
-        this.diameterSub = diameterSub;
-        this.porosityCap = porosityCap;
-        this.porositySub = porositySub;
-        this.loadDensityCap = loadDensityCap;
-        this.loadDensitySub = loadDensitySub;
-    }
-
-    public double getPorosityCap(int ndx) {
-        return porosityCap.get(ndx);
-    }
-
-    public double getPorositySub(int ndx) {
-        return porositySub.get(ndx);
-    }
-
-    public double getLoadDensityCap(int ndx) {
-        return loadDensityCap.get(ndx);
-    }
-
-    public double getLoadDensitySub(int ndx) {
-        return loadDensitySub.get(ndx);
-    }
-
-    public double getDiameterCap(int ndx) {
-        return diameterCap.get(ndx);
-    }
-
-    public double getDiameterSub(int ndx) {
-        return diameterSub.get(ndx);
-    }
-
-    public double[][] getDiameterCapData() {
-        return new double[][] {
-            kms.toNativeArray(),
-            diameterCap.toNativeArray()
-        };
-    }
-
-    public double[][] getDiameterSubData() {
-        return new double[][] {
-            kms.toNativeArray(),
-            diameterSub.toNativeArray()
-        };
-    }
-
-    public double[][] getPorosityTopLayerData() {
-        return new double[][] {
-            kms.toNativeArray(),
-            porosityCap.toNativeArray()
-        };
-    }
-
-    public double[][] getPorositySubLayerData() {
-        return new double[][] {
-            kms.toNativeArray(),
-            porositySub.toNativeArray()
-        };
-    }
-
-    public double[][] getDensityTopLayerData() {
-        return new double[][] {
-            kms.toNativeArray(),
-            loadDensityCap.toNativeArray()
-        };
-    }
-
-    public double[][] getDensitySubLayerData() {
-        return new double[][] {
-            kms.toNativeArray(),
-            loadDensitySub.toNativeArray()
-        };
-    }
-}
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDensityFacet.java	Mon Sep 17 10:12:32 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDensityFacet.java	Wed Sep 19 14:56:13 2012 +0000
@@ -38,9 +38,12 @@
         CalculationResult res = (CalculationResult) flys.compute(context, hash,
             stateId, type, false);
 
-        Object[] data = (Object[]) res.getData(); // TODO CAST TO SPECIFIC CLASS
+        int ndx = index >> 8;
+        Object[] data =
+            ((BedQualityResult[]) res.getData())[ndx].getParameters(); // TODO CAST TO SPECIFIC CLASS
 
-        return data != null && data.length > index ? data[index] : null;
+        int ndy = index & 255;
+        return data != null && data.length > ndy ? data[ndy] : null;
     }
 
     /** Copy deeply. */
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiameterFacet.java	Mon Sep 17 10:12:32 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiameterFacet.java	Wed Sep 19 14:56:13 2012 +0000
@@ -38,9 +38,11 @@
         CalculationResult res = (CalculationResult) flys.compute(context, hash,
             stateId, type, false);
 
-        Object[] data = (Object[]) res.getData(); // TODO CAST TO SPECIFIC CLASS
+        int ndx = index >> 8;
+        Object[] data = ((BedQualityResult[]) res.getData())[ndx].getBedResults(); // TODO CAST TO SPECIFIC CLASS
 
-        return data != null && data.length > index ? data[index] : null;
+        int ndy = index & 255;
+        return data != null && data.length > ndy ? data[ndy] : null;
     }
 
     /** Copy deeply. */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiameterResult.java	Wed Sep 19 14:56:13 2012 +0000
@@ -0,0 +1,50 @@
+package de.intevation.flys.artifacts.model.minfo;
+
+import gnu.trove.TDoubleArrayList;
+
+
+public class BedDiameterResult
+extends BedQualityDiameterResult
+{
+    protected TDoubleArrayList diameterCap;
+    protected TDoubleArrayList diameterSub;
+
+    public BedDiameterResult (
+        String type,
+        TDoubleArrayList diameterCap,
+        TDoubleArrayList diameterSub,
+        TDoubleArrayList km
+    ) {
+        super(type, km);
+        this.diameterCap = diameterCap;
+        this.diameterSub = diameterSub;
+    }
+
+    public double getDiameterCap(int ndx) {
+        if (diameterCap != null) {
+            return this.diameterCap.get(ndx);
+        }
+        return Double.NaN;
+    }
+
+    public double getDiameterSub(int ndx) {
+        if (diameterSub != null) {
+            return this.diameterSub.get(ndx);
+        }
+        return Double.NaN;
+    }
+
+    public double[][] getDiameterCapData() {
+        return new double[][] {
+            kms.toNativeArray(),
+            diameterCap.toNativeArray()
+        };
+    }
+
+    public double[][] getDiameterSubData() {
+        return new double[][] {
+            kms.toNativeArray(),
+            diameterSub.toNativeArray()
+        };
+    }
+}
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedLoadBedQualityResult.java	Mon Sep 17 10:12:32 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-package de.intevation.flys.artifacts.model.minfo;
-
-import de.intevation.flys.artifacts.model.DateRange;
-import gnu.trove.TDoubleArrayList;
-
-public class BedLoadBedQualityResult
-extends BedQualityResult
-{
-    public BedLoadBedQualityResult (
-        String type,
-        TDoubleArrayList diameter,
-        TDoubleArrayList km,
-        DateRange range
-    ) {
-        super(type, diameter, km, range);
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedParametersResult.java	Wed Sep 19 14:56:13 2012 +0000
@@ -0,0 +1,78 @@
+package de.intevation.flys.artifacts.model.minfo;
+
+import gnu.trove.TDoubleArrayList;
+
+import java.io.Serializable;
+
+
+public class BedParametersResult
+implements Serializable
+{
+    protected TDoubleArrayList porosityCap;
+    protected TDoubleArrayList porositySub;
+    protected TDoubleArrayList loadDensityCap;
+    protected TDoubleArrayList loadDensitySub;
+    protected TDoubleArrayList kms;
+
+    public BedParametersResult() {
+
+    }
+
+    public BedParametersResult(
+        TDoubleArrayList kms,
+        TDoubleArrayList porosityCap,
+        TDoubleArrayList porositySub,
+        TDoubleArrayList densityCap,
+        TDoubleArrayList densitySub
+    ) {
+        this.kms = kms;
+        this.porosityCap = porosityCap;
+        this.porositySub = porositySub;
+        this.loadDensityCap = densityCap;
+        this.loadDensitySub = densitySub;
+    }
+
+    public double getPorosityCap(int ndx) {
+        return porosityCap.get(ndx);
+    }
+
+    public double getPorositySub(int ndx) {
+        return porositySub.get(ndx);
+    }
+
+    public double getLoadDensityCap(int ndx) {
+        return loadDensityCap.get(ndx);
+    }
+
+    public double getLoadDensitySub(int ndx) {
+        return loadDensitySub.get(ndx);
+    }
+
+    public double[][] getPorosityCapData() {
+        return new double[][] {
+            kms.toNativeArray(),
+            porosityCap.toNativeArray()
+        };
+    }
+
+    public double[][] getPorositySubData() {
+        return new double[][] {
+            kms.toNativeArray(),
+            porositySub.toNativeArray()
+        };
+    }
+
+    public double[][] getDensityCapData() {
+        return new double[][] {
+            kms.toNativeArray(),
+            loadDensityCap.toNativeArray()
+        };
+    }
+
+    public double[][] getDensitySubData() {
+        return new double[][] {
+            kms.toNativeArray(),
+            loadDensitySub.toNativeArray()
+        };
+    }
+}
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedPorosityFacet.java	Mon Sep 17 10:12:32 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedPorosityFacet.java	Wed Sep 19 14:56:13 2012 +0000
@@ -38,9 +38,11 @@
         CalculationResult res = (CalculationResult) flys.compute(context, hash,
             stateId, type, false);
 
-        Object[] data = (Object[]) res.getData(); // TODO CAST TO SPECIFIC CLASS
+        int ndx = index >> 8;
+        Object[] data = ((BedQualityResult[]) res.getData())[ndx].getParameters(); // TODO CAST TO SPECIFIC CLASS
 
-        return data != null && data.length > index ? data[index] : null;
+        int ndy = index & 255;
+        return data != null && data.length > ndy ? data[ndy] : null;
     }
 
     /** Copy deeply. */
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java	Mon Sep 17 10:12:32 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityCalculation.java	Wed Sep 19 14:56:13 2012 +0000
@@ -99,55 +99,50 @@
                     to,
                     dr.getFrom(),
                     dr.getTo());
+            BedQualityResult result = new BedQualityResult();
+            result.setDateRange(dr);
             if (bedDiameter != null) {
+                result.add(calculateBedParameter(bedMeasurements, dr));
                 for (String bd : bedDiameter) {
-                    BedQualityResult bedResult =
+                    BedDiameterResult bedResult =
                         calculateBed(bedMeasurements, bd, dr);
 
                     // Avoid adding empty result sets.
                     if (!bedResult.isEmpty()) {
-                        results.add(bedResult);
+                        result.add(bedResult);
                     }
                 }
             }
             if (bedloadDiameter != null) {
                 for (String bld : bedloadDiameter) {
-                    BedQualityResult loadResult =
+                    BedloadDiameterResult loadResult =
                         calculateBedload(loadMeasurements, bld, dr);
-                    results.add(loadResult);
+                    result.add(loadResult);
                 }
             }
+            results.add(result);
         }
 
         return new CalculationResult(
             results.toArray(new BedQualityResult[results.size()]), this);
     }
 
-    protected BedQualityResult calculateBed(
+    private BedParametersResult calculateBedParameter(
         QualityMeasurements qm,
-        String diameter,
-        DateRange range
+        DateRange dr
     ) {
         List<Double> kms = qm.getKms();
+        QualityMeasurements capFiltered = filterCapMeasurements(qm);
+        QualityMeasurements subFiltered = filterSubMeasurements(qm);
         TDoubleArrayList location = new TDoubleArrayList();
-        TDoubleArrayList avDiameterCap = new TDoubleArrayList();
-        TDoubleArrayList avDiameterSub = new TDoubleArrayList();
         TDoubleArrayList porosityCap = new TDoubleArrayList();
         TDoubleArrayList porositySub = new TDoubleArrayList();
         TDoubleArrayList densityCap = new TDoubleArrayList();
         TDoubleArrayList densitySub = new TDoubleArrayList();
-        for (double km : kms) {
-            //Filter cap and sub measurements.
-            QualityMeasurements capFiltered = filterCapMeasurements(qm);
-            QualityMeasurements subFiltered = filterSubMeasurements(qm);
-
-            List<QualityMeasurement> cm = capFiltered.getMeasurements(km);
-            List<QualityMeasurement> sm = subFiltered.getMeasurements(km);
-
-            double avCap = calculateAverage(cm, diameter);
-            double avSub = calculateAverage(sm, diameter);
-            double[] pCap = calculatePorosity(capFiltered, km, diameter);
-            double[] pSub = calculatePorosity(subFiltered, km, diameter);
+ 
+        for(double km : kms) {
+            double[] pCap = calculatePorosity(capFiltered, km);
+            double[] pSub = calculatePorosity(subFiltered, km);
             double[] dCap = calculateDensity(capFiltered, pCap);
             double[] dSub = calculateDensity(subFiltered, pSub);
 
@@ -164,25 +159,51 @@
                 dSubRes += dSub[i];
             }
             location.add(km);
-            avDiameterCap.add(avCap);
-            avDiameterSub.add(avSub);
             porosityCap.add((pCapRes / pCap.length) * 100 );
             porositySub.add((pSubRes / pSub.length) * 100);
             densityCap.add((dCapRes / dCap.length) / 1000);
             densitySub.add((dSubRes / dSub.length) / 1000);
+ 
         }
-        return new BedBedQualityResult(
-            diameter,
-            avDiameterCap,
-            avDiameterSub,
+
+        return new BedParametersResult(
             location,
-            range,
             porosityCap,
             porositySub,
             densityCap,
             densitySub);
     }
 
+    protected BedDiameterResult calculateBed(
+        QualityMeasurements qm,
+        String diameter,
+        DateRange range
+    ) {
+        List<Double> kms = qm.getKms();
+        TDoubleArrayList location = new TDoubleArrayList();
+        TDoubleArrayList avDiameterCap = new TDoubleArrayList();
+        TDoubleArrayList avDiameterSub = new TDoubleArrayList();
+        for (double km : kms) {
+            //Filter cap and sub measurements.
+            QualityMeasurements capFiltered = filterCapMeasurements(qm);
+            QualityMeasurements subFiltered = filterSubMeasurements(qm);
+
+            List<QualityMeasurement> cm = capFiltered.getMeasurements(km);
+            List<QualityMeasurement> sm = subFiltered.getMeasurements(km);
+
+            double avCap = calculateAverage(cm, diameter);
+            double avSub = calculateAverage(sm, diameter);
+            location.add(km);
+            avDiameterCap.add(avCap);
+            avDiameterSub.add(avSub);
+        }
+        return new BedDiameterResult(
+            diameter,
+            avDiameterCap,
+            avDiameterSub,
+            location);
+    }
+
     private double[] calculateDensity(
         QualityMeasurements capFiltered,
         double[] porosity
@@ -196,8 +217,7 @@
 
     private double[] calculatePorosity(
         QualityMeasurements capFiltered,
-        double km,
-        String diameter
+        double km
     ) {
         List<QualityMeasurement> list = capFiltered.getMeasurements(km);
         double[] results = new double[list.size()];
@@ -213,7 +233,7 @@
         return results;
     }
 
-    protected BedQualityResult calculateBedload(
+    protected BedloadDiameterResult calculateBedload(
         QualityMeasurements qm,
         String diameter,
         DateRange range
@@ -227,7 +247,7 @@
             location.add(km);
             avDiameter.add(mid);
         }
-        return new BedLoadBedQualityResult(
+        return new BedloadDiameterResult(
             diameter,
             avDiameter,
             location,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityDiameterResult.java	Wed Sep 19 14:56:13 2012 +0000
@@ -0,0 +1,61 @@
+package de.intevation.flys.artifacts.model.minfo;
+
+import gnu.trove.TDoubleArrayList;
+
+import java.io.Serializable;
+
+public class BedQualityDiameterResult implements Serializable {
+
+    public static enum DIAMETER_TYPE {
+        D90,
+        D84,
+        D80,
+        D75,
+        D70,
+        D60,
+        D50,
+        D40,
+        D30,
+        D25,
+        D20,
+        D16,
+        D10,
+        DMIN,
+        DMAX
+    }
+
+    protected DIAMETER_TYPE type;
+    protected TDoubleArrayList kms;
+    protected boolean empty;
+
+    public BedQualityDiameterResult () {
+        empty = true;
+    }
+
+    public BedQualityDiameterResult (
+        String type,
+        TDoubleArrayList km
+    ) {
+        if (km.size() > 0) {
+            empty = false;
+        }
+        this.type = DIAMETER_TYPE.valueOf(type.toUpperCase());
+        this.kms = km;
+    }
+
+    public DIAMETER_TYPE getType() {
+        return this.type;
+    }
+
+    public TDoubleArrayList getKms() {
+        return this.kms;
+    }
+
+    public void setType(DIAMETER_TYPE type) {
+        this.type = type;
+    }
+
+    public boolean isEmpty() {
+        return empty;
+    }
+}
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityResult.java	Mon Sep 17 10:12:32 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedQualityResult.java	Wed Sep 19 14:56:13 2012 +0000
@@ -1,87 +1,71 @@
 package de.intevation.flys.artifacts.model.minfo;
 
-import gnu.trove.TDoubleArrayList;
-
 import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
 
 import de.intevation.flys.artifacts.model.DateRange;
 
-public class BedQualityResult implements Serializable {
+import gnu.trove.TDoubleArrayList;
 
-    public static enum DIAMETER_TYPE {
-        D90,
-        D84,
-        D80,
-        D75,
-        D70,
-        D60,
-        D50,
-        D40,
-        D30,
-        D25,
-        D20,
-        D16,
-        D10,
-        DMIN,
-        DMAX
-    }
+public class BedQualityResult
+implements Serializable
+{
 
-    protected DIAMETER_TYPE type;
-    protected TDoubleArrayList diameter;
-    protected TDoubleArrayList kms;
+    protected List<BedDiameterResult> bedResults;
+    protected List<BedloadDiameterResult> bedloadResults;
+    protected List<BedParametersResult> bedParameters;
     protected DateRange dateRange;
-    protected boolean empty;
 
     public BedQualityResult () {
-        empty = true;
-    }
+        bedResults = new LinkedList<BedDiameterResult>();
+        bedloadResults = new LinkedList<BedloadDiameterResult>();
+        bedParameters = new LinkedList<BedParametersResult>();
+    };
 
     public BedQualityResult (
-        String type,
-        TDoubleArrayList diameter,
-        TDoubleArrayList km,
+        List<BedDiameterResult> bedResults,
+        List<BedloadDiameterResult> bedloadResults,
+        List<BedParametersResult> bedParameters,
         DateRange range
     ) {
-        if (km.size() > 0) {
-            empty = false;
-        }
-        this.type = DIAMETER_TYPE.valueOf(type.toUpperCase());
-        this.diameter = diameter;
-        this.kms = km;
         this.dateRange = range;
+        this.bedResults = bedResults;
+        this.bedloadResults = bedloadResults;
+        this.bedParameters = bedParameters;
     }
 
-    public DIAMETER_TYPE getType() {
-        return this.type;
+    public BedParametersResult[] getParameters() {
+        return bedParameters.toArray(
+            new BedParametersResult[bedParameters.size()]);
     }
 
-    public TDoubleArrayList getKms() {
-        return this.kms;
+    public BedDiameterResult[] getBedResults() {
+        return bedResults.toArray(new BedDiameterResult[bedResults.size()]);
     }
 
-    public double getDiameter(int ndx) {
-        if (diameter != null) {
-            return this.diameter.get(ndx);
-        }
-        return Double.NaN;
+    public BedloadDiameterResult[] getBedloadResults() {
+        return bedloadResults.toArray(
+            new BedloadDiameterResult[bedloadResults.size()]);
+    }
+
+    public void add(BedloadDiameterResult result) {
+        bedloadResults.add(result);
+    }
+
+    public void add(BedDiameterResult result) {
+        bedResults.add(result);
+    }
+
+    public void add(BedParametersResult result) {
+        bedParameters.add(result);
     }
 
     public DateRange getDateRange() {
-        return this.dateRange;
-    }
-
-    public void setType(DIAMETER_TYPE type) {
-        this.type = type;
+        return dateRange;
     }
 
-    public boolean isEmpty() {
-        return empty;
-    }
-
-    public double[][] getDiameterData() {
-        return new double[][] {
-            kms.toNativeArray(),
-            diameter.toNativeArray()
-        };
+    public void setDateRange(DateRange range) {
+        this.dateRange = range;
     }
 }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedloadDiameterFacet.java	Mon Sep 17 10:12:32 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedloadDiameterFacet.java	Wed Sep 19 14:56:13 2012 +0000
@@ -39,9 +39,12 @@
         CalculationResult res = (CalculationResult) flys.compute(context, hash,
             stateId, type, false);
 
-        Object[] data = (Object[]) res.getData(); // TODO CAST TO SPECIFIC CLASS
+        int ndx = index >> 8;
+        Object[] data =
+            ((BedQualityResult[]) res.getData())[ndx].getBedloadResults(); // TODO CAST TO SPECIFIC CLASS
 
-        return data != null && data.length > index ? data[index] : null;
+        int ndy = index & 255;
+        return data != null && data.length > ndy ? data[ndy] : null;
     }
 
     /** Copy deeply. */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedloadDiameterResult.java	Wed Sep 19 14:56:13 2012 +0000
@@ -0,0 +1,35 @@
+package de.intevation.flys.artifacts.model.minfo;
+
+import de.intevation.flys.artifacts.model.DateRange;
+import gnu.trove.TDoubleArrayList;
+
+
+public class BedloadDiameterResult
+extends BedQualityDiameterResult
+{
+    protected TDoubleArrayList diameter;
+
+    public BedloadDiameterResult(
+        String type,
+        TDoubleArrayList diameter,
+        TDoubleArrayList km,
+        DateRange range
+    ) {
+        super (type, km);
+        this.diameter = diameter;
+    }
+
+    public double getDiameter(int ndx) {
+        if (diameter != null) {
+            return this.diameter.get(ndx);
+        }
+        return Double.NaN;
+    }
+
+    public double[][] getDiameterData() {
+        return new double[][] {
+            kms.toNativeArray(),
+            diameter.toNativeArray()
+        };
+    }
+}
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java	Mon Sep 17 10:12:32 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/minfo/BedQualityState.java	Wed Sep 19 14:56:13 2012 +0000
@@ -14,14 +14,16 @@
 import de.intevation.flys.artifacts.model.CalculationResult;
 import de.intevation.flys.artifacts.model.DateRange;
 import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.minfo.BedBedQualityResult;
 import de.intevation.flys.artifacts.model.minfo.BedDensityFacet;
 import de.intevation.flys.artifacts.model.minfo.BedDiameterFacet;
-import de.intevation.flys.artifacts.model.minfo.BedLoadBedQualityResult;
+import de.intevation.flys.artifacts.model.minfo.BedDiameterResult;
+import de.intevation.flys.artifacts.model.minfo.BedParametersResult;
 import de.intevation.flys.artifacts.model.minfo.BedPorosityFacet;
 import de.intevation.flys.artifacts.model.minfo.BedQualityCalculation;
+import de.intevation.flys.artifacts.model.minfo.BedQualityDiameterResult;
 import de.intevation.flys.artifacts.model.minfo.BedQualityResult;
 import de.intevation.flys.artifacts.model.minfo.BedloadDiameterFacet;
+import de.intevation.flys.artifacts.model.minfo.BedloadDiameterResult;
 import de.intevation.flys.artifacts.resources.Resources;
 import de.intevation.flys.artifacts.states.DefaultState;
 
@@ -83,53 +85,76 @@
 
         for (int idx = 0; idx < results.length; idx++) {
             BedQualityResult result = results[idx];
-
-            if (result instanceof BedBedQualityResult) {
-                BedBedQualityResult data = (BedBedQualityResult) result;
-                newFacets.add(new BedPorosityFacet(idx,
-                    BED_QUALITY_POROSITY_TOPLAYER,
-                    createPorosityTopLayerDescription(meta, data),
-                    ComputeType.ADVANCE, stateId, hash));
-
-                newFacets.add(new BedPorosityFacet(idx,
-                    BED_QUALITY_POROSITY_SUBLAYER,
-                    createPorositySubLayerDescription(meta, data),
-                    ComputeType.ADVANCE, stateId, hash));
-
-                newFacets.add(new BedDensityFacet(idx,
-                    BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER,
-                    createDensityTopLayerDescription(meta, data),
+            DateRange range = result.getDateRange();
+            BedDiameterResult[] bedDiameter = result.getBedResults();
+            for (int j = 0; j < bedDiameter.length; j++) {
+                newFacets.add(new BedDiameterFacet((idx << 8) + j,
+                    BED_QUALITY_BED_DIAMETER_TOPLAYER,
+                    createDiameterTopLayerDescription(
+                        meta,
+                        bedDiameter[j],
+                        range),
                     ComputeType.ADVANCE, stateId, hash));
 
-                newFacets.add(new BedDensityFacet(idx,
-                    BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER,
-                    createDensitySubLayerDescription(meta, data),
+                newFacets.add(new BedDiameterFacet((idx << 8) +j,
+                    BED_QUALITY_BED_DIAMETER_SUBLAYER,
+                    createDiameterSubLayerDescription(
+                        meta,
+                        bedDiameter[j],
+                        range),
                     ComputeType.ADVANCE, stateId, hash));
+            }
+            BedloadDiameterResult[] bedloadDiameter = result.getBedloadResults();
+            for (int j = 0;  j < bedloadDiameter.length; j++) {
+                newFacets.add(new BedloadDiameterFacet(
+                    (idx << 8) + j,
+                    BED_QUALITY_BEDLOAD_DIAMETER,
+                    createDiameterDescription(
+                        meta, bedloadDiameter[j]),
+                    ComputeType.ADVANCE,
+                    stateId,
+                    hash));
 
-                newFacets.add(new BedloadDiameterFacet(idx,
-                    BED_QUALITY_BED_DIAMETER_TOPLAYER,
-                    createDiameterTopLayerDescription(meta, data),
+            }
+            BedParametersResult[] bedParameters = result.getParameters();
+            for (int j = 0; j < bedParameters.length; j++) {
+                newFacets.add(new BedPorosityFacet((idx << 8) + j,
+                    BED_QUALITY_POROSITY_TOPLAYER,
+                    createPorosityTopLayerDescription(
+                        meta,
+                        bedParameters[j],
+                        range),
                     ComputeType.ADVANCE, stateId, hash));
 
-                newFacets.add(new BedloadDiameterFacet(idx,
-                    BED_QUALITY_BED_DIAMETER_SUBLAYER,
-                    createDiameterSubLayerDescription(meta, data),
+                newFacets.add(new BedPorosityFacet((idx << 8) + j,
+                    BED_QUALITY_POROSITY_SUBLAYER,
+                    createPorositySubLayerDescription(
+                        meta,
+                        bedParameters[j],
+                        range),
                     ComputeType.ADVANCE, stateId, hash));
-            }
-            else if (result instanceof BedLoadBedQualityResult) {
-                newFacets.add(new BedDiameterFacet(idx,
-                    BED_QUALITY_BEDLOAD_DIAMETER, createDiameterDescription(
-                        meta, result), ComputeType.ADVANCE, stateId, hash));
-            }
-            else {
-                logger.warn("unknown result object: " + result.getClass());
+
+                newFacets.add(new BedDensityFacet((idx << 8) + j,
+                    BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER,
+                    createDensityTopLayerDescription(
+                        meta,
+                        bedParameters[j],
+                        range),
+                    ComputeType.ADVANCE, stateId, hash));
+
+                newFacets.add(new BedDensityFacet((idx << 8) + j,
+                    BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER,
+                    createDensitySubLayerDescription(
+                        meta,
+                        bedParameters[j],
+                        range),
+                    ComputeType.ADVANCE, stateId, hash));
             }
         }
     }
 
     protected String createPorosityTopLayerDescription(CallMeta meta,
-        BedBedQualityResult result) {
-        DateRange range = result.getDateRange();
+        BedParametersResult result, DateRange range) {
         Date from = range != null ? range.getFrom() : new Date();
         Date to = range != null ? range.getTo() : new Date();
 
@@ -139,8 +164,7 @@
     }
 
     protected String createPorositySubLayerDescription(CallMeta meta,
-        BedBedQualityResult result) {
-        DateRange range = result.getDateRange();
+        BedParametersResult result, DateRange range) {
         Date from = range != null ? range.getFrom() : new Date();
         Date to = range != null ? range.getTo() : new Date();
 
@@ -150,8 +174,7 @@
     }
 
     protected String createDensityTopLayerDescription(CallMeta meta,
-        BedBedQualityResult result) {
-        DateRange range = result.getDateRange();
+        BedParametersResult result, DateRange range) {
         Date from = range != null ? range.getFrom() : new Date();
         Date to = range != null ? range.getTo() : new Date();
 
@@ -161,8 +184,7 @@
     }
 
     protected String createDensitySubLayerDescription(CallMeta meta,
-        BedBedQualityResult result) {
-        DateRange range = result.getDateRange();
+        BedParametersResult result, DateRange range) {
         Date from = range != null ? range.getFrom() : new Date();
         Date to = range != null ? range.getTo() : new Date();
 
@@ -172,8 +194,7 @@
     }
 
     protected String createDiameterTopLayerDescription(CallMeta meta,
-        BedBedQualityResult result) {
-        DateRange range = result.getDateRange();
+        BedDiameterResult result, DateRange range) {
         Date from = range != null ? range.getFrom() : new Date();
         Date to = range != null ? range.getTo() : new Date();
 
@@ -185,8 +206,7 @@
     }
 
     protected String createDiameterSubLayerDescription(CallMeta meta,
-        BedBedQualityResult result) {
-        DateRange range = result.getDateRange();
+        BedDiameterResult result, DateRange range) {
         Date from = range != null ? range.getFrom() : new Date();
         Date to = range != null ? range.getTo() : new Date();
 
@@ -197,7 +217,7 @@
     }
 
     protected String createDiameterDescription(CallMeta meta,
-        BedQualityResult result) {
+        BedQualityDiameterResult result) {
         return Resources.getMsg(meta, I18N_FACET_BEDLOAD_DIAMETER,
             I18N_FACET_BEDLOAD_DIAMETER, new Object[] { result.getType() });
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java	Mon Sep 17 10:12:32 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/minfo/BedQualityGenerator.java	Wed Sep 19 14:56:13 2012 +0000
@@ -7,9 +7,10 @@
 import de.intevation.artifactdatabase.state.ArtifactAndFacet;
 import de.intevation.artifactdatabase.state.Facet;
 import de.intevation.flys.artifacts.model.FacetTypes;
-import de.intevation.flys.artifacts.model.minfo.BedBedQualityResult;
-import de.intevation.flys.artifacts.model.minfo.BedLoadBedQualityResult;
+import de.intevation.flys.artifacts.model.minfo.BedDiameterResult;
+import de.intevation.flys.artifacts.model.minfo.BedParametersResult;
 import de.intevation.flys.artifacts.model.minfo.BedQualityResult;
+import de.intevation.flys.artifacts.model.minfo.BedloadDiameterResult;
 import de.intevation.flys.exports.StyledSeriesBuilder;
 import de.intevation.flys.exports.XYChartGenerator;
 import de.intevation.flys.jfree.StyledXYSeries;
@@ -148,38 +149,38 @@
         // TODO BED_QUALITY_BED_DIAMETER_TOPLAYER
         if (name.equals(BED_QUALITY_BED_DIAMETER_TOPLAYER)) {
             doBedDiameterTopLayerOut(
-                (BedBedQualityResult) artifactAndFacet.getData(context),
+                (BedDiameterResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
         else if (name.equals(BED_QUALITY_BED_DIAMETER_SUBLAYER)) {
             doBedDiameterSubLayerOut(
-                (BedBedQualityResult) artifactAndFacet.getData(context),
+                (BedDiameterResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
         // TODO BED_QUALITY_BED_DIAMETER_SUBLAYER
         else if (name.equals(BED_QUALITY_BEDLOAD_DIAMETER)) {
             doBedLoadDiameterOut(
-                (BedLoadBedQualityResult) artifactAndFacet.getData(context),
+                (BedloadDiameterResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
         else if (name.equals(BED_QUALITY_POROSITY_TOPLAYER)) {
             doPorosityTopLayerOut(
-                (BedBedQualityResult) artifactAndFacet.getData(context),
+                (BedParametersResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
         else if (name.equals(BED_QUALITY_POROSITY_SUBLAYER)) {
             doPorositySubLayerOut(
-                (BedBedQualityResult) artifactAndFacet.getData(context),
+                (BedParametersResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
         else if (name.equals(BED_QUALITY_SEDIMENT_DENSITY_TOPLAYER)) {
             doDensityTopLayerOut(
-                (BedBedQualityResult) artifactAndFacet.getData(context),
+                (BedParametersResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
         else if (name.equals(BED_QUALITY_SEDIMENT_DENSITY_SUBLAYER)) {
             doDensitySubLayerOut(
-                (BedBedQualityResult) artifactAndFacet.getData(context),
+                (BedParametersResult) artifactAndFacet.getData(context),
                 artifactAndFacet, attr, visible);
         }
         else if (FacetTypes.IS.MANUALPOINTS(name)) {
@@ -192,7 +193,7 @@
         }
     }
 
-    protected void doBedDiameterTopLayerOut(BedBedQualityResult data,
+    protected void doBedDiameterTopLayerOut(BedDiameterResult data,
         ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doBedDiameterTopLayerOut");
 
@@ -202,7 +203,7 @@
         addAxisSeries(series, YAXIS.W.idx, visible);
     }
 
-    protected void doBedDiameterSubLayerOut(BedBedQualityResult data,
+    protected void doBedDiameterSubLayerOut(BedDiameterResult data,
         ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doBedDiameterSubLayerOut");
 
@@ -212,7 +213,7 @@
         addAxisSeries(series, YAXIS.W.idx, visible);
     }
 
-    protected void doBedLoadDiameterOut(BedQualityResult data,
+    protected void doBedLoadDiameterOut(BedloadDiameterResult data,
         ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doBedLoadDiameterOut");
 
@@ -222,49 +223,49 @@
         addAxisSeries(series, YAXIS.W.idx, visible);
     }
 
-    protected void doPorosityTopLayerOut(BedBedQualityResult data,
+    protected void doPorosityTopLayerOut(BedParametersResult data,
         ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doPorosityTopLayerOut");
 
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
 
-        StyledSeriesBuilder.addPoints(series, data.getPorosityTopLayerData(),
+        StyledSeriesBuilder.addPoints(series, data.getPorosityCapData(),
             true);
 
         addAxisSeries(series, YAXIS.P.idx, visible);
     }
 
-    protected void doPorositySubLayerOut(BedBedQualityResult data,
+    protected void doPorositySubLayerOut(BedParametersResult data,
         ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doPorositySubLayerOut");
 
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
 
-        StyledSeriesBuilder.addPoints(series, data.getPorositySubLayerData(),
+        StyledSeriesBuilder.addPoints(series, data.getPorositySubData(),
             true);
 
         addAxisSeries(series, YAXIS.P.idx, visible);
     }
 
-    protected void doDensityTopLayerOut(BedBedQualityResult data,
+    protected void doDensityTopLayerOut(BedParametersResult data,
         ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doDensityOut");
 
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
 
-        StyledSeriesBuilder.addPoints(series, data.getDensityTopLayerData(),
+        StyledSeriesBuilder.addPoints(series, data.getDensityCapData(),
             true);
 
         addAxisSeries(series, YAXIS.D.idx, visible);
     }
 
-    protected void doDensitySubLayerOut(BedBedQualityResult data,
+    protected void doDensitySubLayerOut(BedParametersResult data,
         ArtifactAndFacet aandf, Document theme, boolean visible) {
         logger.debug("BedQuality.doDensityOut");
 
         XYSeries series = new StyledXYSeries(aandf.getFacetDescription(), theme);
 
-        StyledSeriesBuilder.addPoints(series, data.getDensitySubLayerData(),
+        StyledSeriesBuilder.addPoints(series, data.getDensitySubData(),
             true);
 
         addAxisSeries(series, YAXIS.D.idx, visible);

http://dive4elements.wald.intevation.org