diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthFilterFacet.java @ 8854:7bbfb24e6eec

SINFO - first prototype of BArt Fließtiefen
author gernotbelger
date Thu, 18 Jan 2018 18:34:41 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthFilterFacet.java	Thu Jan 18 18:34:41 2018 +0100
@@ -0,0 +1,98 @@
+/* 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.sinfo.flowdepth;
+
+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.model.CalculationResult;
+import org.dive4elements.river.artifacts.model.DataFacet;
+import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
+
+/**
+ * Facet of a FlowDepth curve.
+ */
+public class FlowDepthFilterFacet extends DataFacet {
+
+    private static Logger log = Logger.getLogger(FlowDepthFilterFacet.class);
+
+    public FlowDepthFilterFacet() {
+        // required for clone operation deepCopy()
+    }
+
+    public FlowDepthFilterFacet(
+        int         idx,
+        String      name,
+        String      description,
+        ComputeType type,
+        String      stateId,
+        String      hash
+    ) {
+        super(idx, name, description, type, hash, stateId);
+        this.metaData.put("X", "sinfo.chart.flow_depth.xaxis.label");
+        this.metaData.put("Y", "sinfo.chart.flow_depth.yaxis.label");
+    }
+
+    @Override
+    public Object getData(Artifact artifact, CallContext context) {
+        log.debug("Get data for flow velocity at index: " + index);
+
+        final D4EArtifact flys = (D4EArtifact) artifact;
+
+        final CalculationResult res = (CalculationResult)
+            flys.compute(context, hash, stateId, type, false);
+
+        final FlowDepthCalculationResults data = (FlowDepthCalculationResults) res.getData();
+        
+        final FlowDepthCalculationResult result = data.getResults().get(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;
+    }
+
+
+    /** Copy deeply. */
+    @Override
+    public Facet deepCopy() {
+        FlowDepthFilterFacet copy = new FlowDepthFilterFacet();
+        // FIXME: why does DataFacet does not override set? Bad access to variables of parent!
+        copy.set(this);
+        copy.type    = type;
+        copy.hash    = hash;
+        copy.stateId = stateId;
+        return copy;
+    }
+}
\ No newline at end of file

http://dive4elements.wald.intevation.org