8854
|
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 */ |
8884
|
23 public class FlowDepthFacet extends DataFacet { |
8854
|
24 |
8884
|
25 private static final long serialVersionUID = 1L; |
8854
|
26 |
8884
|
27 private static Logger log = Logger.getLogger(FlowDepthFacet.class); |
|
28 |
|
29 public FlowDepthFacet() { |
8854
|
30 // required for clone operation deepCopy() |
|
31 } |
|
32 |
8884
|
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) { |
8854
|
35 super(idx, name, description, type, hash, stateId); |
|
36 this.metaData.put("X", "sinfo.chart.flow_depth.xaxis.label"); |
8884
|
37 this.metaData.put("Y", yAxisLabelKey); |
8854
|
38 } |
|
39 |
|
40 @Override |
8884
|
41 public Object getData(final Artifact artifact, final CallContext context) { |
|
42 log.debug("Get data for flow velocity at index: " + this.index); |
8854
|
43 |
|
44 final D4EArtifact flys = (D4EArtifact) artifact; |
|
45 |
8884
|
46 final CalculationResult res = (CalculationResult) flys.compute(context, this.hash, this.stateId, this.type, false); |
8854
|
47 |
|
48 final FlowDepthCalculationResults data = (FlowDepthCalculationResults) res.getData(); |
8884
|
49 |
|
50 final FlowDepthCalculationResult result = data.getResults().get(this.index); |
8854
|
51 |
|
52 // FIXME: variable mean computation depending on current scale |
|
53 |
8884
|
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; |
8854
|
80 } |
|
81 |
|
82 /** Copy deeply. */ |
|
83 @Override |
|
84 public Facet deepCopy() { |
8884
|
85 final FlowDepthFacet copy = new FlowDepthFacet(); |
8854
|
86 // FIXME: why does DataFacet does not override set? Bad access to variables of parent! |
|
87 copy.set(this); |
8884
|
88 copy.type = this.type; |
|
89 copy.hash = this.hash; |
|
90 copy.stateId = this.stateId; |
8854
|
91 return copy; |
|
92 } |
|
93 } |