Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FlowVelocityFacet.java @ 4629:e29f368c09ba
Removed obsolete import
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Mon, 03 Dec 2012 17:55:04 +0100 |
parents | 5b551e3a58d5 |
children | 63368dcc3f94 |
rev | line source |
---|---|
2706
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifactdatabase.state.Facet; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.artifacts.Artifact; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.artifacts.CallContext; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.flys.artifacts.FLYSArtifact; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
4626
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
10 import de.intevation.flys.artifacts.access.RiverAccess; |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
11 import de.intevation.flys.artifacts.context.FLYSContext; |
2706
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import org.apache.log4j.Logger; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
4483
cc6323401643
Cosmetics: Removed some WSP, obsolete imports. Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4460
diff
changeset
|
16 |
2706
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 /** |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 * Facet of a FlowVelocity curve. |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 */ |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 public class FlowVelocityFacet extends DataFacet { |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 private static Logger logger = Logger.getLogger(FlowVelocityFacet.class); |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 public FlowVelocityFacet() { |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 // required for clone operation deepCopy() |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 } |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 public FlowVelocityFacet( |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 int idx, |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 String name, |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 String description, |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 ComputeType type, |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 String stateId, |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 String hash |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 ) { |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 super(idx, name, description, type, hash, stateId); |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 } |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 public Object getData(Artifact artifact, CallContext context) { |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 logger.debug("Get data for flow velocity at index: " + index); |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
4626
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
44 Double start = (Double)context.getContextValue("startkm"); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
45 Double end = (Double)context.getContextValue("endkm"); |
2706
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 FLYSArtifact flys = (FLYSArtifact) artifact; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 CalculationResult res = (CalculationResult) |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 flys.compute(context, hash, stateId, type, false); |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 FlowVelocityData[] data = (FlowVelocityData[]) res.getData(); |
4626
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
52 if(start != null && end != null) { |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
53 FLYSContext fc = (FLYSContext)context.globalContext(); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
54 ZoomScale scales = (ZoomScale)fc.get("zoomscale"); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
55 RiverAccess access = new RiverAccess((FLYSArtifact)artifact); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
56 String river = access.getRiver(); |
2706
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
4626
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
58 double radius = scales.getRadius(river, start, end); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
59 FlowVelocityData oldData = data[index]; |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
60 FlowVelocityData newData = new FlowVelocityData(); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
61 double[][] q = oldData.getQPoints(); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
62 double[][] totalV = MovingAverage.weighted(oldData.getTotalChannelPoints(), radius); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
63 double[][] mainV = MovingAverage.weighted(oldData.getMainChannelPoints(), radius); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
64 double[][] tau = MovingAverage.weighted(oldData.getTauPoints(), radius); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
65 for(int j = 0; j < q[0].length; j++) { |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
66 newData.addKM(q[0][j]); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
67 newData.addQ(q[1][j]); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
68 newData.addTauMain(tau[1][j]); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
69 newData.addVMain(mainV[1][j]); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
70 newData.addVTotal(totalV[1][j]); |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
71 } |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
72 return newData; |
5b551e3a58d5
Add start and end km of current chart zoomlevel to the context and use these
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
73 } |
2706
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 return data[index]; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 } |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 /** Copy deeply. */ |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 @Override |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 public Facet deepCopy() { |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 FlowVelocityFacet copy = new FlowVelocityFacet(); |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 copy.set(this); |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 copy.type = type; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 copy.hash = hash; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 copy.stateId = stateId; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 return copy; |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 } |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 } |
d8444fcb4e44
Create chart facets for flow velocity calculation and a chart generator for this.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |