Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedDiffEpochFacet.java @ 4639:79827cd334d5
Use moving average algorithm to calculate average values depending on the zoom
level.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Tue, 04 Dec 2012 15:41:02 +0100 |
parents | 95d699c769fb |
children | e3f28be45103 |
comparison
equal
deleted
inserted
replaced
4638:6122ee2ab67f | 4639:79827cd334d5 |
---|---|
4 | 4 |
5 import de.intevation.artifactdatabase.state.Facet; | 5 import de.intevation.artifactdatabase.state.Facet; |
6 import de.intevation.artifacts.Artifact; | 6 import de.intevation.artifacts.Artifact; |
7 import de.intevation.artifacts.CallContext; | 7 import de.intevation.artifacts.CallContext; |
8 import de.intevation.flys.artifacts.FLYSArtifact; | 8 import de.intevation.flys.artifacts.FLYSArtifact; |
9 import de.intevation.flys.artifacts.access.RiverAccess; | |
10 import de.intevation.flys.artifacts.context.FLYSContext; | |
9 import de.intevation.flys.artifacts.model.CalculationResult; | 11 import de.intevation.flys.artifacts.model.CalculationResult; |
10 import de.intevation.flys.artifacts.model.DataFacet; | 12 import de.intevation.flys.artifacts.model.DataFacet; |
13 import de.intevation.flys.artifacts.model.MovingAverage; | |
14 import de.intevation.flys.artifacts.model.ZoomScale; | |
11 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | 15 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
12 | 16 |
13 | 17 |
14 public class BedDiffEpochFacet | 18 public class BedDiffEpochFacet |
15 extends DataFacet | 19 extends DataFacet |
30 FLYSArtifact flys = (FLYSArtifact) artifact; | 34 FLYSArtifact flys = (FLYSArtifact) artifact; |
31 | 35 |
32 CalculationResult res = (CalculationResult) flys.compute(context, hash, | 36 CalculationResult res = (CalculationResult) flys.compute(context, hash, |
33 stateId, type, false); | 37 stateId, type, false); |
34 | 38 |
35 Object[] data = | 39 BedDiffEpochResult[] data = |
36 (BedDiffEpochResult[]) res.getData(); // TODO CAST TO SPECIFIC CLASS | 40 (BedDiffEpochResult[]) res.getData(); // TODO CAST TO SPECIFIC CLASS |
41 Double start = (Double)context.getContextValue("startkm"); | |
42 Double end = (Double)context.getContextValue("endkm"); | |
37 | 43 |
44 if(start != null && end != null) { | |
45 FLYSContext fc = (FLYSContext)context.globalContext(); | |
46 ZoomScale scales = (ZoomScale)fc.get("zoomscale"); | |
47 RiverAccess access = new RiverAccess((FLYSArtifact)artifact); | |
48 String river = access.getRiver(); | |
49 | |
50 double radius = scales.getRadius(river, start, end); | |
51 BedDiffEpochResult oldData = data[index]; | |
52 BedDiffEpochResult newData = new BedDiffEpochResult(); | |
53 newData.setStart(oldData.getStart()); | |
54 newData.setEnd(oldData.getEnd()); | |
55 double[][] diffs = MovingAverage.weighted(oldData.getDifferencesData(), radius); | |
56 double[][] heights1 = MovingAverage.weighted(oldData.getHeights1Data(), radius); | |
57 double[][] heights2 = MovingAverage.weighted(oldData.getHeights2Data(), radius); | |
58 for(int j = 0; j < diffs[0].length; j++) { | |
59 newData.addKm(diffs[0][j]); | |
60 newData.addDifference(diffs[1][j]); | |
61 newData.addHeight1(heights1[1][j]); | |
62 newData.addHeight2(heights2[1][j]); | |
63 } | |
64 return newData; | |
65 } | |
38 return data != null && data.length > index ? data[index] : null; | 66 return data != null && data.length > index ? data[index] : null; |
39 } | 67 } |
40 | 68 |
41 /** Copy deeply. */ | 69 /** Copy deeply. */ |
42 @Override | 70 @Override |