[PATCH] Remove obsolete historical discharge curve implementations

Wald Commits scm-commit at wald.intevation.org
Thu Oct 30 15:04:59 CET 2014


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1414677835 -3600
# Node ID 1127dbe950832750a7853852c46ffb4c2987f07c
# Parent  2b4191f78ea64874a8f43898ae36b4737cc9fe66
Remove obsolete historical discharge curve implementations.

diff -r 2b4191f78ea6 -r 1127dbe95083 artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation6.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation6.java	Thu Oct 30 14:20:28 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation6.java	Thu Oct 30 15:03:55 2014 +0100
@@ -127,13 +127,12 @@
         ValuesCache vc = new ValuesCache();
 
         WQTimerange [] wqt = prepareData(refTable, dts, vc);
-        WQKms []       wqs = prepareWQData(dts, vc);
 
         if (debug) {
             log.debug("Number of calculation results: " + wqt.length);
         }
 
-        return new CalculationResult(new HistoricalDischargeData(wqt, wqs),
+        return new CalculationResult(new HistoricalDischargeData(wqt),
             this);
     }
 
@@ -196,32 +195,6 @@
         return !(timerange[1] < dtStart || timerange[0] > dtStop);
     }
 
-    protected WQKms[] prepareWQData(List<DischargeTable> dts, ValuesCache vc) {
-        WQKms[] wqs = new WQKms[dts.size()];
-
-        for (int i = 0, N = wqs.length; i < N; ++i) {
-            DischargeTable dt = dts.get(i);
-            wqs[i] = prepareWQ(dt, vc.getValues(dts.get(i)));
-        }
-
-        return wqs;
-    }
-
-    protected WQKms prepareWQ(DischargeTable dt, double[][] values) {
-        double datum = dt.getGauge().getDatum().doubleValue();
-        double km = dt.getGauge().getStation().doubleValue();
-
-        double[] kms = new double[values[1].length];
-        Arrays.fill(kms, km);
-
-        for (int i = 0 ; i < values[1].length; i++) {
-            values[1][i] = values[1][i]/100d + datum;
-        }
-
-        return new HistoricalWQKms(kms, values[0], values[1],
-            String.valueOf(km), dt.getTimeInterval());
-    }
-
     protected String name(double value) {
         return mode == EvaluationMode.W.getMode()
             ? "W=" + value
diff -r 2b4191f78ea6 -r 1127dbe95083 artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java	Thu Oct 30 14:20:28 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java	Thu Oct 30 15:03:55 2014 +0100
@@ -289,7 +289,6 @@
     String HISTORICAL_DISCHARGE_W_DIFF = "historical_discharge.historicalw.diff";
     String HISTORICAL_DISCHARGE_WQ_Q   = "historical_discharge.wq.q";
     String HISTORICAL_DISCHARGE_WQ_W   = "historical_discharge.wq.w";
-    String HISTORICAL_DISCHARGE_WQ_CURVE = "historical_discharge.wq.curve";
 
     String REFERENCE_CURVE            = "reference_curve";
     String REFERENCE_CURVE_NORMALIZED = "reference_curve_normalized";
diff -r 2b4191f78ea6 -r 1127dbe95083 artifacts/src/main/java/org/dive4elements/river/artifacts/model/HistoricalDischargeCurveFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/HistoricalDischargeCurveFacet.java	Thu Oct 30 14:20:28 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +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;
-
-
-/**
- * @author <a href="mailto:ingo.weinzierl at intevation.de">Ingo Weinzierl</a>
- */
-public class HistoricalDischargeCurveFacet extends DataFacet {
-
-    public HistoricalDischargeCurveFacet() {
-    }
-
-    public HistoricalDischargeCurveFacet(int index, String name,
-        String description, ComputeType type, String stateID, String hash
-
-    ) {
-        super(index, name, description, type, hash, stateID);
-    }
-
-    @Override
-    public Facet deepCopy() {
-        WaterlevelFacet copy = new WaterlevelFacet();
-        copy.set(this);
-        copy.type = type;
-        copy.hash = hash;
-        copy.stateId = stateId;
-        return copy;
-    }
-
-    @Override
-    public Object getData(Artifact artifact, CallContext context) {
-        D4EArtifact flys = (D4EArtifact) artifact;
-
-        CalculationResult res = (CalculationResult) flys.compute(context, hash,
-            stateId, type, false);
-
-        HistoricalDischargeData data = (HistoricalDischargeData) res.getData();
-        WQKms[] wqkms = (WQKms[]) data.getWQs();
-
-        return wqkms[index];
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r 2b4191f78ea6 -r 1127dbe95083 artifacts/src/main/java/org/dive4elements/river/artifacts/model/HistoricalDischargeData.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/HistoricalDischargeData.java	Thu Oct 30 14:20:28 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/HistoricalDischargeData.java	Thu Oct 30 15:03:55 2014 +0100
@@ -13,25 +13,19 @@
 
 public class HistoricalDischargeData implements Serializable {
 
-    private WQKms[] wqs;
     private WQTimerange[] wqTimeranges;
 
     public HistoricalDischargeData() {
-        wqs          = new WQKms[0];
         wqTimeranges = new WQTimerange[0];
     }
 
-    public HistoricalDischargeData(WQTimerange[] wqTimeranges, WQKms[] wqs) {
+    public HistoricalDischargeData(WQTimerange[] wqTimeranges) {
         this.wqTimeranges = wqTimeranges;
-        this.wqs = wqs;
     }
 
     public WQTimerange[] getWQTimeranges() {
         return wqTimeranges;
     }
 
-    public WQ[] getWQs() {
-        return wqs;
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 2b4191f78ea6 -r 1127dbe95083 artifacts/src/main/java/org/dive4elements/river/artifacts/model/HistoricalWQKms.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/HistoricalWQKms.java	Thu Oct 30 14:20:28 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +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.river.model.TimeInterval;
-
-
-public class HistoricalWQKms extends WQKms {
-
-    private TimeInterval timeInterval;
-
-    public HistoricalWQKms() {
-    }
-
-    public HistoricalWQKms(double[] kms, double[] qs, double[] ws, String name,
-        TimeInterval timeInterval) {
-        super(kms, qs, ws, name);
-        this.timeInterval = timeInterval;
-    }
-
-    public TimeInterval getTimeInterval() {
-        return timeInterval;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 2b4191f78ea6 -r 1127dbe95083 artifacts/src/main/java/org/dive4elements/river/artifacts/states/HistoricalDischargeComputeState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/HistoricalDischargeComputeState.java	Thu Oct 30 14:20:28 2014 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/HistoricalDischargeComputeState.java	Thu Oct 30 15:03:55 2014 +0100
@@ -31,12 +31,10 @@
 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.HistoricalDischargeCurveFacet;
 import org.dive4elements.river.artifacts.model.HistoricalDischargeData;
 import org.dive4elements.river.artifacts.model.HistoricalDischargeDifferenceFacet;
 import org.dive4elements.river.artifacts.model.HistoricalDischargeFacet;
 import org.dive4elements.river.artifacts.model.HistoricalDischargeWQFacet;
-import org.dive4elements.river.artifacts.model.HistoricalWQKms;
 import org.dive4elements.river.artifacts.model.HistoricalWQTimerange;
 import org.dive4elements.river.artifacts.model.ReportFacet;
 import org.dive4elements.river.artifacts.model.WQKms;
@@ -61,8 +59,6 @@
         .getLogger(HistoricalDischargeComputeState.class);
 
     public static final String DEFAULT_UNIT = "cm";
-    public static final String I18N_WQ_CURVE_FACET_RANGE = "historical_discharge.wq.curve_range";
-    public static final String I18N_WQ_CURVE_FACET_SINCE = "historical_discharge.wq.curve_since";
 
     @Override
     protected void appendItems(Artifact artifact, ElementCreator creator,
@@ -103,10 +99,7 @@
             prepareFacets(facets, wqts, access);
         }
 
-        WQKms[] wqs = (WQKms[]) data.getWQs();
-        if (wqs != null && wqs.length > 0) {
-            prepareWQFacets(context, facets, wqs, access, hash);
-        }
+        prepareWQFacets(context, facets, access, hash);
 
         return res;
     }
@@ -154,7 +147,7 @@
     }
 
     protected void prepareWQFacets(CallContext cc, List<Facet> facets,
-        WQKms[] wqs, HistoricalDischargeAccess access, String hash) {
+        HistoricalDischargeAccess access, String hash) {
         double[] ws = access.getWs();
         double[] qs = access.getQs();
 
@@ -171,41 +164,8 @@
                 HISTORICAL_DISCHARGE_WQ_Q, "Q=" + format.format(qs[k]), ComputeType.ADVANCE,
                 hash, getID(), qs[k]));
         }
-
-        int idx = 0;
-        for (WQKms wqkms : wqs) {
-            String title = null;
-            if (wqkms instanceof HistoricalWQKms) {
-                title = createDischargeCurveTitle(cc, (HistoricalWQKms) wqkms);
-            }
-            else {
-                title = wqkms.getName();
-            }
-
-            facets.add(new HistoricalDischargeCurveFacet(idx,
-                HISTORICAL_DISCHARGE_WQ_CURVE, title, ComputeType.ADVANCE,
-                getID(), hash));
-            idx++;
-        }
     }
 
-    /** Create title for a Discharge-curve, including date. */
-    protected String createDischargeCurveTitle(CallContext cc,
-        HistoricalWQKms wqkms) {
-        TimeInterval timeInterval = wqkms.getTimeInterval();
-
-        if (timeInterval.getStopTime() != null) {
-            return Resources.format(cc.getMeta(), I18N_WQ_CURVE_FACET_RANGE,
-                I18N_WQ_CURVE_FACET_RANGE, timeInterval.getStartTime(),
-                timeInterval.getStopTime());
-        }
-        else {
-            return Resources.format(cc.getMeta(), I18N_WQ_CURVE_FACET_SINCE,
-                I18N_WQ_CURVE_FACET_SINCE, timeInterval.getStartTime());
-        }
-    }
-
-
     /** Create string for facets name/description. */
     protected String createFacetTitle(WQTimerange wqt) {
         String name = wqt.getName();
diff -r 2b4191f78ea6 -r 1127dbe95083 artifacts/src/main/java/org/dive4elements/river/exports/process/HistoricalDischargeProcessor.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/HistoricalDischargeProcessor.java	Thu Oct 30 14:20:28 2014 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-package org.dive4elements.river.exports.process;
-
-import org.apache.log4j.Logger;
-import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
-import org.dive4elements.artifacts.CallContext;
-import org.dive4elements.river.artifacts.model.FacetTypes;
-import org.dive4elements.river.artifacts.model.WQKms;
-import org.dive4elements.river.exports.DiagramGenerator;
-import org.dive4elements.river.exports.StyledSeriesBuilder;
-import org.dive4elements.river.jfree.StyledXYSeries;
-import org.dive4elements.river.themes.ThemeDocument;
-import org.jfree.data.xy.XYSeries;
-
-
-public class HistoricalDischargeProcessor
-extends DefaultProcessor
-implements FacetTypes
-{
-
-    private final static Logger log =
-            Logger.getLogger(HistoricalDischargeProcessor.class);
-
-    /** Station for which the diagram is shown. */
-    private double km;
-
-    /** Tolerance for comparison of kilometers. */
-    public static final double KM_EPSILON = 0.001d;
-
-
-    /** This processor needs to be constructed with a given km. */
-    public HistoricalDischargeProcessor() {
-        km = Double.NaN;
-    }
-
-
-    public HistoricalDischargeProcessor(double km) {
-        this.km = km;
-    }
-
-
-    /** Process data, add it to plot. */
-    @Override
-    public void doOut(
-            DiagramGenerator generator,
-            ArtifactAndFacet bundle,
-            ThemeDocument theme,
-            boolean visible
-    ) {
-        log.debug("do out: " + bundle.getFacetName());
-        CallContext context = generator.getCallContext();
-        Object data = bundle.getData(context);
-        if (data instanceof WQKms) {
-            doDischargeOut(generator, bundle, theme, visible);
-        }
-    }
-
-    /** True if this processor knows how to deal with facetType. */
-    @Override
-    public boolean canHandle(String facetType) {
-        return HISTORICAL_DISCHARGE_WQ_CURVE.equals(facetType);
-    }
-
-
-    /** The station of the current calculation/view. */
-    protected double getKm() {
-        return km;
-    }
-
-    /**
-     * Add series with discharge curve to diagram.
-     */
-    protected void doDischargeOut(
-        DiagramGenerator generator,
-        ArtifactAndFacet bundle,
-        ThemeDocument theme,
-        boolean       visible
-    ) {
-        CallContext context = generator.getCallContext();
-        WQKms data = (WQKms)bundle.getData(context);
-        XYSeries series = new StyledXYSeries(
-            bundle.getFacetDescription().trim(),
-            theme
-        );
-        double[][] wqData = new double[2][data.size()];
-        for (int i = 0; i < data.size(); i++) {
-            wqData[0][i] = data.getQ(i);
-            wqData[1][i] = data.getW(i);
-        }
-        StyledSeriesBuilder.addPoints(series, wqData, false);
-
-        generator.addAxisSeries(series, axisName, visible);
-    }
-}
diff -r 2b4191f78ea6 -r 1127dbe95083 artifacts/src/main/resources/messages.properties
--- a/artifacts/src/main/resources/messages.properties	Thu Oct 30 14:20:28 2014 +0100
+++ b/artifacts/src/main/resources/messages.properties	Thu Oct 30 15:03:55 2014 +0100
@@ -80,8 +80,6 @@
 
 historical.mode.w = Waterlevel Analyse
 historical.mode.q = Discharge Analyse
-historical_discharge.wq.curve_range = Discharge Curve {0,date,medium} - {1,date,medium}
-historical_discharge.wq.curve_since = Discharge Curve {0,date,medium}
 
 calc.surface.curve = Water Level/Surface Curve
 calc.flood.map = Flood Plain
diff -r 2b4191f78ea6 -r 1127dbe95083 artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties	Thu Oct 30 14:20:28 2014 +0100
+++ b/artifacts/src/main/resources/messages_de.properties	Thu Oct 30 15:03:55 2014 +0100
@@ -81,8 +81,6 @@
 
 historical.mode.w = Wasserstandsanalyse
 historical.mode.q = Abflussanalyse
-historical_discharge.wq.curve_range = Abflusskurve {0,date,medium} - {1,date,medium}
-historical_discharge.wq.curve_since = Abflusskurve ab {0,date,medium}
 
 calc.surface.curve = Wasserstand/Wasserspiegellage
 calc.flood.map = \u00dcberschwemmungsfl\u00e4che
diff -r 2b4191f78ea6 -r 1127dbe95083 artifacts/src/main/resources/messages_de_DE.properties
--- a/artifacts/src/main/resources/messages_de_DE.properties	Thu Oct 30 14:20:28 2014 +0100
+++ b/artifacts/src/main/resources/messages_de_DE.properties	Thu Oct 30 15:03:55 2014 +0100
@@ -80,8 +80,6 @@
 
 historical.mode.w = Wasserstandsanalyse
 historical.mode.q = Abflussanalyse
-historical_discharge.wq.curve_range = Abflusskurve {0,date,medium} - {1,date,medium}
-historical_discharge.wq.curve_since = Abflusskurve ab {0,date,medium}
 
 calc.surface.curve = Wasserstand/Wasserspiegellage
 calc.flood.map = \u00dcberschwemmungsfl\u00e4che
diff -r 2b4191f78ea6 -r 1127dbe95083 artifacts/src/main/resources/messages_en.properties
--- a/artifacts/src/main/resources/messages_en.properties	Thu Oct 30 14:20:28 2014 +0100
+++ b/artifacts/src/main/resources/messages_en.properties	Thu Oct 30 15:03:55 2014 +0100
@@ -80,8 +80,6 @@
 
 historical.mode.w = Waterlevel Analyse
 historical.mode.q = Discharge Analyse
-historical_discharge.wq.curve_range = Discharge Curve {0,date,medium} - {1,date,medium}
-historical_discharge.wq.curve_since = Discharge Curve {0,date,medium}
 
 calc.surface.curve = Water Level/Surface Curve
 calc.flood.map = Flood Plain


More information about the Dive4Elements-commits mailing list