changeset 7525:6650485c2c9b

Part fix for flys/issue1585: Use result from fitting to display interpolated W/Q points, too. TODO: Draw interpolated as circles.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 06 Nov 2013 19:12:46 +0100
parents 25d890e3eb69
children a836adfaccc6
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java
diffstat 4 files changed, 45 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java	Wed Nov 06 12:07:48 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixAnalysisCalculation.java	Wed Nov 06 19:12:46 2013 +0100
@@ -102,9 +102,6 @@
             analysisPeriods);
 
         // Workaraound to deal with same dates in data set
-        far.makeReferenceEventsDatesUnique();
-        far.remapReferenceIndicesToRank();
-
         far.makeAnalysisEventsUnique();
         for (int i = 0; i < this.analysisPeriods.length; ++i) {
             far.remapAnalysisEventsIndicesToRank(i);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixCalculation.java	Wed Nov 06 12:07:48 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixCalculation.java	Wed Nov 06 19:12:46 2013 +0100
@@ -428,8 +428,19 @@
         if (hasProblems()) {
             return new CalculationResult(this);
         }
+        CalculationResult result = innerCalculate(overview, func);
 
-        return innerCalculate(overview, func);
+        if (result != null) {
+            // Workaraound to deal with same dates in data set
+            Object o = result.getData();
+            if (o instanceof FixResult) {
+                FixResult fr = (FixResult)o;
+                fr.makeReferenceEventsDatesUnique();
+                fr.remapReferenceIndicesToRank();
+            }
+        }
+
+        return result;
     }
 
     protected abstract CalculationResult innerCalculate(
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java	Wed Nov 06 12:07:48 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java	Wed Nov 06 19:12:46 2013 +0100
@@ -8,6 +8,9 @@
 
 package org.dive4elements.river.artifacts.states.fixation;
 
+import java.text.DateFormat;
+import java.util.Collection;
+import java.util.Date;
 import java.util.List;
 
 import org.apache.log4j.Logger;
@@ -24,15 +27,16 @@
 import org.dive4elements.river.artifacts.model.ReportFacet;
 import org.dive4elements.river.artifacts.model.WQCKms;
 import org.dive4elements.river.artifacts.model.WQKms;
-import org.dive4elements.river.artifacts.model.WQKmsFactory;
 import org.dive4elements.river.artifacts.model.fixings.FixOutlierFacet;
 import org.dive4elements.river.artifacts.model.fixings.FixRealizingCalculation;
 import org.dive4elements.river.artifacts.model.fixings.FixRealizingResult;
-import org.dive4elements.river.artifacts.model.fixings.FixEventFacet;
+import org.dive4elements.river.artifacts.model.fixings.FixReferenceEventsFacet;
 import org.dive4elements.river.artifacts.model.fixings.FixWQCurveFacet;
 import org.dive4elements.river.artifacts.model.fixings.FixWaterlevelFacet;
 import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.artifacts.states.DefaultState;
+import org.dive4elements.river.utils.Formatter;
+import org.dive4elements.river.utils.UniqueDateFormatter;
 
 /**
  * State to compute the fixation realizing (vollmer) results.
@@ -48,9 +52,6 @@
 
     public static final String I18N_WQ_OUTLIER = "fix.vollmer.wq.outliers";
 
-    public static final String I18N_WQ_EVENTS = "fix.vollmer.wq.events";
-
-
     /**
      * The default constructor that initializes an empty State object.
      */
@@ -122,6 +123,7 @@
             facets.add(q);
             facets.add(csFacet);
 
+            // XXX: THIS CAN NOT HAPPEN! REMOVE IT!
             if (wqkms[i] instanceof WQCKms) {
                 String nameC = nameW.replace(
                     "benutzerdefiniert",
@@ -134,10 +136,18 @@
             }
         }
 
-        // Add one facet per event.
+        DateFormat df = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy");
+        DateFormat lf = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy'T'HH:mm");
+
+        Collection<Date> reds = fixRes.getReferenceEventsDates();
+        UniqueDateFormatter cf = new UniqueDateFormatter(df, lf, reds);
+
         int i = 0;
-        for (int event: access.getEvents()) {
-            facets.add(new FixEventFacet(i, FIX_EVENTS, WQKmsFactory.getWQKmsName(event)));
+        for (Date d: reds) {
+            facets.add(new FixReferenceEventsFacet(
+                (1 << 9) | i,
+                FIX_EVENTS,
+                cf.format(d)));
             i++;
         }
 
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java	Wed Nov 06 12:07:48 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java	Wed Nov 06 19:12:46 2013 +0100
@@ -155,12 +155,13 @@
 
     /** Returns value != 0 if the current km is not at a gauge. */
     public double getCurrentGaugeDatum() {
-        if (context.getContextValue(CURRENT_KM) != null) {
+        Object ckm = context.getContextValue(CURRENT_KM);
+        if (ckm != null) {
             return DischargeCurveGenerator.getCurrentGaugeDatum(
-                (Double) context.getContextValue(CURRENT_KM),
+                (Double) ckm,
                 (D4EArtifact) getMaster(), 1e-4);
         }
-        else return 0d;
+        return 0d;
     }
 
     /** Overriden to show second axis also if no visible data present. */
@@ -196,7 +197,8 @@
         else if(FIX_ANALYSIS_EVENTS_WQ.equals(name)) {
             doAnalysisEventsOut(aaf, doc, visible);
         }
-        else if(FIX_REFERENCE_EVENTS_WQ.equals(name)) {
+        else if(FIX_REFERENCE_EVENTS_WQ.equals(name)
+             || FIX_EVENTS.equals(name)) {
             doReferenceEventsOut(aaf, doc, visible);
         }
         else if(FIX_WQ_CURVE.equals(name)) {
@@ -208,9 +210,11 @@
         else if(QSECTOR.equals(name)) {
             doQSectorOut(aaf, doc, visible);
         }
+        /*
         else if(FIX_EVENTS.equals(name)) {
             doEventsOut(aaf, doc, visible);
         }
+        */
         else if(/*STATIC_WKMS_INTERPOL.equals(name) ||*/
                 STATIC_WKMS_MARKS.equals(name) ||
                 STATIC_WKMS.equals(name) ||
@@ -227,7 +231,7 @@
             doWQOut(aaf.getData(context), aaf, doc, visible);
         }
         else if (name.equals(DISCHARGE_CURVE)) {
-        logger.debug("diso " + name);
+            logger.debug("diso " + name);
             doDischargeOut(
                     (WINFOArtifact) aaf.getArtifact(),
                     aaf.getData(context),
@@ -431,8 +435,9 @@
                         maxQ); // end
                 addAxisSeries(series2, YAXIS.W.idx, false);
                 // Use second axis at cm if at gauge.
-                for (int i = 0; i < series.getItemCount(); i++) {
-                    series.updateByIndex(i, new Double(100d*(series.getY(i).doubleValue()-gaugeDatum)));
+                for (int i = 0, N = series.getItemCount(); i < N; i++) {
+                    series.updateByIndex(
+                        i, new Double(100d*(series.getY(i).doubleValue()-gaugeDatum)));
                 }
                 addAxisSeries(series, YAXIS.WCm.idx, visible);
             }
@@ -758,10 +763,9 @@
     protected String getDefaultYAxisLabel(int pos) {
         D4EArtifact flys = (D4EArtifact) master;
 
-        String unit = RiverUtils.getRiver(flys).getWstUnit().getName();
-        if (pos == 0) {
-            unit = "cm";
-        }
+        String unit = pos == 0
+            ? "cm"
+            : RiverUtils.getRiver(flys).getWstUnit().getName();
 
         return msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT, new Object[] { unit });
     }

http://dive4elements.wald.intevation.org