comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FlowVelocityFacet.java @ 4626:5b551e3a58d5

Add start and end km of current chart zoomlevel to the context and use these values to calculate the moving average.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 03 Dec 2012 17:10:08 +0100
parents cc6323401643
children 63368dcc3f94
comparison
equal deleted inserted replaced
4625:d6d16b5ab2f0 4626:5b551e3a58d5
5 import de.intevation.artifacts.Artifact; 5 import de.intevation.artifacts.Artifact;
6 import de.intevation.artifacts.CallContext; 6 import de.intevation.artifacts.CallContext;
7 7
8 import de.intevation.flys.artifacts.FLYSArtifact; 8 import de.intevation.flys.artifacts.FLYSArtifact;
9 9
10 import de.intevation.flys.artifacts.access.RiverAccess;
11 import de.intevation.flys.artifacts.context.FLYSContext;
10 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; 12 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
11 13
12 import org.apache.log4j.Logger; 14 import org.apache.log4j.Logger;
13 15
14 16
37 39
38 40
39 public Object getData(Artifact artifact, CallContext context) { 41 public Object getData(Artifact artifact, CallContext context) {
40 logger.debug("Get data for flow velocity at index: " + index); 42 logger.debug("Get data for flow velocity at index: " + index);
41 43
44 Double start = (Double)context.getContextValue("startkm");
45 Double end = (Double)context.getContextValue("endkm");
42 FLYSArtifact flys = (FLYSArtifact) artifact; 46 FLYSArtifact flys = (FLYSArtifact) artifact;
43 47
44 CalculationResult res = (CalculationResult) 48 CalculationResult res = (CalculationResult)
45 flys.compute(context, hash, stateId, type, false); 49 flys.compute(context, hash, stateId, type, false);
46 50
47 FlowVelocityData[] data = (FlowVelocityData[]) res.getData(); 51 FlowVelocityData[] data = (FlowVelocityData[]) res.getData();
52 if(start != null && end != null) {
53 FLYSContext fc = (FLYSContext)context.globalContext();
54 ZoomScale scales = (ZoomScale)fc.get("zoomscale");
55 RiverAccess access = new RiverAccess((FLYSArtifact)artifact);
56 String river = access.getRiver();
48 57
58 double radius = scales.getRadius(river, start, end);
59 FlowVelocityData oldData = data[index];
60 FlowVelocityData newData = new FlowVelocityData();
61 double[][] q = oldData.getQPoints();
62 double[][] totalV = MovingAverage.weighted(oldData.getTotalChannelPoints(), radius);
63 double[][] mainV = MovingAverage.weighted(oldData.getMainChannelPoints(), radius);
64 double[][] tau = MovingAverage.weighted(oldData.getTauPoints(), radius);
65 for(int j = 0; j < q[0].length; j++) {
66 newData.addKM(q[0][j]);
67 newData.addQ(q[1][j]);
68 newData.addTauMain(tau[1][j]);
69 newData.addVMain(mainV[1][j]);
70 newData.addVTotal(totalV[1][j]);
71 }
72 return newData;
73 }
49 return data[index]; 74 return data[index];
50 } 75 }
51 76
52 77
53 /** Copy deeply. */ 78 /** Copy deeply. */

http://dive4elements.wald.intevation.org