Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
8853:8c64617a7991 | 8854:7bbfb24e6eec |
---|---|
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 FlowDepthFilterFacet extends DataFacet { | |
24 | |
25 private static Logger log = Logger.getLogger(FlowDepthFilterFacet.class); | |
26 | |
27 public FlowDepthFilterFacet() { | |
28 // required for clone operation deepCopy() | |
29 } | |
30 | |
31 public FlowDepthFilterFacet( | |
32 int idx, | |
33 String name, | |
34 String description, | |
35 ComputeType type, | |
36 String stateId, | |
37 String hash | |
38 ) { | |
39 super(idx, name, description, type, hash, stateId); | |
40 this.metaData.put("X", "sinfo.chart.flow_depth.xaxis.label"); | |
41 this.metaData.put("Y", "sinfo.chart.flow_depth.yaxis.label"); | |
42 } | |
43 | |
44 @Override | |
45 public Object getData(Artifact artifact, CallContext context) { | |
46 log.debug("Get data for flow velocity at index: " + index); | |
47 | |
48 final D4EArtifact flys = (D4EArtifact) artifact; | |
49 | |
50 final CalculationResult res = (CalculationResult) | |
51 flys.compute(context, hash, stateId, type, false); | |
52 | |
53 final FlowDepthCalculationResults data = (FlowDepthCalculationResults) res.getData(); | |
54 | |
55 final FlowDepthCalculationResult result = data.getResults().get(index); | |
56 | |
57 // FIXME: variable mean computation depending on current scale | |
58 // Double start = (Double)context.getContextValue("startkm"); | |
59 // Double end = (Double)context.getContextValue("endkm"); | |
60 // if(start != null && end != null) { | |
61 // RiverContext fc = (RiverContext)context.globalContext(); | |
62 // ZoomScale scales = (ZoomScale)fc.get("zoomscale"); | |
63 // RiverAccess access = new RiverAccess((D4EArtifact)artifact); | |
64 // String river = access.getRiverName(); | |
65 // | |
66 // double radius = scales.getRadius(river, start, end); | |
67 // FlowVelocityData oldData = data[index]; | |
68 // FlowVelocityData newData = new FlowVelocityData(); | |
69 // double[][] q = oldData.getQPoints(); | |
70 // double[][] totalV = MovingAverage.weighted(oldData.getTotalChannelPoints(), radius); | |
71 // double[][] mainV = MovingAverage.weighted(oldData.getMainChannelPoints(), radius); | |
72 // double[][] tau = MovingAverage.weighted(oldData.getTauPoints(), radius); | |
73 // for(int j = 0; j < q[0].length; j++) { | |
74 // newData.addKM(q[0][j]); | |
75 // newData.addQ(q[1][j]); | |
76 // newData.addTauMain(tau[1][j]); | |
77 // newData.addVMain(mainV[1][j]); | |
78 // newData.addVTotal(totalV[1][j]); | |
79 // } | |
80 // return newData; | |
81 // } | |
82 | |
83 return result; | |
84 } | |
85 | |
86 | |
87 /** Copy deeply. */ | |
88 @Override | |
89 public Facet deepCopy() { | |
90 FlowDepthFilterFacet copy = new FlowDepthFilterFacet(); | |
91 // FIXME: why does DataFacet does not override set? Bad access to variables of parent! | |
92 copy.set(this); | |
93 copy.type = type; | |
94 copy.hash = hash; | |
95 copy.stateId = stateId; | |
96 return copy; | |
97 } | |
98 } |