Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthFacet.java @ 8884:7a8c12706834
Work on SINFO-FlowDepth
author | gernotbelger |
---|---|
date | Tue, 13 Feb 2018 14:53:23 +0100 |
parents | artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowDepthFilterFacet.java@7bbfb24e6eec |
children | f431aec10d2c |
line wrap: on
line source
/* 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 FlowDepthFacet extends DataFacet { private static final long serialVersionUID = 1L; private static Logger log = Logger.getLogger(FlowDepthFacet.class); public FlowDepthFacet() { // required for clone operation deepCopy() } public FlowDepthFacet(final int idx, final String name, final String description, final String yAxisLabelKey, final ComputeType type, final String stateId, final String hash) { super(idx, name, description, type, hash, stateId); this.metaData.put("X", "sinfo.chart.flow_depth.xaxis.label"); this.metaData.put("Y", yAxisLabelKey); } @Override public Object getData(final Artifact artifact, final CallContext context) { log.debug("Get data for flow velocity at index: " + this.index); final D4EArtifact flys = (D4EArtifact) artifact; final CalculationResult res = (CalculationResult) flys.compute(context, this.hash, this.stateId, this.type, false); 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; } /** Copy deeply. */ @Override public Facet deepCopy() { final FlowDepthFacet copy = new FlowDepthFacet(); // FIXME: why does DataFacet does not override set? Bad access to variables of parent! copy.set(this); copy.type = this.type; copy.hash = this.hash; copy.stateId = this.stateId; return copy; } }