changeset 8891:f431aec10d2c

Implemented access to bed measurements
author gernotbelger
date Wed, 14 Feb 2018 19:06:21 +0100
parents 90b7f45ff4ae
children 87a242425467 89f3c5462a16
files artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthFacet.java
diffstat 2 files changed, 37 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java	Wed Feb 14 18:45:42 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthCalculation.java	Wed Feb 14 19:06:21 2018 +0100
@@ -10,8 +10,10 @@
 package org.dive4elements.river.artifacts.sinfo.flowdepth;
 
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 
 import org.apache.commons.math.FunctionEvaluationException;
@@ -24,6 +26,8 @@
 import org.dive4elements.river.artifacts.model.LocationProvider;
 import org.dive4elements.river.artifacts.model.QKms;
 import org.dive4elements.river.artifacts.model.WKms;
+import org.dive4elements.river.artifacts.model.minfo.QualityMeasurementFactory;
+import org.dive4elements.river.artifacts.model.minfo.QualityMeasurements;
 import org.dive4elements.river.artifacts.resources.Resources;
 import org.dive4elements.river.artifacts.sinfo.SINFOArtifact;
 import org.dive4elements.river.artifacts.sinfo.flowdepth.FlowDepthAccess.DifferencesPair;
@@ -39,6 +43,8 @@
 
 class FlowDepthCalculation {
 
+    private static final int VALID_BED_MEASUREMENT_YEARS = 20;
+
     private static final String CSV_NOT_IN_GAUGE_RANGE = "export.waterlevel.csv.not.in.gauge.range";
 
     private final CallContext context;
@@ -136,13 +142,17 @@
             // TODO: keine Berechnung TKH
         }
 
-        // FIXME
-        // - Sohlbeschaffenheit (D50 Korndurchmesser aus Seddb)
-        // - Abhängig von Peiljahr
-        // - kein D50 vorhanden --> Fehler
+        final QualityMeasurements bedMeasurements = getBedMeasurements(river, from, to, sounding.getYear());
+        // FIXME: prüfung ob (genug) werte vorhanden sind? was sind genau die kriterien? falls nein, problemhinzufügen und keine
+        // berechnung tkh
+        // FIXME: wie wird ggf. interpoliert? --> absprache?
+        // FIXME: mir direkt aufgefallen, die Beispieldatenbank liefert Werte zum gleichen km und zeitpunkt, die messwerte sind
+        // aber unterschiedlich....???
+        // FIXME: die eigentlichen daten extrahieren, ggf. wenn esswerte zum gleichen datum voriliegen. das neueste nehmen? oder
+        // das näheste zum Peiljahr?
 
-        // FIXME
-        // - Art der Gewässersohle (starr/mobil)
+        // FIXME Art der Gewässersohle (starr/mobil)
+        // FIXME: wie wird ggf. interpoliert? prüfung ob werte vorhanden?
 
         final String bedHeightLabel = bedHeight.getDescription();
         final String wstLabel = wstKms.getName();
@@ -245,6 +255,25 @@
     }
 
     /**
+     * Sohlbeschaffenheit (D50 Korndurchmesser aus Seddb)
+     * Abhängig von Peiljahr
+     */
+    private QualityMeasurements getBedMeasurements(final River river, final double from, final double to, final int soundingYear) {
+
+        /* construct valid measurement time range */
+        final Calendar cal = Calendar.getInstance();
+        cal.clear();
+
+        cal.set(soundingYear - VALID_BED_MEASUREMENT_YEARS, 0, 1);
+        final Date startTime = cal.getTime();
+
+        cal.set(soundingYear + VALID_BED_MEASUREMENT_YEARS, 11, 31);
+        final Date endTime = cal.getTime();
+
+        return QualityMeasurementFactory.getBedMeasurements(river.getName(), from, to, startTime, endTime);
+    }
+
+    /**
      * Checks the year difference between waterlevels and sounding, and issues a warning if too big.
      *
      * Zeitraum Zeitliche Differenz [a]
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthFacet.java	Wed Feb 14 18:45:42 2018 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthFacet.java	Wed Feb 14 19:06:21 2018 +0100
@@ -47,41 +47,13 @@
 
         final FlowDepthCalculationResults data = (FlowDepthCalculationResults) res.getData();
 
-        final FlowDepthCalculationResult result = data.getResults().get(this.index);
-
-        // FIXME: variable mean computation depending on current scale
-
-        // Double start = (Double)context.getContextValue("startkm");
-        // Double end = (Double)context.getContextValue("endkm");
-        // if(start != null && end != null) {
-        // RiverContext fc = (RiverContext)context.globalContext();
-        // ZoomScale scales = (ZoomScale)fc.get("zoomscale");
-        // RiverAccess access = new RiverAccess((D4EArtifact)artifact);
-        // String river = access.getRiverName();
-        //
-        // double radius = scales.getRadius(river, start, end);
-        // FlowVelocityData oldData = data[index];
-        // FlowVelocityData newData = new FlowVelocityData();
-        // double[][] q = oldData.getQPoints();
-        // double[][] totalV = MovingAverage.weighted(oldData.getTotalChannelPoints(), radius);
-        // double[][] mainV = MovingAverage.weighted(oldData.getMainChannelPoints(), radius);
-        // double[][] tau = MovingAverage.weighted(oldData.getTauPoints(), radius);
-        // for(int j = 0; j < q[0].length; j++) {
-        // newData.addKM(q[0][j]);
-        // newData.addQ(q[1][j]);
-        // newData.addTauMain(tau[1][j]);
-        // newData.addVMain(mainV[1][j]);
-        // newData.addVTotal(totalV[1][j]);
-        // }
-        // return newData;
-        // }
-
-        return result;
+        return data.getResults().get(this.index);
     }
 
     /** Copy deeply. */
     @Override
     public Facet deepCopy() {
+        // FIXME: why not simply use the full constructor instead?
         final FlowDepthFacet copy = new FlowDepthFacet();
         // FIXME: why does DataFacet does not override set? Bad access to variables of parent!
         copy.set(this);

http://dive4elements.wald.intevation.org