comparison 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
comparison
equal deleted inserted replaced
8883:a536e1aacf0f 8884:7a8c12706834
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU AGPL (>=v3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6 * documentation coming with Dive4Elements River for details.
7 */
8
9 package org.dive4elements.river.artifacts.sinfo.flowdepth;
10
11 import org.apache.log4j.Logger;
12 import org.dive4elements.artifactdatabase.state.Facet;
13 import org.dive4elements.artifacts.Artifact;
14 import org.dive4elements.artifacts.CallContext;
15 import org.dive4elements.river.artifacts.D4EArtifact;
16 import org.dive4elements.river.artifacts.model.CalculationResult;
17 import org.dive4elements.river.artifacts.model.DataFacet;
18 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
19
20 /**
21 * Facet of a FlowDepth curve.
22 */
23 public class FlowDepthFacet extends DataFacet {
24
25 private static final long serialVersionUID = 1L;
26
27 private static Logger log = Logger.getLogger(FlowDepthFacet.class);
28
29 public FlowDepthFacet() {
30 // required for clone operation deepCopy()
31 }
32
33 public FlowDepthFacet(final int idx, final String name, final String description, final String yAxisLabelKey, final ComputeType type, final String stateId,
34 final String hash) {
35 super(idx, name, description, type, hash, stateId);
36 this.metaData.put("X", "sinfo.chart.flow_depth.xaxis.label");
37 this.metaData.put("Y", yAxisLabelKey);
38 }
39
40 @Override
41 public Object getData(final Artifact artifact, final CallContext context) {
42 log.debug("Get data for flow velocity at index: " + this.index);
43
44 final D4EArtifact flys = (D4EArtifact) artifact;
45
46 final CalculationResult res = (CalculationResult) flys.compute(context, this.hash, this.stateId, this.type, false);
47
48 final FlowDepthCalculationResults data = (FlowDepthCalculationResults) res.getData();
49
50 final FlowDepthCalculationResult result = data.getResults().get(this.index);
51
52 // FIXME: variable mean computation depending on current scale
53
54 // Double start = (Double)context.getContextValue("startkm");
55 // Double end = (Double)context.getContextValue("endkm");
56 // if(start != null && end != null) {
57 // RiverContext fc = (RiverContext)context.globalContext();
58 // ZoomScale scales = (ZoomScale)fc.get("zoomscale");
59 // RiverAccess access = new RiverAccess((D4EArtifact)artifact);
60 // String river = access.getRiverName();
61 //
62 // double radius = scales.getRadius(river, start, end);
63 // FlowVelocityData oldData = data[index];
64 // FlowVelocityData newData = new FlowVelocityData();
65 // double[][] q = oldData.getQPoints();
66 // double[][] totalV = MovingAverage.weighted(oldData.getTotalChannelPoints(), radius);
67 // double[][] mainV = MovingAverage.weighted(oldData.getMainChannelPoints(), radius);
68 // double[][] tau = MovingAverage.weighted(oldData.getTauPoints(), radius);
69 // for(int j = 0; j < q[0].length; j++) {
70 // newData.addKM(q[0][j]);
71 // newData.addQ(q[1][j]);
72 // newData.addTauMain(tau[1][j]);
73 // newData.addVMain(mainV[1][j]);
74 // newData.addVTotal(totalV[1][j]);
75 // }
76 // return newData;
77 // }
78
79 return result;
80 }
81
82 /** Copy deeply. */
83 @Override
84 public Facet deepCopy() {
85 final FlowDepthFacet copy = new FlowDepthFacet();
86 // FIXME: why does DataFacet does not override set? Bad access to variables of parent!
87 copy.set(this);
88 copy.type = this.type;
89 copy.hash = this.hash;
90 copy.stateId = this.stateId;
91 return copy;
92 }
93 }

http://dive4elements.wald.intevation.org