Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffHeightSubFilterFacet.java @ 7985:10debf4b82be facet-metadata
Split bed differences facet into data specific facets.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 01 Jul 2014 15:09:56 +0200 |
parents | |
children | 9f42d161886b |
comparison
equal
deleted
inserted
replaced
7984:cf674b03901a | 7985:10debf4b82be |
---|---|
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.model.minfo; | |
10 | |
11 import org.apache.log4j.Logger; | |
12 | |
13 import org.dive4elements.artifactdatabase.state.Facet; | |
14 import org.dive4elements.artifacts.Artifact; | |
15 import org.dive4elements.artifacts.CallContext; | |
16 import org.dive4elements.river.artifacts.D4EArtifact; | |
17 import org.dive4elements.river.artifacts.access.RiverAccess; | |
18 import org.dive4elements.river.artifacts.context.RiverContext; | |
19 import org.dive4elements.river.artifacts.model.CalculationResult; | |
20 import org.dive4elements.river.artifacts.model.DataFacet; | |
21 import org.dive4elements.river.artifacts.math.MovingAverage; | |
22 import org.dive4elements.river.artifacts.model.ZoomScale; | |
23 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | |
24 | |
25 | |
26 public class BedDiffHeightSubFilterFacet | |
27 extends DataFacet | |
28 { | |
29 private static Logger logger = Logger.getLogger(BedDiffHeightSubFilterFacet.class); | |
30 | |
31 public BedDiffHeightSubFilterFacet() { | |
32 } | |
33 | |
34 public BedDiffHeightSubFilterFacet(int idx, String name, String description, | |
35 ComputeType type, String stateId, String hash) { | |
36 super(idx, name, description, type, hash, stateId); | |
37 this.metaData.put("X", "chart.longitudinal.section.xaxis.label"); | |
38 this.metaData.put("Y", "chart.beddifference.height.yaxis.label"); | |
39 } | |
40 | |
41 public Object getData(Artifact artifact, CallContext context) { | |
42 logger.debug("Get data for bed density at index: " + index); | |
43 | |
44 D4EArtifact flys = (D4EArtifact) artifact; | |
45 | |
46 CalculationResult res = (CalculationResult) flys.compute(context, hash, | |
47 stateId, type, false); | |
48 | |
49 BedDiffYearResult[] data = | |
50 (BedDiffYearResult[]) res.getData(); // TODO CAST TO SPECIFIC CLASS | |
51 Double start = (Double)context.getContextValue("startkm"); | |
52 Double end = (Double)context.getContextValue("endkm"); | |
53 if(start != null && end != null) { | |
54 RiverContext fc = (RiverContext)context.globalContext(); | |
55 // Adaptive smoothing, based on zoom factor/diagram extents. | |
56 ZoomScale scales = (ZoomScale)fc.get("zoomscale"); | |
57 RiverAccess access = new RiverAccess((D4EArtifact)artifact); | |
58 String river = access.getRiverName(); | |
59 | |
60 double radius = scales.getRadius(river, start, end); | |
61 BedDiffYearResult oldData = data[index]; | |
62 double[][] heights = MovingAverage.weighted(oldData.getHeights2Data(), radius); | |
63 return heights; | |
64 } | |
65 return null; | |
66 } | |
67 | |
68 /** Copy deeply. */ | |
69 @Override | |
70 public Facet deepCopy() { | |
71 BedDiffHeightSubFilterFacet copy = new BedDiffHeightSubFilterFacet(); | |
72 copy.set(this); | |
73 copy.type = type; | |
74 copy.hash = hash; | |
75 copy.stateId = stateId; | |
76 return copy; | |
77 } | |
78 } | |
79 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |