[PATCH 1 of 2] Anti programming

Wald Commits scm-commit at wald.intevation.org
Thu Sep 4 15:49:15 CEST 2014


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1409838193 -7200
# Node ID fcc1ffbc2ea6495ce7c238999b6f9d4136fe6ed9
# Parent  3bb1c62ad73238dc162f70f472121d0c3530cad8
Anti programming.

diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/WMSLineArtifact.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/WMSLineArtifact.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +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;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import com.vividsolutions.jts.geom.Envelope;
-
-import org.dive4elements.artifactdatabase.state.DefaultOutput;
-import org.dive4elements.artifactdatabase.state.Facet;
-import org.dive4elements.artifactdatabase.state.State;
-
-import org.dive4elements.river.model.River;
-import org.dive4elements.river.model.HWSLine;
-
-import org.dive4elements.river.artifacts.model.FacetTypes;
-import org.dive4elements.river.artifacts.model.RiverFactory;
-import org.dive4elements.river.utils.RiverUtils;
-import org.dive4elements.river.utils.GeometryUtils;
-
-
-public class WMSLineArtifact extends WMSDBArtifact {
-
-    public static final String NAME = "lines";
-
-
-    private static final Logger logger =
-        Logger.getLogger(WMSLineArtifact.class);
-
-
-    @Override
-    public String getName() {
-        return NAME;
-    }
-
-
-    @Override
-    public State getCurrentState(Object cc) {
-        State s = new LineState(this);
-
-        List<Facet> fs = getFacets(getCurrentStateId());
-
-        DefaultOutput o = new DefaultOutput(
-            "floodmap",
-            "floodmap",
-            "image/png",
-            fs,
-            "map");
-
-        s.getOutputs().add(o);
-
-        return s;
-    }
-
-
-    public static class LineState extends WMSDBState implements FacetTypes
-    {
-        private static final Logger logger =
-            Logger.getLogger(LineState.class);
-
-        protected int riverId;
-
-        public LineState(WMSDBArtifact artifact) {
-            super(artifact);
-            riverId = 0;
-        }
-
-        public int getRiverId() {
-            if (riverId == 0) {
-                String   ids   = artifact.getDataAsString("ids");
-                String[] parts = ids.split(";");
-
-                try {
-                    riverId = Integer.parseInt(parts[0]);
-                }
-                catch (NumberFormatException nfe) {
-                    logger.error("Cannot parse river id from '" + parts[0] + "'");
-                }
-            }
-
-            return riverId;
-        }
-
-        @Override
-        protected String getFacetType() {
-            return FLOODMAP_LINES;
-        }
-
-        @Override
-        protected String getUrl() {
-            return RiverUtils.getUserWMSUrl(artifact.identifier());
-        }
-
-        @Override
-        protected String getSrid() {
-            River river = RiverFactory.getRiver(getRiverId());
-            return RiverUtils.getRiverSrid(river.getName());
-        }
-
-        @Override
-        protected Envelope getExtent(boolean reproject) {
-            List<HWSLine> lines = HWSLine.getLines(getRiverId(), getName());
-
-            Envelope max = null;
-
-            for (HWSLine l: lines) {
-                Envelope env = l.getGeom().getEnvelopeInternal();
-
-                if (max == null) {
-                    max = env;
-                    continue;
-                }
-
-                max.expandToInclude(env);
-            }
-
-            return max != null && reproject
-                ? GeometryUtils.transform(max, getSrid())
-                : max;
-        }
-
-        @Override
-        protected String getFilter() {
-            return "river_id=" + String.valueOf(getRiverId()) +
-                " AND name='" + getName() + "'";
-        }
-
-        @Override
-        protected String getDataString() {
-            String srid = getSrid();
-
-            if (RiverUtils.isUsingOracle()) {
-                return "geom FROM lines USING SRID " + srid;
-            }
-            else {
-                return "geom FROM lines USING UNIQUE id USING SRID " + srid;
-            }
-        }
-
-        @Override
-        protected String getGeometryType() {
-            return "LINE";
-        }
-    } // end of WMSKmState
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/access/GaugeAccess.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/GaugeAccess.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +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.access;
-
-import org.apache.log4j.Logger;
-
-import org.dive4elements.river.artifacts.D4EArtifact;
-import org.dive4elements.river.utils.RiverUtils;
-
-/** For the moment, light-weight wrapper around RiverUtils. */
-// TODO employ 'Caching' like other Accesses, remove usage of RiverUtils.
-public class GaugeAccess
-extends RangeAccess
-{
-    private static Logger logger = Logger.getLogger(GaugeAccess.class);
-
-    public GaugeAccess(D4EArtifact artifact) {
-        super(artifact);
-    }
-
-
-    public String getGaugeName() {
-        return RiverUtils.getGaugename(this.getArtifact());
-    }
-
-    // TODO there is also getGauges in RiverUtils...
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/charts/TimeseriesStepChart.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/charts/TimeseriesStepChart.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,227 +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.charts;
-
-import java.awt.Dimension;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.ChartPanel;
-import org.jfree.chart.JFreeChart;
-import org.jfree.ui.ApplicationFrame;
-
-import org.jfree.data.time.SimpleTimePeriod;
-import org.jfree.data.time.Second;
-import org.jfree.data.time.TimeSeries;
-import org.jfree.data.time.TimeSeriesCollection;
-import org.jfree.data.time.TimePeriodValues;
-import org.jfree.data.time.TimePeriodValuesCollection;
-
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
-
-
-public class TimeseriesStepChart extends ApplicationFrame {
-
-    private static final Logger logger =
-        Logger.getLogger(TimeseriesStepChart.class);
-
-
-    public static final String LOG4J_PROPERTIES = "FLYS_CLIENT_LOG4J_PROPERIES";
-
-    public static final int USER_CHART_TYPE =
-        Integer.getInteger("chart.type", -1);
-
-    public static final int CHART_TYPE_TIMEPERIOD = 1;
-    public static final int CHART_TYPE_TIMESERIES = 2;
-
-
-    public static void main(String[] args) {
-        configureLogging();
-
-        logger.info("Start TimeseriesStepChart demo.");
-
-        if (USER_CHART_TYPE <= 0) {
-            logger.error("Unknown chart type: " + USER_CHART_TYPE);
-        }
-
-        logger.debug("Create Chart from type: " + USER_CHART_TYPE);
-
-        TimeseriesStepChart tsc = new TimeseriesStepChart();
-        tsc.build(USER_CHART_TYPE);
-
-        logger.info("End of TimeseriesStepChart demo.");
-    }
-
-
-    /** Setup the log4j logging (read LOG4J_PROPERIES envvar). */
-    public static void configureLogging() {
-        String log4jProperties = System.getenv(LOG4J_PROPERTIES);
-
-        if (log4jProperties != null && log4jProperties.length() > 0) {
-            PropertyConfigurator.configure(log4jProperties);
-            logger.info("Log4J logging initialized.");
-        }
-        else {
-            System.out.println("Error while setting up Log4J configuration.");
-        }
-
-        System.out.println("LoggingConfigurator.init finished");
-    }
-
-
-    public TimeseriesStepChart() {
-        super("TimeseriesStepChart");
-    }
-
-
-    public void build(int type) {
-        ChartPanel chartPanel = createChartPanel(type);
-        chartPanel.setPreferredSize(new Dimension(500, 300));
-
-        setContentPane(chartPanel);
-
-        pack();
-        setVisible(true);
-    }
-
-
-    protected ChartPanel createChartPanel(int type) {
-        JFreeChart chart = createJFreeChart(type);
-        ChartPanel panel = new ChartPanel(chart);
-        return panel;
-    }
-
-
-    protected JFreeChart createJFreeChart(int type) {
-        if (type == CHART_TYPE_TIMEPERIOD) {
-            return createTimePeriodValuesChart();
-        }
-        else if (type == CHART_TYPE_TIMESERIES) {
-            return createTimeSeriesChart();
-        }
-
-        logger.error("Unknown chart type: " + type);
-
-        return null;
-    }
-
-
-    public static Date createDate(int year, int month, int day) {
-        GregorianCalendar cal = new GregorianCalendar(year, month, day);
-        return cal.getTime();
-    }
-
-
-
-    //
-    // XXX FOLLOWING METHODS ARE USED FOR "TimePeriodValues" CHART TYPE
-    //
-    protected JFreeChart createTimePeriodValuesChart() {
-        return ChartFactory.createTimeSeriesChart(
-            "TimePeriodValues Chart",
-            "Time Axis",
-            "Y Axis",
-            createTimePeriodValuesDataset(),
-            true,
-            false,
-            false);
-    }
-
-
-    protected TimePeriodValuesCollection createTimePeriodValuesDataset() {
-        TimePeriodValuesCollection dataset = new TimePeriodValuesCollection();
-        TimePeriodValues series = createTimePeriodValues();
-
-        dataset.addSeries(series);
-
-        return dataset;
-    }
-
-
-    protected TimePeriodValues createTimePeriodValues() {
-        TimePeriodValues series1 = new TimePeriodValues("Series 1");
-
-        Date start1 = createDate(2000, 0, 1);
-        Date end1   = createDate(2000, 11, 31);
-
-        logger.debug("START DATE 1 = " + start1);
-        logger.debug("END   DATE 1 = " + end1);
-
-        SimpleTimePeriod period1 = new SimpleTimePeriod(start1, end1);
-
-        Date start2 = createDate(2001, 0, 1);
-        Date end2   = createDate(2001, 11, 31);
-        SimpleTimePeriod period2 = new SimpleTimePeriod(start2, end2);
-
-        Date start3 = createDate(2002, 0, 1);
-        Date end3   = createDate(2002, 11, 31);
-        SimpleTimePeriod period3 = new SimpleTimePeriod(start3, end3);
-
-        series1.add(period1, 100);
-        series1.add(period2, 200);
-        series1.add(period3, 150);
-
-        return series1;
-    }
-
-
-    //
-    // XXX FOLLOWING METHODS ARE USED FOR "TimePeriodValues" CHART TYPE
-    //
-    protected JFreeChart createTimeSeriesChart() {
-        return ChartFactory.createTimeSeriesChart(
-            "TimeSeriesCollection Chart",
-            "Time Axis",
-            "Y Axis",
-            createTimeSeriesCollectionDataset(),
-            true,
-            false,
-            false);
-    }
-
-
-    protected TimeSeriesCollection createTimeSeriesCollectionDataset() {
-        TimeSeriesCollection dataset = new TimeSeriesCollection();
-        TimeSeries[]         series  = createTimeSeries();
-
-        for (TimeSeries tmp: series) {
-            dataset.addSeries(tmp);
-        }
-
-        return dataset;
-    }
-
-
-    protected TimeSeries[] createTimeSeries() {
-        TimeSeries series1 = new TimeSeries("Series 1");
-        series1.add(new Second(0, 0, 0, 1, 1, 2000), 100);
-        series1.add(new Second(59, 59, 23, 31, 12, 2000), 100);
-
-        series1.add(new Second(0, 0, 0, 1, 1, 2001), 200);
-        series1.add(new Second(59, 59, 23, 31, 12, 2001), 200);
-
-        series1.add(new Second(0, 0, 0, 1, 1, 2002), 150);
-        series1.add(new Second(59, 59, 23, 31, 12, 2002), 150);
-
-        TimeSeries series2 = new TimeSeries("Series 2");
-        series2.add(new Second(0, 0, 0, 1, 1, 2000), 10);
-        series2.add(new Second(59, 59, 23, 31, 12, 2000), 10);
-
-        series2.add(new Second(0, 0, 0, 1, 1, 2001), 20);
-        series2.add(new Second(59, 59, 23, 31, 12, 2001), 20);
-
-        series2.add(new Second(0, 0, 0, 1, 1, 2002), 15);
-        series2.add(new Second(59, 59, 23, 31, 12, 2002), 15);
-
-        return new TimeSeries[] { series1, series2 };
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/map/PrintMap.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/map/PrintMap.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +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.map;
-
-import java.awt.Color;
-import java.awt.Rectangle;
-
-import java.io.File;
-import java.io.IOException;
-
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-
-import java.util.List;
-
-import java.net.URL;
-import java.net.MalformedURLException;
-
-import javax.imageio.ImageIO;
-
-
-import org.geotools.data.ows.Layer;
-import org.geotools.data.ows.WMSCapabilities;
-import org.geotools.data.wms.WebMapServer;
-import org.geotools.geometry.jts.ReferencedEnvelope;
-import org.geotools.map.MapContext;
-import org.geotools.map.WMSMapLayer;
-import org.geotools.ows.ServiceException;
-import org.geotools.renderer.lite.StreamingRenderer;
-import org.geotools.renderer.GTRenderer;
-
-
-public class PrintMap {
-
-    public static final String DEFAULT_WMS = "http://map1.naturschutz.rlp.de/service_lanis/mod_wms/wms_getmap.php?mapfile=group_gdide&REQUEST=GetCapabilities&SERVICE=WMS";
-    public static final String DEFAULT_OUTFILE = "~/map.jpeg";
-
-    public static final String MAPSERVER = System.getProperty("wms", DEFAULT_WMS);
-    public static final String MAP_IMAGE = System.getProperty("outfile", DEFAULT_OUTFILE);
-
-
-    public static void main(String[] args) {
-        System.out.println("-> start PrintMap");
-        System.out.println("  -> Print layers of WMS: " + MAPSERVER);
-
-        try {
-            WebMapServer    server = getMapserver();
-            WMSMapLayer[] wmsLayer = getWMSLayers(server);
-
-            MapContext mapcontent = new MapContext( wmsLayer );
-            mapcontent.setTitle(" NEW MAP CONTENT TITLE ");
-
-            printMap(mapcontent);
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-        }
-
-        System.out.println("-> finished PrintMap");
-    }
-
-
-    public static void printMap(MapContext map) throws Exception {
-        int imageWidth = 600;
-
-        GTRenderer renderer = new StreamingRenderer();
-        renderer.setContext(map);
-
-        Rectangle imageBounds = null;
-        ReferencedEnvelope mapBounds = null;
-
-        try {
-            mapBounds = map.getLayerBounds();
-            double heightToWidth = mapBounds.getSpan(1) / mapBounds.getSpan(0);
-            imageBounds = new Rectangle(
-                0, 0,
-                imageWidth,
-                (int) Math.round(imageWidth * heightToWidth));
-
-        }
-        catch (Exception e) {
-            // failed to access map layers
-            throw new RuntimeException(e);
-        }
-
-        BufferedImage image = new BufferedImage(imageBounds.width, imageBounds.height, BufferedImage.TYPE_INT_RGB);
-        Graphics2D gr = image.createGraphics();
-        gr.setPaint(Color.WHITE);
-        gr.fill(imageBounds);
-
-        try {
-            renderer.paint(gr, imageBounds, mapBounds);
-            File fileToSave = new File(MAP_IMAGE);
-            ImageIO.write(image, "jpeg", fileToSave);
-        }
-        catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-
-    public static WebMapServer getMapserver() throws MalformedURLException, IOException, ServiceException {
-        return new WebMapServer(getServerUrl());
-    }
-
-
-    public static URL getServerUrl() throws MalformedURLException {
-        return new URL(MAPSERVER);
-    }
-
-
-    public static WMSMapLayer[] getWMSLayers(WebMapServer server) {
-        if (server == null) {
-            System.out.println("WebMapServer == null");
-            throw new RuntimeException("WebMapServer == null");
-        }
-
-        WMSCapabilities capabilities = server.getCapabilities();
-
-        List<Layer> layers = capabilities.getLayerList();
-        WMSMapLayer[] wmslayers = new WMSMapLayer[layers.size()];
-
-        for (int i = 0, L = layers.size(); i < L; i++) {
-            Layer l = layers.get(i);
-
-            System.out.println("   -> add layer: " + l);
-            wmslayers[i] = new WMSMapLayer(server, l);
-        }
-
-        return wmslayers;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/math/FilterFunction.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/math/FilterFunction.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +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.math;
-
-public class FilterFunction implements Function {
-
-    protected Function parent;
-
-    public FilterFunction(Function parent) {
-        this.parent = parent;
-    }
-
-    @Override
-    public double value(double x) {
-        return parent.value(x);
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/math/LinearFilterFunction.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/math/LinearFilterFunction.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +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.math;
-
-public class LinearFilterFunction
-extends      FilterFunction
-{
-    protected double m;
-    protected double b;
-
-    public LinearFilterFunction(double m, double b) {
-        this(Identity.IDENTITY, m, b);
-    }
-
-    public LinearFilterFunction(Function parent, double m, double b) {
-        super(parent);
-        this.m = m;
-        this.b = b;
-    }
-
-    @Override
-    public double value(double x) {
-        return super.value(x)*m + b;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/math/LinearFunction.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/math/LinearFunction.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +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.math;
-
-public class LinearFunction
-implements   Function
-{
-    protected double m;
-    protected double b;
-
-    public LinearFunction(double m, double b) {
-        this.m = m;
-        this.b = b;
-    }
-
-    @Override
-    public double value(double x) {
-        return x*m + b;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/model/LinearInterpolated.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/LinearInterpolated.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +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 gnu.trove.TDoubleArrayList;
-
-import java.io.Serializable;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.apache.commons.math.stat.descriptive.moment.StandardDeviation;
-
-import org.dive4elements.river.artifacts.math.Linear;
-
-import org.dive4elements.river.backend.utils.EpsilonComparator;
-
-public class LinearInterpolated
-implements   Serializable
-{
-    public static final double EPSILON = 1e-5;
-    public static final double MULTIPLE_STD_DEV = 4d;
-
-    public static final EpsilonComparator CMP = new EpsilonComparator(EPSILON);
-
-    private TDoubleArrayList xs;
-    private TDoubleArrayList ys;
-
-    private List<Range> gaps;
-
-    public interface Operator {
-        double evaluate(double y1, double y2);
-    } // interface Operator
-
-    public static final Operator SUB = new Operator() {
-        @Override
-        public double evaluate(double y1, double y2) {
-            return y1 - y2;
-        }
-    };
-
-    public static final Operator MAX = new Operator() {
-        @Override
-        public double evaluate(double y1, double y2) {
-            return Math.max(y1, y2);
-        }
-    };
-
-    public LinearInterpolated() {
-        xs = new TDoubleArrayList();
-        ys = new TDoubleArrayList();
-    }
-
-    public LinearInterpolated(int capacity) {
-        xs = new TDoubleArrayList(capacity);
-        ys = new TDoubleArrayList(capacity);
-    }
-
-    public void add(double x, double y) {
-        xs.add(x);
-        ys.add(y);
-    }
-
-    public int size() {
-        return xs.size();
-    }
-
-    public void pointsInRange(double from, double to, Set<Double> points) {
-        if (from > to) {
-            double t = from;
-            from = to;
-            to = t;
-        }
-        for (int i = 0, S = size(); i < S; ++i) {
-            double x = xs.getQuick(i);
-            if (x >= from && x <= to) {
-                points.add(x);
-            }
-        }
-    }
-
-    public boolean inGap(double x) {
-        if (gaps != null) {
-            for (Range gap: gaps) {
-                if (gap.inside(x)) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    public void detectGaps(double threshold) {
-        List<Range> gabs = new ArrayList<Range>();
-        for (int i = 1, S = size(); i < S; ++i) {
-            double x0 = xs.getQuick(i-1);
-            double x1 = xs.getQuick(i);
-            double minX, maxX;
-            if (x0 < x1) { minX = x0; maxX = x1; }
-            else         { minX = x1; maxX = x0; }
-            double diff = maxX - minX - 2d*EPSILON;
-            if (diff > threshold) {
-                gaps.add(new Range(minX+EPSILON, maxX-EPSILON));
-            }
-        }
-        this.gaps = gaps.isEmpty() ? null : gabs;
-    }
-
-    public void resetGaps() {
-        gaps = null;
-    }
-
-    public double guessGapThreshold() {
-        return guessGapThreshold(MULTIPLE_STD_DEV);
-    }
-
-    public double guessGapThreshold(double scale) {
-        int S = size();
-        if (S < 5) { // Too less points.
-            return Double.MAX_VALUE;
-        }
-
-        StandardDeviation s = new StandardDeviation();
-
-        for (int i = 1; i < S; ++i) {
-            double diff = Math.abs(xs.getQuick(i-1) - xs.getQuick(i));
-            s.increment(diff);
-        }
-
-        return scale*s.getResult();
-    }
-
-    public double value(double x) {
-        for (int i = 0, S = size(); i < S; ++i) {
-            double x1 = xs.getQuick(i);
-            if (Math.abs(x1 - x) < EPSILON) {
-                return ys.getQuick(i);
-            }
-            if (i > 0) {
-                double x0 = xs.getQuick(i-1);
-                double minX, maxX;
-                if (x0 < x1) { minX = x0; maxX = x1; }
-                else         { minX = x1; maxX = x0; }
-                if (x > minX && x < maxX) {
-                    return Linear.linear(
-                        x,
-                        x0, x1,
-                        ys.getQuick(i-1), ys.getQuick(i));
-                }
-            }
-        }
-        return Double.NaN;
-    }
-
-    public LinearInterpolated sub(
-        LinearInterpolated other,
-        double             from,
-        double             to
-    ) {
-        return apply(SUB, other, from, to);
-    }
-
-    public LinearInterpolated max(
-        LinearInterpolated other,
-        double             from,
-        double             to
-    ) {
-        return apply(MAX, other, from, to);
-    }
-
-    public boolean intersect(LinearInterpolated other) {
-        if (xs.isEmpty() || other.xs.isEmpty()) {
-            return false;
-        }
-
-        double tMax = xs.max();
-        double oMin = other.xs.min();
-        if (tMax < oMin) {
-            return false;
-        }
-
-        double tMin = xs.min();
-        double oMax = other.xs.max();
-        return !(tMin > oMax);
-    }
-
-    public LinearInterpolated apply(
-        Operator           operator,
-        LinearInterpolated other,
-        double             from,
-        double             to
-    ) {
-        LinearInterpolated result = new LinearInterpolated();
-        if (!intersect(other)) {
-            return result;
-        }
-
-        Set<Double> points = new TreeSet<Double>(CMP);
-        points.add(from);
-        points.add(to);
-
-        this .pointsInRange(from, to, points);
-        other.pointsInRange(from, to, points);
-
-
-        for (double x: points) {
-            if (!inGap(x) && !other.inGap(x)) {
-                double y1 = this .value(x);
-                double y2 = other.value(x);
-                double y  = operator.evaluate(y1, y2);
-                if (!Double.isNaN(y)) {
-                    result.add(x, y);
-                }
-            }
-        }
-
-        return result;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/model/QKmsImpl.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/QKmsImpl.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +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 gnu.trove.TDoubleArrayList;
-
-import org.dive4elements.river.utils.DoubleUtil;
-
-public class QKmsImpl
-extends      NamedObjectImpl
-implements   QKms
-{
-    protected TDoubleArrayList kms;
-    protected TDoubleArrayList qs;
-
-    public QKmsImpl() {
-        super("");
-        kms = new TDoubleArrayList();
-        qs  = new TDoubleArrayList();
-    }
-
-    public QKmsImpl(String name) {
-        super(name);
-        kms = new TDoubleArrayList();
-        qs  = new TDoubleArrayList();
-    }
-
-
-    public QKmsImpl(int capacity) {
-        super("");
-        kms = new TDoubleArrayList(capacity);
-        qs  = new TDoubleArrayList(capacity);
-    }
-
-
-    public QKmsImpl(TDoubleArrayList kms, TDoubleArrayList qs) {
-        this(kms, qs, "");
-    }
-
-    public QKmsImpl(
-        TDoubleArrayList kms,
-        TDoubleArrayList qs,
-        String           name
-    ) {
-        super(name);
-        this.kms = kms;
-        this.qs  = qs;
-    }
-
-    public void add(double km, double q) {
-        kms.add(km);
-        qs .add(q);
-    }
-
-    @Override
-    public double getQ(int index) {
-        return qs.getQuick(index);
-    }
-
-
-    @Override
-    public double getKm(int index) {
-        return kms.getQuick(index);
-    }
-
-    @Override
-    public int size() {
-        return kms.size();
-    }
-
-    @Override
-    public TDoubleArrayList allKms() {
-        return kms;
-    }
-
-    @Override
-    public TDoubleArrayList allQs() {
-        return qs;
-    }
-
-    public void removeNaNs() {
-        DoubleUtil.removeNaNs(new TDoubleArrayList [] { kms, qs });
-    }
-}
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/model/StaticSedimentLoadCacheKey.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/StaticSedimentLoadCacheKey.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +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.apache.commons.lang.builder.HashCodeBuilder;
-
-
-public class StaticSedimentLoadCacheKey
-{
-    public static final String CACHE_NAME = "sedimentload-value-table-static";
-
-    private String river;
-    private double startKm;
-    private double endKm;
-    private int sYear;
-    private int eYear;
-
-    public StaticSedimentLoadCacheKey(
-        String river,
-        double startKm,
-        double endKm,
-        int sYear,
-        int eYear
-    ) {
-        this.river = river;
-        this.startKm = startKm;
-        this.endKm = endKm;
-        this.sYear = sYear;
-        this.eYear = eYear;
-    }
-
-    @Override
-    public int hashCode() {
-        HashCodeBuilder builder = new HashCodeBuilder();
-        builder.append(river);
-        builder.append(startKm);
-        builder.append(endKm);
-        builder.append(sYear);
-        builder.append(eYear);
-        return builder.toHashCode();
-    }
-
-    @Override
-    public boolean equals(Object other) {
-        if (!(other instanceof StaticSedimentLoadCacheKey)) {
-            return false;
-        }
-        StaticSedimentLoadCacheKey o = (StaticSedimentLoadCacheKey) other;
-        return this.river == o.river &&
-            this.startKm == o.startKm &&
-            this.endKm == o.endKm &&
-            this.sYear == o.sYear &&
-            this.eYear == o.eYear;
-    }
-}
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,940 +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.minfo;
-
-import gnu.trove.TDoubleArrayList;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.TreeMap;
-
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.Element;
-
-import org.apache.log4j.Logger;
-import org.dive4elements.river.artifacts.cache.CacheFactory;
-import org.dive4elements.river.artifacts.model.Range;
-import org.dive4elements.river.artifacts.model.RiverFactory;
-import org.dive4elements.river.artifacts.model.StaticSedimentLoadCacheKey;
-import org.dive4elements.river.backend.SessionHolder;
-import org.dive4elements.river.model.MeasurementStation;
-import org.hibernate.SQLQuery;
-import org.hibernate.Session;
-import org.hibernate.type.StandardBasicTypes;
-
-
-/** Pull Sediment Loads out of db. */
-public class SedimentLoadFactory
-{
-    /** Private logger to use here. */
-    private static Logger log = Logger.getLogger(SedimentLoadFactory.class);
-
-    // Cache name/keys
-    public static final String LOADS_CACHE_NAME = "sedimentloads";
-    public static final String LOAD_DATA_CACHE_NAME = "sedimentload-data";
-
-    /** Query to get description and start year of single type
-     * sediment_load_lss. */
-    public static final String SQL_SELECT_SINGLES =
-        "SELECT DISTINCT " +
-        "       sy.description AS description, " +
-        "       ti.start_time AS year " +
-        "   FROM     sediment_load_ls sy " +
-        "       JOIN rivers r ON sy.river_id = r.id " +
-        "       JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " +
-        "       JOIN time_intervals ti ON sy.time_interval_id = ti.id " +
-        "   WHERE   r.name = :name " +
-        "       AND ti.stop_time IS NULL " +
-        "       AND syv.station BETWEEN :startKm AND :endKm";
-
-    /** Query to get fraction name of single sediment_load_ls. */
-    public static final String SQL_SELECT_SINGLE_TIMES_BY_ID =
-        "SELECT DISTINCT " +
-        "       ti.start_time AS starttime, " +
-        "       ti.stop_time  AS stoptime " +
-        "   FROM    sediment_load_ls sy " +
-        "   JOIN    time_intervals ti ON ti.id = sy.time_interval_id " +
-        "   WHERE   sy.id = :id ";
-
-    /** Query to get fraction name of single sediment_load_ls. */
-    public static final String SQL_SELECT_SINGLE_FRACTION_BY_ID =
-        "SELECT DISTINCT " +
-        "       gf.name AS fraction " +
-        "   FROM    sediment_load_ls sy " +
-        "   JOIN    grain_fraction gf ON gf.id = grain_fraction_id " +
-        "   WHERE   sy.id = :id ";
-
-    /** Query to get unit name of single sediment_load_ls. */
-    public static final String SQL_SELECT_SINGLE_UNIT_BY_ID =
-        "SELECT DISTINCT " +
-        "       u.name AS unit " +
-        "   FROM    sediment_load_ls sy " +
-        "   JOIN    units u ON u.id = unit_id " +
-        "   WHERE   sy.id = :id ";
-
-    /** Query to get description of single sediment_load_ls. */
-    public static final String SQL_SELECT_SINGLE_BY_ID =
-        "SELECT DISTINCT " +
-        "       sy.description AS description " +
-        "   FROM    sediment_load_ls sy " +
-        "   WHERE   sy.id = :id ";
-
-    /** Query to get description, name and time range for official
-     * epoch-type sediment yields. */
-    public static final String SQL_SELECT_OFFEPOCHS =
-        "SELECT DISTINCT " +
-        "       ti.start_time AS startYear, " +
-        "       ti.stop_time AS end " +
-        "   FROM     sediment_load_ls sy " +
-        "       JOIN rivers r ON sy.river_id = r.id " +
-        "       JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " +
-        "       JOIN time_intervals ti ON sy.time_interval_id = ti.id " +
-        "   WHERE   r.name = :name " +
-        "       AND ti.stop_time IS NOT NULL " +
-        "       AND syv.station BETWEEN :startKm AND :endKm " +
-        "       AND sy.kind = 1";
-
-    /** Query to get description, name and time range for epoch-type
-     * sediment yields. */
-    public static final String SQL_SELECT_EPOCHS =
-        "SELECT DISTINCT " +
-        "       sy.description AS description, " +
-        "       ti.start_time AS startYear, " +
-        "       ti.stop_time AS end, " +
-        "       u.name AS unit" +
-        "   FROM     sediment_load_ls sy " +
-        "       JOIN rivers r ON sy.river_id = r.id " +
-        "       JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " +
-        "       JOIN time_intervals ti ON sy.time_interval_id = ti.id " +
-        "       JOIN units u ON u.id = sy.unit_id " +
-        "   WHERE   r.name = :name " +
-        "       AND ti.stop_time IS NOT NULL " +
-        "       AND sy.kind = 0" +
-        "       AND syv.station BETWEEN :startKm AND :endKm";
-
-    public static final String SQL_SELECT_SINGLES_DATA_BY_ID =
-        "SELECT" +
-        "       sy.description AS description, " +
-        "       syv.value AS load, " +
-        "       syv.station AS km, " +
-        "       u.name AS unit, " +
-        "       gf.name AS fraction " +
-        "   FROM     sediment_load_ls sy " +
-        "       JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " +
-        "       JOIN units u ON u.id = sy.unit_id" +
-        "       JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " +
-        "   WHERE   sy.id = :id" +
-        "   ORDER BY syv.station";
-
-    public static final String SQL_SELECT_SINGLES_DATA =
-        "SELECT" +
-        "       sy.description AS description, " +
-        "       ti.start_time AS year, " +
-        "       syv.value AS load, " +
-        "       syv.station AS km, " +
-        "       u.name AS unit " +
-        "   FROM     sediment_load_ls sy " +
-        "       JOIN rivers r ON sy.river_id = r.id " +
-        "       JOIN time_intervals ti ON sy.time_interval_id = ti.id " +
-        "       JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " +
-        "       JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " +
-        "       JOIN units u ON u.id = sy.unit_id" +
-        "   WHERE   r.name = :name " +
-        "       AND ti.start_time BETWEEN :begin AND :end " +
-        "       AND ti.stop_time IS NULL " +
-        "       AND gf.name = :grain " +
-        "       AND syv.station BETWEEN :startKm AND :endKm " +
-        "   ORDER BY syv.station";
-
-    public static final String SQL_SELECT_UNKNOWN_DATA =
-        "SELECT" +
-        "       sy.description AS description, " +
-        "       ti.start_time AS startYear, " +
-        "       ti.stop_time AS end, " +
-        "       syv.value AS load, " +
-        "       syv.station AS km, " +
-        "       u.name AS unit " +
-        "   FROM     sediment_load_ls sy " +
-        "       JOIN rivers r ON sy.river_id = r.id " +
-        "       JOIN time_intervals ti ON sy.time_interval_id = ti.id " +
-        "       JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " +
-        "       JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " +
-        "       JOIN units u ON u.id = sy.unit_id" +
-        "   WHERE   r.name = :name " +
-        "       AND sy.description = :descr " +
-        "       AND gf.name = 'unknown' " +
-        "       AND sy.kind = :type" +
-        "   ORDER BY syv.station";
-
-    public static final String SQL_SELECT_UNKNOWN =
-        "SELECT DISTINCT " +
-        "    sy.description AS description, " +
-        "    ti.start_time AS startYear, " +
-        "    ti.stop_time AS end " +
-        "FROM sediment_load_ls sy " +
-        "    JOIN rivers r ON sy.river_id = r.id " +
-        "    JOIN time_intervals ti ON sy.time_interval_id = ti.id " +
-        "    JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " +
-        "    JOIN units u ON sy.unit_id = u.id " +
-        "WHERE r.name = :river " +
-        "    AND gf.name = 'unknown' " +
-        "    AND sy.kind = :type " +
-        "    AND u.name = :unit";
-
-    public static final String SQL_SELECT_EPOCHS_DATA =
-        "SELECT" +
-        "       sy.description AS description, " +
-        "       ti.start_time AS startYear, " +
-        "       syv.value AS load, " +
-        "       syv.station AS km," +
-        "       ti.stop_time AS endYear, " +
-        "       u.name AS unit" +
-        "   FROM     sediment_load_ls sy " +
-        "       JOIN rivers r ON sy.river_id = r.id " +
-        "       JOIN time_intervals ti ON sy.time_interval_id = ti.id " +
-        "       JOIN sediment_load_ls_values syv ON sy.id = syv.sediment_load_ls_id " +
-        "       JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " +
-        "       JOIN units u ON u.id = sy.unit_id " +
-        "   WHERE   r.name = :name " +
-        "       AND ti.start_time BETWEEN :sbegin AND :send " +
-        "       AND ti.stop_time BETWEEN :ebegin AND :eend " +
-        "       AND gf.name = :grain " +
-        "       AND syv.station BETWEEN :startKm AND :endKm " +
-        "   ORDER BY syv.station";
-
-    private SedimentLoadFactory() {
-    }
-
-    /**
-     * @param river name of river.
-     * @param type
-     */
-    public static SedimentLoadLSData[] getLoads(
-        String river,
-        String type,
-        double startKm,
-        double endKm
-    ) {
-        log.debug("SedimentLoadFactory.getLoads");
-        Cache cache = CacheFactory.getCache(LOADS_CACHE_NAME);
-
-        if (cache == null) {
-            log.debug("Cache not configured.");
-            return getSedimentLoadsUncached(river, type, startKm, endKm);
-        }
-
-        StaticSedimentLoadCacheKey key =
-            new StaticSedimentLoadCacheKey(river, startKm, endKm, 0, 0);
-
-        Element element = cache.get(key);
-
-        if (element != null) {
-            log.debug("SedimentLoad found in cache");
-            return (SedimentLoadLSData[])element.getValue();
-        }
-
-        SedimentLoadLSData[] values =
-            getSedimentLoadsUncached(river, type, startKm, endKm);
-
-        if (values != null) {
-            log.debug("Store static sediment load values in cache.");
-            element = new Element(key, values);
-            cache.put(element);
-        }
-        return values;
-    }
-
-    /**
-     * Get a sedimentLoad filled with data from db (or cache).
-     * @param type "epoch", "off_epoch" or "single"
-     * @return A Sedimentload filled with values from db or cache.
-     */
-    public static SedimentLoadLSData getLoadWithData(
-        String river,
-        String type,
-        double startKm,
-        double endKm,
-        int syear,
-        int eyear
-    ) {
-        log.debug("SedimentLoadFactory.getLoadWithData");
-        Cache cache = CacheFactory.getCache(LOAD_DATA_CACHE_NAME);
-
-        if (cache == null) {
-            log.debug("Cache not configured.");
-            return getSedimentLoadWithDataUncached(
-                river,
-                type,
-                startKm,
-                endKm,
-                syear,
-                eyear);
-        }
-
-        StaticSedimentLoadCacheKey key =
-            new StaticSedimentLoadCacheKey(river, startKm, endKm, syear, eyear);
-
-        Element element = cache.get(key);
-
-        if (element != null) {
-            log.debug("SedimentLoad found in cache");
-            return (SedimentLoadLSData)element.getValue();
-        }
-
-        SedimentLoadLSData values = getSedimentLoadWithDataUncached(
-            river,
-            type,
-            startKm,
-            endKm,
-            syear,
-            eyear);
-
-        if (values != null) {
-            log.debug("Store sediment loads in cache.");
-            element = new Element(key, values);
-            cache.put(element);
-        }
-        return values;
-    }
-
-    /**
-     * Get sediment yields time definition.
-     * @param id the sediment yield by id.
-     * @return sediment yields fraction name.
-     */
-    public static Date[] getSedimentYieldTimes(int id) {
-        log.debug("SedimentLoadFactory.getSedimentYieldTimes");
-
-        Session session = SessionHolder.HOLDER.get();
-        SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_TIMES_BY_ID)
-                .addScalar("starttime", StandardBasicTypes.DATE)
-                .addScalar("stoptime", StandardBasicTypes.DATE);
-        sqlQuery.setInteger("id", id);
-
-        List<Object[]> results = sqlQuery.list();
-        Object[] row = results.get(0);
-
-        return new Date[] {(Date)row[0], (Date) row[1]};
-    }
-
-    /**
-     * Get sediment load unit name.
-     * @param id the sediment yield by id.
-     * @return sediment yields unit name.
-     */
-    public static String getSedimentYieldUnitName(int id) {
-        log.debug("SedimentLoadFactory.getSedimentYieldUnitName");
-
-        Session session = SessionHolder.HOLDER.get();
-        SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_UNIT_BY_ID)
-                .addScalar("unit", StandardBasicTypes.STRING);
-        sqlQuery.setDouble("id", id);
-
-        List<Object> results = sqlQuery.list();
-
-        return (String) results.get(0);
-    }
-
-    /**
-     * Get sediment load fraction name.
-     * @param id the sediment yield by id.
-     * @return sediment yields fraction name.
-     */
-    public static String getSedimentYieldFractionName(int id) {
-        log.debug("SedimentLoadFactory.getSedimentYieldFractionName");
-
-        Session session = SessionHolder.HOLDER.get();
-        SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_FRACTION_BY_ID)
-                .addScalar("fraction", StandardBasicTypes.STRING);
-        sqlQuery.setDouble("id", id);
-
-        List<Object> results = sqlQuery.list();
-
-        return (String) results.get(0);
-    }
-
-
-    /**
-     * Get sediment load description.
-     * @param id the sediment yield by id.
-     * @return sediment yields description
-     */
-    public static String getSedimentYieldDescription(int id) {
-        log.debug("SedimentLoadFactory.getSedimentYieldDescription");
-
-        Session session = SessionHolder.HOLDER.get();
-        SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_BY_ID)
-                .addScalar("description", StandardBasicTypes.STRING);
-        sqlQuery.setDouble("id", id);
-
-        List<Object> results = sqlQuery.list();
-
-        return (String) results.get(0);
-    }
-
-
-    /**
-     * Get sediment loads from db.
-     * @param river the river
-     * @param type the sediment load type (year or epoch)
-     * @return according sediment loads.
-     */
-    public static SedimentLoadLSData[] getSedimentLoadsUncached(
-        String river,
-        String type,
-        double startKm,
-        double endKm
-    ) {
-        log.debug("SedimentLoadFactory.getSedimentLoadsUncached");
-
-        Session session = SessionHolder.HOLDER.get();
-        SQLQuery sqlQuery = null;
-
-        if (type.equals("single")) {
-            sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLES)
-                .addScalar("description", StandardBasicTypes.STRING)
-                .addScalar("year", StandardBasicTypes.DATE);
-            sqlQuery.setString("name", river);
-            sqlQuery.setDouble("startKm", startKm);
-            sqlQuery.setDouble("endKm", endKm);
-            List<Object []> results = sqlQuery.list();
-            SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()];
-            for (int i = 0, R = results.size(); i < R; i++) {
-                Object[] row = results.get(i);
-                loads[i] = new SedimentLoadLSData(
-                    (String) row[0],
-                    (Date) row[1],
-                    null,
-                    false,
-                    "");
-            }
-            return loads;
-        }
-        else if (type.equals("epoch")) {
-            sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCHS)
-                .addScalar("description", StandardBasicTypes.STRING)
-                .addScalar("startYear", StandardBasicTypes.DATE)
-                .addScalar("end", StandardBasicTypes.DATE);
-            sqlQuery.setString("name", river);
-            sqlQuery.setDouble("startKm", startKm);
-            sqlQuery.setDouble("endKm", endKm);
-            List<Object []> results = sqlQuery.list();
-
-            SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()];
-            for (int i = 0, R = results.size(); i < R; i++) {
-                Object[] row = results.get(i);
-                loads[i] = new SedimentLoadLSData(
-                    (String) row[0],
-                    (Date) row[1],
-                    (Date) row[2],
-                    true,
-                    "");
-            }
-            return loads;
-        }
-        else if (type.equals("off_epoch")) {
-            sqlQuery = session.createSQLQuery(SQL_SELECT_OFFEPOCHS)
-                .addScalar("startYear", StandardBasicTypes.DATE)
-                .addScalar("end", StandardBasicTypes.DATE);
-            sqlQuery.setString("name", river);
-            sqlQuery.setDouble("startKm", startKm);
-            sqlQuery.setDouble("endKm", endKm);
-            List<Object []> results = sqlQuery.list();
-
-            SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()];
-            for (int i = 0, R = results.size(); i < R; i++) {
-                Object[] row = results.get(i);
-                loads[i] = new SedimentLoadLSData(
-                    ((Date) row[0]).toString() + (Date) row[1],
-                    (Date) row[0],
-                    (Date) row[1],
-                    true,
-                    "");
-            }
-            return loads;
-        }
-        else {
-             log.warn("getSedimentLoadsUncached does not understand type " + type);
-        }
-        return new SedimentLoadLSData[0];
-    }
-
-    /**
-     * Get a specific sediment load from db.
-     *
-     * @param id the sediment yields id.
-     *
-     * @return according sediment load.
-     */
-    public static SedimentLoadLSData getSedimentLoadWithDataUncached(
-        String id,
-        String river
-    ) {
-        log.debug("SedimentLoadFactory.getSedimentLoadWithDataUncached / id " + id);
-        Session session = SessionHolder.HOLDER.get();
-        SQLQuery sqlQuery = null;
-
-        // Measurement stations: all, for float-stuff, for suspended stuff.
-        // Because they need fast sorted access, use TreeMaps.
-        // They map the starting validity range km to the station itself.
-        List<MeasurementStation> allStations =
-            RiverFactory.getRiver(river).getMeasurementStations();
-        TreeMap<Double,MeasurementStation> floatStations =
-            new TreeMap<Double, MeasurementStation>();
-        TreeMap<Double,MeasurementStation> suspStations =
-            new TreeMap<Double, MeasurementStation>();
-
-        // From all stations, sort into the two kinds, skip undefined ones.
-        for (MeasurementStation measurementStation: allStations) {
-            if (measurementStation.getMeasurementType() == null ||
-                measurementStation.getRange() == null) {
-                continue;
-            }
-            if (measurementStation.getMeasurementType().equals("Schwebstoff")) {
-                suspStations.put(
-                    measurementStation.getRange().getA().doubleValue(),
-                    measurementStation);
-            }
-            else if (measurementStation.getMeasurementType().equals("Geschiebe")) {
-                floatStations.put(
-                    measurementStation.getRange().getA().doubleValue(),
-                    measurementStation);
-            }
-        }
-
-        sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLES_DATA_BY_ID)
-            .addScalar("description", StandardBasicTypes.STRING)
-            .addScalar("load", StandardBasicTypes.DOUBLE)
-            .addScalar("km", StandardBasicTypes.DOUBLE)
-            .addScalar("fraction", StandardBasicTypes.STRING)
-            .addScalar("unit", StandardBasicTypes.STRING);
-        sqlQuery.setInteger("id", Integer.valueOf(id));
-
-        List<Object []> results = sqlQuery.list();
-        SedimentLoadLSData load = new SedimentLoadLSData();
-        if (results.isEmpty()) {
-            log.warn("Empty result for year calculation.");
-        }
-        else {
-            Object[] row = results.get(0);
-            load = new SedimentLoadLSData(
-                    (String) row[0], //description
-                    null,//(Date) row[1], //start
-                    null,  //end
-                    false, //isEpoch
-                    (String) row[4]); //unit
-
-            String fraction = (String) row[3];
-
-            TreeMap<Double,MeasurementStation> relevantStations =
-                fraction.equals("suspended_sediment") /* || TODO clarify: fraction.equals("susp_sand") */
-                ? suspStations
-                : floatStations;
-
-            for (int i = 0, R = results.size(); i < R; i++) {
-                row = results.get(i);
-                double km = (Double) row[2];
-                Range range = findMeasurementStationRange(relevantStations, km);
-                if (range == null) {
-                    log.warn("No measurement station for " + fraction + " km " + km);
-                    continue;
-                }
-
-                double v = -1;
-
-                if (row[1] != null) {
-                    v = ((Double)row[1]).doubleValue();
-                }
-
-                setLoadFraction(load, km, v, range, fraction);
-            }
-
-        }
-
-        return load;
-    }
-
-    /**
-     * Get sediment loads from db.
-     *
-     * @param river the river
-     * @param type the sediment load type (year, epoch or off_epoch)
-     *
-     * @return according sediment loads.
-     */
-    public static SedimentLoadLSData getSedimentLoadWithDataUncached(
-        String river,
-        String type,
-        double startKm,
-        double endKm,
-        int syear,
-        int eyear
-    ) {
-        log.debug("SedimentLoadFactory.getSedimentLoadWithDataUncached");
-        Session session = SessionHolder.HOLDER.get();
-        SQLQuery sqlQuery = null;
-
-        // Measurement stations: all, for float-stuff, for suspended stuff.
-        // Because they need fast sorted access, use TreeMaps.
-        // They map the starting validity range km to the station itself.
-        List<MeasurementStation> allStations =
-            RiverFactory.getRiver(river).getMeasurementStations();
-        TreeMap<Double,MeasurementStation> floatStations =
-            new TreeMap<Double, MeasurementStation>();
-        TreeMap<Double,MeasurementStation> suspStations =
-            new TreeMap<Double, MeasurementStation>();
-
-        // From all stations, sort into the two kinds, skip undefined ones.
-        for (MeasurementStation measurementStation: allStations) {
-            if (measurementStation.getMeasurementType() == null ||
-                measurementStation.getRange() == null) {
-                continue;
-            }
-            if (measurementStation.getMeasurementType().equals("Schwebstoff")) {
-                suspStations.put(
-                    measurementStation.getRange().getA().doubleValue(),
-                    measurementStation);
-            }
-            else if (measurementStation.getMeasurementType().equals("Geschiebe")) {
-                floatStations.put(
-                    measurementStation.getRange().getA().doubleValue(),
-                    measurementStation);
-            }
-        }
-
-        // Construct date constraint.
-        Calendar start = Calendar.getInstance();
-        start.set(syear - 1, 11, 31);
-        Calendar end = Calendar.getInstance();
-        end.set(syear, 11, 30);
-
-        if (type.equals("year") || type.equals("epoch")) {
-            sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLES_DATA)
-                .addScalar("description", StandardBasicTypes.STRING)
-                .addScalar("year", StandardBasicTypes.DATE)
-                .addScalar("load", StandardBasicTypes.DOUBLE)
-                .addScalar("km", StandardBasicTypes.DOUBLE)
-                .addScalar("unit", StandardBasicTypes.STRING);
-            sqlQuery.setString("name", river);
-            sqlQuery.setDouble("startKm", startKm);
-            sqlQuery.setDouble("endKm", endKm);
-            sqlQuery.setDate("begin", start.getTime());
-            sqlQuery.setDate("end", end.getTime());
-            sqlQuery.setString("grain", "total");
-            List<Object []> results = sqlQuery.list();
-            SedimentLoadLSData load = new SedimentLoadLSData();
-            if (results.isEmpty()) {
-                log.warn("Empty result for year calculation.");
-            }
-            else {
-                Object[] row = results.get(0);
-                load = new SedimentLoadLSData(
-                        (String) row[0], //description
-                        (Date) row[1], //start
-                        null,  //end
-                        false, //isEpoch
-                        (String) row[4]); //unit
-            }
-            load = getValues("coarse", sqlQuery, load, floatStations);
-            load = getValues("fine_middle", sqlQuery, load, floatStations);
-            load = getValues("sand", sqlQuery, load, floatStations);
-            load = getValues("suspended_sediment", sqlQuery, load, suspStations);
-            load = getValues("susp_sand_bed", sqlQuery, load, floatStations);
-            load = getValues("susp_sand", sqlQuery, load, floatStations);
-
-            return load;
-        }
-        else if (type.equals("off_epoch")) {
-            // Set calendars to fetch the epochs by their start and end
-            // dates.
-            Calendar toStart = Calendar.getInstance();
-            toStart.set(eyear - 1, 11, 31);
-            Calendar toEnd = Calendar.getInstance();
-            toEnd.set(eyear+1, 00, 01);
-            // Set query parameters.
-            sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCHS_DATA)
-                .addScalar("description", StandardBasicTypes.STRING)
-                .addScalar("startYear", StandardBasicTypes.DATE)
-                .addScalar("load", StandardBasicTypes.DOUBLE)
-                .addScalar("km", StandardBasicTypes.DOUBLE)
-                .addScalar("endYear", StandardBasicTypes.DATE)
-                .addScalar("unit", StandardBasicTypes.STRING);
-            sqlQuery.setString("name", river);
-            sqlQuery.setDouble("startKm", startKm);
-            sqlQuery.setDouble("endKm", endKm);
-            sqlQuery.setDate("sbegin", start.getTime());
-            sqlQuery.setDate("send", end.getTime());
-            sqlQuery.setDate("ebegin", toStart.getTime());
-            sqlQuery.setDate("eend", toEnd.getTime());
-            sqlQuery.setString("grain", "total");
-
-            List<Object[]> results = null;
-            results = sqlQuery.list();
-
-            SedimentLoadLSData load = null;
-            if (results.isEmpty()) {
-                log.warn("No total results for off-epoch");
-            }
-            else {
-                Object[] row = results.get(0);
-                load = new SedimentLoadLSData(
-                        (String) row[0],
-                        (Date) row[1],
-                        (Date) row[4],
-                        true,
-                        (String)row[5]);
-                TDoubleArrayList kms = new TDoubleArrayList();
-                for (int i = 0, R = results.size(); i < R; i++) {
-                    row = results.get(i);
-                    kms.add((Double)row[3]);
-                    load.setLoadTotal((Double)row[3], (Double)row[2]);
-                }
-            }
-            load = getValues("coarse", sqlQuery, load, floatStations);
-            load = getValues("fine_middle", sqlQuery, load, floatStations);
-            load = getValues("sand", sqlQuery, load, floatStations);
-            load = getValues("suspended_sediment", sqlQuery, load, suspStations);
-            load = getValues("susp_sand_bed", sqlQuery, load, floatStations);
-            load = getValues("susp_sand", sqlQuery, load, floatStations);
-            return load;
-        }
-        return new SedimentLoadLSData();
-    }
-
-    protected static Range findMeasurementStationRange(
-        TreeMap<Double, MeasurementStation> stations,
-        double km
-    ) {
-        MeasurementStation station = stations.get(km);
-        if (station == null) {
-            return null;
-        }
-
-        double endKm;
-
-        if (stations.ceilingEntry(km + 0.1d) != null) {
-            MeasurementStation nextStation = stations.ceilingEntry(km + 0.1d).getValue();
-            endKm = nextStation.getRange().getA().doubleValue();
-        }
-        else {
-            // TODO end-of-river instead of B.
-            endKm = station.getRange().getB().doubleValue();
-        }
-
-        return new Range(
-            station.getRange().getA().doubleValue(),
-            endKm);
-    }
-
-    /**
-     * Run query with grain parameter set to fraction, feed result into
-     * load. Create load if null.
-     *
-     * @param fraction value to set 'grain' parameter in query to.
-     * @param query query in which to set 'grain' parameter and run.
-     * @param load[out] SedimentLoad which to populate with values. if null
-     *                  and values are found, return a new load.
-     * @return param load or new load if null.
-     */
-    protected static SedimentLoadLSData getValues (
-        String fraction,
-        SQLQuery query,
-        SedimentLoadLSData load,
-        TreeMap<Double, MeasurementStation> stations
-    ) {
-        query.setString("grain", fraction);
-        List<Object[]> results = query.list();
-
-        // We have the first results for this query, create new load.
-        if (!results.isEmpty() && load == null) {
-           Object[] row = results.get(0);
-           load = new SedimentLoadLSData(
-                   (String) row[0],
-                   (Date) row[1],
-                   (Date) row[4],
-                   true,
-                   (String)row[5]);
-        }
-
-        for (int i = 0, R = results.size(); i < R; i++) {
-            Object[] row = results.get(i);
-            double km = (Double)row[3];
-            Range range = findMeasurementStationRange(stations, km);
-            if (range == null) {
-                log.warn("No measurement station for " + fraction + " km " + km);
-                continue;
-            }
-            double v = -1;
-
-            if (row[2] != null) {
-                v = ((Double)row[2]).doubleValue();
-            }
-
-            setLoadFraction(load, km, v, range, fraction);
-        }
-
-        if (results.isEmpty()) {
-            log.warn("No " + fraction + " values found.");
-        }
-
-        return load;
-    }
-
-
-    /** Set a fraction value of load to given km, value and range. */
-    private static void setLoadFraction(
-        SedimentLoadLSData load, double km, double v, Range range, String fraction) {
-        if (fraction.equals("coarse")) {
-            load.setCoarse(km, v, range);
-        }
-        else if (fraction.equals("sand")) {
-            load.setSand(km, v, range);
-        }
-        else if (fraction.equals("fine_middle")) {
-            load.setFineMiddle(km, v, range);
-        }
-        else if (fraction.equals("suspended_sediment")) {
-            load.setSuspSediment(km, v, range);
-        }
-        else if (fraction.equals("susp_sand")) {
-            load.setSuspSand(km, v, range);
-        }
-        else if (fraction.equals("susp_sand_bed")) {
-            load.setSuspSandBed(km, v, range);
-        }
-        else if (fraction.equals("total")) {
-            load.setLoadTotal(km, v, range);
-        }
-        else {
-            log.error("Unknown fraction type " + fraction);
-        }
-    }
-
-    public static SedimentLoadLSData getLoadUnknown(
-        String river,
-        String description,
-        String type
-    ) {
-        log.debug("SedimentLoadFactory.getLoadWithData");
-        Cache cache = CacheFactory.getCache(LOAD_DATA_CACHE_NAME);
-
-        if (cache == null) {
-            log.debug("Cache not configured.");
-            return getSedimentLoadUnknownUncached(river, description, type);
-        }
-
-        StaticSedimentLoadCacheKey key =
-            new StaticSedimentLoadCacheKey(river, 0d, 0d, 0, 0);
-
-        Element element = cache.get(key);
-
-        if (element != null) {
-            log.debug("SedimentLoad found in cache");
-            return (SedimentLoadLSData)element.getValue();
-        }
-
-        SedimentLoadLSData values =
-            getSedimentLoadUnknownUncached(river, description, type);
-
-        if (values != null && key != null) {
-            log.debug("Store static bed height values in cache.");
-            element = new Element(key, values);
-            cache.put(element);
-        }
-        return values;
-    }
-
-    /**
-     * Get sediment loads with fraction 'unknown' from db.
-     * @param river the river
-     * @param type the sediment load type (year or epoch)
-     * @return according sediment loads.
-     */
-    public static SedimentLoadLSData getSedimentLoadUnknownUncached(
-        String river,
-        String description,
-        String type
-    ) {
-        log.debug("SedimentLoadFactory.getSedimentLoadWithDataUncached");
-        Session session = SessionHolder.HOLDER.get();
-        SQLQuery sqlQuery = null;
-
-        sqlQuery = session.createSQLQuery(SQL_SELECT_UNKNOWN_DATA)
-            .addScalar("description", StandardBasicTypes.STRING)
-            .addScalar("startYear", StandardBasicTypes.DATE)
-            .addScalar("end", StandardBasicTypes.DATE)
-            .addScalar("load", StandardBasicTypes.DOUBLE)
-            .addScalar("km", StandardBasicTypes.DOUBLE)
-            .addScalar("unit", StandardBasicTypes.STRING);
-        sqlQuery.setString("name", river);
-        sqlQuery.setString("descr", description);
-        if (type.equals("off_epoch")) {
-            sqlQuery.setInteger("type", 1);
-        }
-        else {
-            sqlQuery.setInteger("type", 0);
-        }
-        List<Object []> results = sqlQuery.list();
-        SedimentLoadLSData load = new SedimentLoadLSData();
-        if (results.isEmpty()) {
-            return new SedimentLoadLSData();
-        }
-        Object[] row = results.get(0);
-        load = new SedimentLoadLSData(
-            (String) row[0],
-            (Date) row[1],
-            (Date) row[2],
-            false,
-            (String)row[5]);
-
-        for (int i = 0, R = results.size(); i < R; i++) {
-            row = results.get(i);
-            SedimentLoadFraction fraction = new SedimentLoadFraction();
-            fraction.setUnknown((Double)row[3]);
-            load.addKm((Double)row[4], fraction);
-        }
-        return load;
-    }
-
-    /**
-     * Return sediment loads with 'unknown' fraction type.
-     * @param river Name of the river
-     * @param unit Restrict result set to those of given unit.
-     * @param type Type like year, epoch, off_epoch
-     */
-    public static SedimentLoadLSData[] getSedimentLoadUnknown(
-        String river,
-        String unit,
-        String type) {
-        Session session = SessionHolder.HOLDER.get();
-        SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_UNKNOWN)
-            .addScalar("description", StandardBasicTypes.STRING)
-            .addScalar("startYear", StandardBasicTypes.DATE)
-            .addScalar("end", StandardBasicTypes.DATE);
-        sqlQuery.setString("river", river);
-        sqlQuery.setString("unit", unit);
-        if (type.equals("off_epoch")) {
-            sqlQuery.setInteger("type", 1);
-        }
-        else {
-            sqlQuery.setInteger("type", 0);
-        }
-        List<Object[]> results = sqlQuery.list();
-        SedimentLoadLSData[] loads = new SedimentLoadLSData[results.size()];
-        int counter = 0;
-        for (Object[] row: results) {
-            loads[counter] = new SedimentLoadLSData(
-                (String)row[0], (Date)row[1], (Date)row[2], false, "");
-            counter++;
-        }
-        return loads;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadUnknownFacet.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-package org.dive4elements.river.artifacts.model.minfo;
-
-import org.apache.log4j.Logger;
-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.access.SedimentLoadAccess;
-import org.dive4elements.river.artifacts.model.DataFacet;
-import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
-
-
-public class SedimentLoadUnknownFacet
-extends DataFacet
-{
-    /** Very own logger. */
-    private static Logger logger = Logger.getLogger(SedimentLoadUnknownFacet.class);
-
-    public SedimentLoadUnknownFacet() {
-    }
-
-    public SedimentLoadUnknownFacet(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", "");
-    }
-
-    /** Get data from SedimentLoad with unknown type, from factory. */
-    @Override
-    public Object getData(Artifact artifact, CallContext context) {
-        logger.debug("Get data for sediment load at index: " + index);
-
-        D4EArtifact flys = (D4EArtifact) artifact;
-
-        SedimentLoadAccess access = new SedimentLoadAccess(flys);
-        String river = access.getRiverName();
-        String unit  = access.getUnit();
-        SedimentLoadLSData[] unknown =
-            SedimentLoadFactory.getSedimentLoadUnknown(
-                river,
-                unit.replace("_per_","/"),
-                access.getYearEpoch());
-
-        SedimentLoadLSData load = SedimentLoadFactory.getLoadUnknown(
-            river, unknown[index].getDescription(), access.getYearEpoch());
-        return load;
-    }
-
-    /** Copy deeply. */
-    @Override
-    public Facet deepCopy() {
-        SedimentLoadUnknownFacet copy = new SedimentLoadUnknownFacet();
-        copy.set(this);
-        copy.hash = hash;
-        copy.stateId = stateId;
-        return copy;
-    }
-}
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffBaseGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffBaseGenerator.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/* Copyright (C) 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.exports.minfo;
-
-import org.apache.log4j.Logger;
-
-import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
-import org.dive4elements.river.artifacts.model.minfo.BedDifferencesResult;
-import org.dive4elements.river.jfree.Bounds;
-import org.dive4elements.river.jfree.DoubleBounds;
-import org.dive4elements.river.exports.fixings.FixChartGenerator;
-
-/** Base for BedDiff*Year*Generators, to avoid duplicate code of setContextBounds. */
-public abstract class BedDiffBaseGenerator
-extends FixChartGenerator
-{
-    /** The logger that is used in this generator. */
-    private static Logger logger = Logger.getLogger(BedDiffBaseGenerator.class);
-
-    /** Set context values for something. */
-    public void setContextBounds(ArtifactAndFacet bundle) {
-        Bounds xBounds = getXBounds(0);
-        if (xBounds != null && getDomainAxisRange() != null) {
-            Bounds bounds =
-                calculateZoom(xBounds, getDomainAxisRange());
-            context.putContextValue("startkm", bounds.getLower());
-            context.putContextValue("endkm", bounds.getUpper());
-        }
-        else if (xBounds != null && getDomainAxisRange() == null) {
-            context.putContextValue("startkm", xBounds.getLower());
-            context.putContextValue("endkm", xBounds.getUpper());
-        }
-        else if (xBounds == null && getDomainAxisRange() == null) {
-            BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
-            if (data.getKms().size() > 0) {
-                context.putContextValue("startkm", data.getKms().min());
-                context.putContextValue("endkm", data.getKms().max());
-            }
-            else {
-                logger.warn("No data to define start and end km");
-            }
-        }
-        else if (xBounds == null && getDomainAxisRange() != null){
-            BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
-            Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max());
-            Bounds bounds =
-                calculateZoom(b, getDomainAxisRange());
-            context.putContextValue("startkm", bounds.getLower());
-            context.putContextValue("endkm", bounds.getUpper());
-        }
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/exports/process/KMIndexProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/KMIndexProcessor.java	Thu Sep 04 15:03:25 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.exports.process;
-
-import org.apache.log4j.Logger;
-import org.jfree.data.xy.XYSeries;
-import org.jfree.data.xy.XYSeriesCollection;
-
-import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
-import org.dive4elements.artifacts.CallContext;
-import org.dive4elements.river.artifacts.model.FacetTypes;
-import org.dive4elements.river.artifacts.model.fixings.AnalysisPeriod;
-import org.dive4elements.river.artifacts.model.fixings.QWD;
-import org.dive4elements.river.exports.XYChartGenerator;
-import org.dive4elements.river.jfree.StyledXYSeries;
-import org.dive4elements.river.themes.ThemeDocument;
-import org.dive4elements.river.utils.KMIndex;
-
-public class KMIndexProcessor extends DefaultProcessor {
-
-    private static final Logger logger = Logger.getLogger(KMIndexProcessor.class);
-
-    @Override
-    public void doOut(XYChartGenerator generator, ArtifactAndFacet bundle,
-            ThemeDocument theme, boolean visible, int index) {
-        String facettype = bundle.getFacetName();
-        if (facettype.contains(FacetTypes.FIX_SECTOR_AVERAGE_LS)) {
-            doSectorAverageOut(generator, bundle, theme, visible, index);
-        }
-        else if (facettype.equals(FacetTypes.FIX_REFERENCE_EVENTS_LS)) {
-            doReferenceEventsOut(generator, bundle, theme, visible, index);
-        }
-        else if (facettype.equals(FacetTypes.FIX_ANALYSIS_EVENTS_LS)) {
-            doAnalysisEventsOut(generator, bundle, theme, visible, index);
-        }
-
-    }
-
-    @Override
-    public boolean canHandle(String facettype) {
-        if (facettype == null) {
-            return false;
-        }
-
-        if (facettype.contains(FacetTypes.FIX_SECTOR_AVERAGE_LS)
-                || facettype.equals(FacetTypes.FIX_REFERENCE_EVENTS_LS)
-                || facettype.equals(FacetTypes.FIX_ANALYSIS_EVENTS_LS))
-        {
-            return true;
-        }
-        return false;
-    }
-
-    private void doSectorAverageOut(XYChartGenerator generator, ArtifactAndFacet bundle,
-            ThemeDocument doc, boolean visible, int idx) {
-        logger.debug("doSectorAverageOut" + bundle.getFacet().getIndex());
-
-        CallContext context = generator.getCallContext();
-        int index = bundle.getFacet().getIndex();
-        int sectorNdx = index & 3;
-
-        @SuppressWarnings("unchecked")
-        KMIndex<AnalysisPeriod> kms =
-                (KMIndex<AnalysisPeriod>)bundle.getData(context);
-
-        if(kms == null) {
-            return;
-        }
-
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), doc);
-
-        for (KMIndex.Entry<AnalysisPeriod> entry: kms) {
-            double km = entry.getKm();
-            AnalysisPeriod ap = entry.getValue();
-            QWD qwd = ap.getQSectorAverages()[sectorNdx];
-            if (qwd == null) {
-                continue;
-            }
-            double deltaW = qwd.getDeltaW();
-            series.add(km, deltaW);
-        }
-
-        generator.addAxisSeries(series, idx, visible);
-    }
-
-    private void doReferenceEventsOut(XYChartGenerator generator,
-            ArtifactAndFacet bundle, ThemeDocument doc, boolean visible, int idx) {
-        logger.debug("doReferenceEventOut");
-
-        CallContext context = generator.getCallContext();
-
-        @SuppressWarnings("unchecked")
-        KMIndex<QWD> kms =
-                (KMIndex<QWD>)bundle.getData(context);
-
-        if(kms == null) {
-            return;
-        }
-
-        XYSeriesCollection col = new XYSeriesCollection();
-
-        StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), false,
-                doc);
-
-        for (KMIndex.Entry<QWD> entry: kms) {
-            double km = entry.getKm();
-            QWD qwd = entry.getValue();
-
-            series.add(km, qwd.getDeltaW());
-        }
-        col.addSeries(series);
-
-        generator.addAxisDataset(col, idx, visible);
-    }
-
-    private void doAnalysisEventsOut(XYChartGenerator generator,
-            ArtifactAndFacet bundle, ThemeDocument doc, boolean visible, int idx) {
-        logger.debug("doAnalysisEventsOut");
-
-        CallContext context = generator.getCallContext();
-
-        @SuppressWarnings("unchecked")
-        KMIndex<QWD> kms =
-                (KMIndex<QWD>)bundle.getData(context);
-
-        if(kms == null) {
-            return;
-        }
-
-        XYSeriesCollection col = new XYSeriesCollection();
-
-        StyledXYSeries series = new StyledXYSeries(bundle.getFacetDescription(), false, doc);
-
-        for (KMIndex.Entry<QWD> entry: kms) {
-            double km = entry.getKm();
-            QWD qwd = entry.getValue();
-
-            series.add(km, qwd.getDeltaW());
-        }
-        col.addSeries(series);
-
-        generator.addAxisDataset(col, idx, visible);
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 3bb1c62ad732 -r fcc1ffbc2ea6 artifacts/src/main/java/org/dive4elements/river/themes/PointStyle.java
--- a/artifacts/src/main/java/org/dive4elements/river/themes/PointStyle.java	Thu Sep 04 15:03:25 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +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.themes;
-
-public class PointStyle {
-    // TODO tbd
-}
\ No newline at end of file


More information about the Dive4Elements-commits mailing list