changeset 7983:62befca02480 facet-metadata

Moved MiddleBedHeight classes to minfo package. Facet now returns double[][] data.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 01 Jul 2014 13:25:46 +0200
parents 45cced06490c
children cf674b03901a
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightData.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightData.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightFacet.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/MiddleBedHeight.java artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java artifacts/src/main/java/org/dive4elements/river/exports/process/MiddleBedHeightProcessor.java
diffstat 9 files changed, 471 insertions(+), 456 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightCalculation.java	Mon Jun 30 11:29:45 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.artifacts.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.dive4elements.artifacts.Artifact;
-import org.dive4elements.artifacts.common.utils.DateUtils;
-
-import org.dive4elements.river.model.BedHeightSingle;
-import org.dive4elements.river.model.BedHeightSingleValue;
-import org.dive4elements.river.model.TimeInterval;
-
-import org.dive4elements.river.artifacts.access.BedHeightAccess;
-
-
-public class MiddleBedHeightCalculation extends Calculation {
-
-    private static final Logger logger =
-        Logger.getLogger(MiddleBedHeightCalculation.class);
-
-
-    public CalculationResult calculate(BedHeightAccess access) {
-        logger.info("MiddleBedHeightCalculation.calculate");
-
-        int[] singleIds = access.getBedHeightSingleIDs();
-
-
-        if (logger.isDebugEnabled()) {
-            Artifact artifact = access.getArtifact();
-
-            logger.debug("Artifact '" + artifact.identifier() + "' contains:");
-            if (singleIds != null) {
-                logger.debug("   " + singleIds.length + " single bedheight ids");
-            }
-        }
-
-        List<BedHeightSingle> singles = getSingles(access, singleIds);
-
-        return buildCalculationResult(access, singles);
-    }
-
-
-    protected List<BedHeightSingle> getSingles(
-        BedHeightAccess access,
-        int[] ids
-    ) {
-        List<BedHeightSingle> singles = new ArrayList<BedHeightSingle>();
-
-        for (int id: ids) {
-            BedHeightSingle s = BedHeightSingle.getBedHeightSingleById(id);
-
-            if (s != null) {
-                singles.add(s);
-            }
-            else {
-                logger.warn("Cannot find Single by id: " + id);
-                // TODO ADD WARNING
-            }
-        }
-
-        return singles;
-    }
-
-
-    protected CalculationResult buildCalculationResult(
-        BedHeightAccess       access,
-        List<BedHeightSingle> singles
-    ) {
-        logger.info("MiddleBedHeightCalculation.buildCalculationResult");
-
-        double kmLo = access.getLowerKM();
-        double kmHi = access.getUpperKM();
-
-        List<MiddleBedHeightData> data = new ArrayList<MiddleBedHeightData>();
-
-        for (BedHeightSingle single: singles) {
-            MiddleBedHeightData d = prepareSingleData(single, kmLo, kmHi);
-
-            if (d != null) {
-                data.add(d);
-            }
-        }
-
-        logger.debug("Calculation results in " + data.size() + " data objects.");
-
-        return new CalculationResult((MiddleBedHeightData[])
-            data.toArray(new MiddleBedHeightData[data.size()]), this);
-    }
-
-
-    protected MiddleBedHeightData prepareSingleData(
-        BedHeightSingle single,
-        double kmLo,
-        double kmHi
-    ) {
-        logger.debug("Prepare data for single: " + single.getDescription());
-
-        List<BedHeightSingleValue> values =
-            BedHeightSingleValue.getBedHeightSingleValues(single, kmLo, kmHi);
-
-        int year = single.getYear() != null ? single.getYear() : 0;
-
-        MiddleBedHeightData data = new MiddleBedHeightData(
-            year,
-            year,
-            single.getEvaluationBy(),
-            single.getDescription());
-
-        for (BedHeightSingleValue value: values) {
-            if (value.getHeight() != null) {
-                double uncert = value.getUncertainty() != null ?
-                    value.getUncertainty().doubleValue() : Double.NaN;
-                double sounding = value.getSoundingWidth() != null ?
-                    value.getSoundingWidth().doubleValue() : Double.NaN;
-                double gap = value.getDataGap() != null ?
-                    value.getDataGap().doubleValue() : Double.NaN;
-                data.addAll(value.getStation().doubleValue(),
-                    value.getHeight().doubleValue(),
-                    uncert,
-                    sounding,
-                    gap,
-                    value.getWidth().doubleValue(),
-                    false);
-             }
-            else {
-                data.addAll(value.getStation().doubleValue(),
-                    0,
-                    0,
-                    0,
-                    0,
-                    0,
-                    true);
-            }
-        }
-
-        logger.debug("Single contains " + values.size() + " values");
-
-        return data;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightData.java	Mon Jun 30 11:29:45 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,221 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.artifacts.model;
-
-import java.io.Serializable;
-
-import java.util.ArrayList;
-
-import gnu.trove.TDoubleArrayList;
-
-import org.dive4elements.artifacts.CallContext;
-
-import org.dive4elements.river.artifacts.resources.Resources;
-
-import org.apache.log4j.Logger;
-
-
-public class MiddleBedHeightData implements Serializable,
-                                            Comparable<MiddleBedHeightData> {
-
-    /** Very private logger. */
-    private static final Logger logger = Logger.getLogger(MiddleBedHeightData.class);
-
-    public static final String I18N_SINGLE_NAME = "facet.bedheight_middle.single";
-    public static final String I18N_EPOCH_NAME  = "facet.bedheight_middle.epoch";
-
-    private int    startYear;
-    private int    endYear;
-    private String evaluatedBy;
-    private String description;
-
-    private TDoubleArrayList km;
-    private TDoubleArrayList middleHeight;
-    private TDoubleArrayList uncertainty;
-    private TDoubleArrayList soundingWidth;
-    private TDoubleArrayList dataGap;
-    private TDoubleArrayList width;
-    private ArrayList empty;
-
-
-    protected MiddleBedHeightData(int start, int end, String eval, String desc) {
-        this.startYear   = start;
-        this.endYear     = end;
-        this.evaluatedBy = eval;
-        this.description = desc;
-
-        this.km            = new TDoubleArrayList();
-        this.middleHeight  = new TDoubleArrayList();
-        this.uncertainty   = new TDoubleArrayList();
-        this.soundingWidth = new TDoubleArrayList();
-        this.dataGap       = new TDoubleArrayList();
-        this.width         = new TDoubleArrayList();
-        this.empty         = new ArrayList();
-    }
-
-    public void addAll(double station, double height, double uncertainty,
-        double soundingWidth, double dataGap, double width, boolean isEmpty) {
-        addKM(station);
-        addMiddleHeight(height);
-        addUncertainty(uncertainty);
-        addSoundingWidth(soundingWidth);
-        addDataGap(dataGap);
-        addWidth(width);
-        addIsEmpty(isEmpty);
-    }
-
-
-    public int getStartYear() {
-        return startYear;
-    }
-
-    public int getEndYear() {
-        return endYear;
-    }
-
-    public String getEvaluatedBy() {
-        return evaluatedBy;
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-
-    protected void addKM(double km) {
-        this.km.add(km);
-    }
-
-    public double getKM(int idx) {
-        return km.get(idx);
-    }
-
-    protected void addMiddleHeight(double middleHeight) {
-        this.middleHeight.add(middleHeight);
-    }
-
-    public double getMiddleHeight(int idx) {
-        return middleHeight.get(idx);
-    }
-
-    protected void addUncertainty(double uncertainty) {
-        this.uncertainty.add(uncertainty);
-    }
-
-    public double getUncertainty(int idx) {
-        return uncertainty.get(idx);
-    }
-
-    protected void addSoundingWidth(double soundingWidth) {
-        this.soundingWidth.add(soundingWidth);
-    }
-
-    public double getSoundingWidth(int idx) {
-        return soundingWidth.get(idx);
-    }
-
-    protected void addDataGap(double gap) {
-        this.dataGap.add(gap);
-    }
-
-    public double getDataGap(int idx) {
-        return dataGap.get(idx);
-    }
-
-    protected void addIsEmpty(boolean empty) {
-        this.empty.add(empty);
-    }
-
-    public boolean isEmpty(int idx) {
-        return (Boolean) empty.get(idx);
-    }
-
-
-    protected void addWidth(double width) {
-        this.width.add(width);
-    }
-
-    public double getWidth(int idx) {
-        return width.get(idx);
-    }
-
-    public int size() {
-        return km.size();
-    }
-
-
-    /**
-     * Get the points, ready to be drawn
-     * @return [[km1, km2,...],[height1,height2,...]]
-     */
-    public double[][] getMiddleHeightsPoints() {
-        double[][] points = new double[2][size()];
-
-        for (int i = 0, n = size(); i < n; i++) {
-            if (isEmpty(i)) {
-                points[0][i] = getKM(i);
-                points[1][i] = Double.NaN;
-            }
-            else {
-                points[0][i] = getKM(i);
-                points[1][i] = getMiddleHeight(i);
-            }
-        }
-
-        return points;
-    }
-
-
-    public String getSoundingName(CallContext context) {
-        if (getStartYear() == getEndYear()) {
-            return Resources.getMsg(
-                context.getMeta(),
-                I18N_SINGLE_NAME,
-                I18N_SINGLE_NAME,
-                new Object[] { getStartYear() }
-            );
-        }
-        else {
-            return Resources.getMsg(
-                context.getMeta(),
-                I18N_EPOCH_NAME,
-                I18N_EPOCH_NAME,
-                new Object[] { getStartYear(), getEndYear() }
-            );
-        }
-    }
-
-    @Override
-    public int compareTo(MiddleBedHeightData other) {
-
-        int descCompared = description.compareTo(other.getDescription());
-
-        if (descCompared != 0) {
-            return descCompared;
-        }
-
-        if (size() == 0 || other.size() == 0) {
-            if (size() == 0 && other.size() > 0) {
-                return 1;
-            } else if (size() > 0 && other.size() == 0) {
-                return -1;
-            } else if (size() == 0 && other.size() == 0) {
-               return 0;
-            }
-        }
-
-        if (getKM(0) < other.getKM(0)) {
-            return -1;
-        } else if (getKM(0) > other.getKM(0)) {
-            return 1;
-        }
-        return 0;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightFacet.java	Mon Jun 30 11:29:45 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.artifacts.model;
-
-import org.dive4elements.artifactdatabase.state.Facet;
-
-import org.dive4elements.artifacts.Artifact;
-import org.dive4elements.artifacts.CallContext;
-
-import org.dive4elements.river.artifacts.D4EArtifact;
-
-import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
-
-import org.apache.log4j.Logger;
-
-
-/**
- * Facet of a MiddleBedHeight curve.
- */
-public class MiddleBedHeightFacet extends DataFacet {
-
-    private static Logger logger = Logger.getLogger(MiddleBedHeightFacet.class);
-
-
-    public MiddleBedHeightFacet() {
-        // required for clone operation deepCopy()
-    }
-
-
-    public MiddleBedHeightFacet(
-        int         idx,
-        String      name,
-        String      description,
-        ComputeType type,
-        String      stateId,
-        String      hash
-    ) {
-        super(idx, name, description, type, hash, stateId);
-        this.metaData.put("X", "chart.longitudinal.section.xaxis.label");
-        this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label");
-    }
-
-
-    public Object getData(Artifact artifact, CallContext context) {
-        logger.debug("Get data for middle bed height at index: " + index);
-
-        D4EArtifact flys = (D4EArtifact) artifact;
-
-        CalculationResult res = (CalculationResult)
-            flys.compute(context, hash, stateId, type, false);
-
-        MiddleBedHeightData[] data = (MiddleBedHeightData[]) res.getData();
-
-        return data[index];
-    }
-
-
-    /** Copy deeply. */
-    @Override
-    public Facet deepCopy() {
-        MiddleBedHeightFacet copy = new MiddleBedHeightFacet();
-        copy.set(this);
-        copy.type    = type;
-        copy.hash    = hash;
-        copy.stateId = stateId;
-        return copy;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightCalculation.java	Tue Jul 01 13:25:46 2014 +0200
@@ -0,0 +1,154 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.artifacts.model.minfo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.common.utils.DateUtils;
+
+import org.dive4elements.river.model.BedHeightSingle;
+import org.dive4elements.river.model.BedHeightSingleValue;
+import org.dive4elements.river.model.TimeInterval;
+
+import org.dive4elements.river.artifacts.access.BedHeightAccess;
+import org.dive4elements.river.artifacts.model.Calculation;
+import org.dive4elements.river.artifacts.model.CalculationResult;
+import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightData;
+
+
+public class MiddleBedHeightCalculation extends Calculation {
+
+    private static final Logger logger =
+        Logger.getLogger(MiddleBedHeightCalculation.class);
+
+
+    public CalculationResult calculate(BedHeightAccess access) {
+        logger.info("MiddleBedHeightCalculation.calculate");
+
+        int[] singleIds = access.getBedHeightSingleIDs();
+
+
+        if (logger.isDebugEnabled()) {
+            Artifact artifact = access.getArtifact();
+
+            logger.debug("Artifact '" + artifact.identifier() + "' contains:");
+            if (singleIds != null) {
+                logger.debug("   " + singleIds.length + " single bedheight ids");
+            }
+        }
+
+        List<BedHeightSingle> singles = getSingles(access, singleIds);
+
+        return buildCalculationResult(access, singles);
+    }
+
+
+    protected List<BedHeightSingle> getSingles(
+        BedHeightAccess access,
+        int[] ids
+    ) {
+        List<BedHeightSingle> singles = new ArrayList<BedHeightSingle>();
+
+        for (int id: ids) {
+            BedHeightSingle s = BedHeightSingle.getBedHeightSingleById(id);
+
+            if (s != null) {
+                singles.add(s);
+            }
+            else {
+                logger.warn("Cannot find Single by id: " + id);
+                // TODO ADD WARNING
+            }
+        }
+
+        return singles;
+    }
+
+
+    protected CalculationResult buildCalculationResult(
+        BedHeightAccess       access,
+        List<BedHeightSingle> singles
+    ) {
+        logger.info("MiddleBedHeightCalculation.buildCalculationResult");
+
+        double kmLo = access.getLowerKM();
+        double kmHi = access.getUpperKM();
+
+        List<MiddleBedHeightData> data = new ArrayList<MiddleBedHeightData>();
+
+        for (BedHeightSingle single: singles) {
+            MiddleBedHeightData d = prepareSingleData(single, kmLo, kmHi);
+
+            if (d != null) {
+                data.add(d);
+            }
+        }
+
+        logger.debug("Calculation results in " + data.size() + " data objects.");
+
+        return new CalculationResult((MiddleBedHeightData[])
+            data.toArray(new MiddleBedHeightData[data.size()]), this);
+    }
+
+
+    protected MiddleBedHeightData prepareSingleData(
+        BedHeightSingle single,
+        double kmLo,
+        double kmHi
+    ) {
+        logger.debug("Prepare data for single: " + single.getDescription());
+
+        List<BedHeightSingleValue> values =
+            BedHeightSingleValue.getBedHeightSingleValues(single, kmLo, kmHi);
+
+        int year = single.getYear() != null ? single.getYear() : 0;
+
+        MiddleBedHeightData data = new MiddleBedHeightData(
+            year,
+            year,
+            single.getEvaluationBy(),
+            single.getDescription());
+
+        for (BedHeightSingleValue value: values) {
+            if (value.getHeight() != null) {
+                double uncert = value.getUncertainty() != null ?
+                    value.getUncertainty().doubleValue() : Double.NaN;
+                double sounding = value.getSoundingWidth() != null ?
+                    value.getSoundingWidth().doubleValue() : Double.NaN;
+                double gap = value.getDataGap() != null ?
+                    value.getDataGap().doubleValue() : Double.NaN;
+                data.addAll(value.getStation().doubleValue(),
+                    value.getHeight().doubleValue(),
+                    uncert,
+                    sounding,
+                    gap,
+                    value.getWidth().doubleValue(),
+                    false);
+             }
+            else {
+                data.addAll(value.getStation().doubleValue(),
+                    0,
+                    0,
+                    0,
+                    0,
+                    0,
+                    true);
+            }
+        }
+
+        logger.debug("Single contains " + values.size() + " values");
+
+        return data;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightData.java	Tue Jul 01 13:25:46 2014 +0200
@@ -0,0 +1,225 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.artifacts.model.minfo;
+
+import java.io.Serializable;
+
+import java.util.ArrayList;
+
+import gnu.trove.TDoubleArrayList;
+
+import org.dive4elements.artifacts.CallContext;
+
+import org.dive4elements.river.artifacts.resources.Resources;
+
+import org.apache.log4j.Logger;
+
+
+public class MiddleBedHeightData implements Serializable,
+                                            Comparable<MiddleBedHeightData> {
+
+    /** Very private logger. */
+    private static final Logger logger = Logger.getLogger(MiddleBedHeightData.class);
+
+    public static final String I18N_SINGLE_NAME = "facet.bedheight_middle.single";
+    public static final String I18N_EPOCH_NAME  = "facet.bedheight_middle.epoch";
+
+    private int    startYear;
+    private int    endYear;
+    private String evaluatedBy;
+    private String description;
+
+    private TDoubleArrayList km;
+    private TDoubleArrayList middleHeight;
+    private TDoubleArrayList uncertainty;
+    private TDoubleArrayList soundingWidth;
+    private TDoubleArrayList dataGap;
+    private TDoubleArrayList width;
+    private ArrayList empty;
+
+
+    protected MiddleBedHeightData(int start, int end, String eval, String desc) {
+        this.startYear   = start;
+        this.endYear     = end;
+        this.evaluatedBy = eval;
+        this.description = desc;
+
+        this.km            = new TDoubleArrayList();
+        this.middleHeight  = new TDoubleArrayList();
+        this.uncertainty   = new TDoubleArrayList();
+        this.soundingWidth = new TDoubleArrayList();
+        this.dataGap       = new TDoubleArrayList();
+        this.width         = new TDoubleArrayList();
+        this.empty         = new ArrayList();
+    }
+
+    public void addAll(double station, double height, double uncertainty,
+        double soundingWidth, double dataGap, double width, boolean isEmpty) {
+        addKM(station);
+        addMiddleHeight(height);
+        addUncertainty(uncertainty);
+        addSoundingWidth(soundingWidth);
+        addDataGap(dataGap);
+        addWidth(width);
+        addIsEmpty(isEmpty);
+    }
+
+
+    public int getStartYear() {
+        return startYear;
+    }
+
+    public int getEndYear() {
+        return endYear;
+    }
+
+    public String getEvaluatedBy() {
+        return evaluatedBy;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+
+    protected void addKM(double km) {
+        this.km.add(km);
+    }
+
+    public double getKM(int idx) {
+        return km.get(idx);
+    }
+
+    public TDoubleArrayList getStations() {
+        return this.km;
+    }
+
+    protected void addMiddleHeight(double middleHeight) {
+        this.middleHeight.add(middleHeight);
+    }
+
+    public double getMiddleHeight(int idx) {
+        return middleHeight.get(idx);
+    }
+
+    protected void addUncertainty(double uncertainty) {
+        this.uncertainty.add(uncertainty);
+    }
+
+    public double getUncertainty(int idx) {
+        return uncertainty.get(idx);
+    }
+
+    protected void addSoundingWidth(double soundingWidth) {
+        this.soundingWidth.add(soundingWidth);
+    }
+
+    public double getSoundingWidth(int idx) {
+        return soundingWidth.get(idx);
+    }
+
+    protected void addDataGap(double gap) {
+        this.dataGap.add(gap);
+    }
+
+    public double getDataGap(int idx) {
+        return dataGap.get(idx);
+    }
+
+    protected void addIsEmpty(boolean empty) {
+        this.empty.add(empty);
+    }
+
+    public boolean isEmpty(int idx) {
+        return (Boolean) empty.get(idx);
+    }
+
+
+    protected void addWidth(double width) {
+        this.width.add(width);
+    }
+
+    public double getWidth(int idx) {
+        return width.get(idx);
+    }
+
+    public int size() {
+        return km.size();
+    }
+
+
+    /**
+     * Get the points, ready to be drawn
+     * @return [[km1, km2,...],[height1,height2,...]]
+     */
+    public double[][] getMiddleHeightsPoints() {
+        double[][] points = new double[2][size()];
+
+        for (int i = 0, n = size(); i < n; i++) {
+            if (isEmpty(i)) {
+                points[0][i] = getKM(i);
+                points[1][i] = Double.NaN;
+            }
+            else {
+                points[0][i] = getKM(i);
+                points[1][i] = getMiddleHeight(i);
+            }
+        }
+
+        return points;
+    }
+
+
+    public String getSoundingName(CallContext context) {
+        if (getStartYear() == getEndYear()) {
+            return Resources.getMsg(
+                context.getMeta(),
+                I18N_SINGLE_NAME,
+                I18N_SINGLE_NAME,
+                new Object[] { getStartYear() }
+            );
+        }
+        else {
+            return Resources.getMsg(
+                context.getMeta(),
+                I18N_EPOCH_NAME,
+                I18N_EPOCH_NAME,
+                new Object[] { getStartYear(), getEndYear() }
+            );
+        }
+    }
+
+    @Override
+    public int compareTo(MiddleBedHeightData other) {
+
+        int descCompared = description.compareTo(other.getDescription());
+
+        if (descCompared != 0) {
+            return descCompared;
+        }
+
+        if (size() == 0 || other.size() == 0) {
+            if (size() == 0 && other.size() > 0) {
+                return 1;
+            } else if (size() > 0 && other.size() == 0) {
+                return -1;
+            } else if (size() == 0 && other.size() == 0) {
+               return 0;
+            }
+        }
+
+        if (getKM(0) < other.getKM(0)) {
+            return -1;
+        } else if (getKM(0) > other.getKM(0)) {
+            return 1;
+        }
+        return 0;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/MiddleBedHeightFacet.java	Tue Jul 01 13:25:46 2014 +0200
@@ -0,0 +1,79 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.artifacts.model.minfo;
+
+import org.dive4elements.artifactdatabase.state.Facet;
+
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallContext;
+
+import org.dive4elements.river.artifacts.D4EArtifact;
+
+import org.dive4elements.river.artifacts.model.CalculationResult;
+import org.dive4elements.river.artifacts.model.DataFacet;
+import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ * Facet of a MiddleBedHeight curve.
+ */
+public class MiddleBedHeightFacet extends DataFacet {
+
+    private static Logger logger = Logger.getLogger(MiddleBedHeightFacet.class);
+
+
+    public MiddleBedHeightFacet() {
+        // required for clone operation deepCopy()
+    }
+
+
+    public MiddleBedHeightFacet(
+        int         idx,
+        String      name,
+        String      description,
+        ComputeType type,
+        String      stateId,
+        String      hash
+    ) {
+        super(idx, name, description, type, hash, stateId);
+        this.metaData.put("X", "chart.longitudinal.section.xaxis.label");
+        this.metaData.put("Y", "chart.bedheight_middle.section.yaxis.label");
+    }
+
+
+    public Object getData(Artifact artifact, CallContext context) {
+        logger.debug("Get data for middle bed height at index: " + index);
+
+        D4EArtifact flys = (D4EArtifact) artifact;
+
+        CalculationResult res = (CalculationResult)
+            flys.compute(context, hash, stateId, type, false);
+
+        MiddleBedHeightData[] resultData =
+            (MiddleBedHeightData[]) res.getData();
+        MiddleBedHeightData data = resultData[index];
+
+        return data.getMiddleHeightsPoints();
+    }
+
+
+    /** Copy deeply. */
+    @Override
+    public Facet deepCopy() {
+        MiddleBedHeightFacet copy = new MiddleBedHeightFacet();
+        copy.set(this);
+        copy.type    = type;
+        copy.hash    = hash;
+        copy.stateId = stateId;
+        return copy;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/MiddleBedHeight.java	Mon Jun 30 11:29:45 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/MiddleBedHeight.java	Tue Jul 01 13:25:46 2014 +0200
@@ -22,9 +22,9 @@
 import org.dive4elements.river.artifacts.model.CalculationResult;
 import org.dive4elements.river.artifacts.model.DataFacet;
 import org.dive4elements.river.artifacts.model.FacetTypes;
-import org.dive4elements.river.artifacts.model.MiddleBedHeightData;
-import org.dive4elements.river.artifacts.model.MiddleBedHeightFacet;
-import org.dive4elements.river.artifacts.model.MiddleBedHeightCalculation;
+import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightCalculation;
+import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightData;
+import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightFacet;
 
 
 /** State in which Middle Bed Heights are generated. */
--- a/artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java	Mon Jun 30 11:29:45 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/MiddleBedHeightExporter.java	Tue Jul 01 13:25:46 2014 +0200
@@ -22,7 +22,7 @@
 
 import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.model.CalculationResult;
-import org.dive4elements.river.artifacts.model.MiddleBedHeightData;
+import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightData;
 
 import org.dive4elements.river.model.River;
 
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/MiddleBedHeightProcessor.java	Mon Jun 30 11:29:45 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/MiddleBedHeightProcessor.java	Tue Jul 01 13:25:46 2014 +0200
@@ -17,9 +17,9 @@
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifacts.CallContext;
 
-import org.dive4elements.river.artifacts.model.MiddleBedHeightData;
 import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.artifacts.model.minfo.MiddleBedHeightData;
 import org.dive4elements.river.themes.ThemeDocument;
 import org.dive4elements.river.exports.DiagramGenerator;
 import org.dive4elements.river.exports.StyledSeriesBuilder;
@@ -47,17 +47,21 @@
             ThemeDocument    theme,
             boolean          visible) {
         CallContext context = generator.getCallContext();
-        logger.debug("Processing: " + bundle.getFacetName());
         Map<String, String> metaData = bundle.getFacet().getMetaData();
         yAxisLabel = metaData.get("Y");
-        MiddleBedHeightData data =
-            (MiddleBedHeightData) bundle.getData(context);
 
+        Object raw = bundle.getData(context);
+        if (!(raw instanceof double[][])) {
+            logger.error("Unkonwn data type: " + raw.getClass().getName());
+            return;
+        }
+
+        double[][] data = (double[][])raw;
         StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
                 theme);
         series.putMetaData(metaData, bundle.getArtifact(), context);
 
-        StyledSeriesBuilder.addPoints(series, data.getMiddleHeightsPoints(),
+        StyledSeriesBuilder.addPoints(series, data,
                 false, 0.110d);
 
         generator.addAxisSeries(series, axisName, visible);

http://dive4elements.wald.intevation.org