Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeDischargeCurveFacet.java @ 3966:0a56dbf81cc6
dummy merge for repo head
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:15:30 +0200 |
parents | 4e1b3b4ef132 |
children | a4930c43b806 |
rev | line source |
---|---|
3936
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
2 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
3 import java.util.Arrays; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
4 import java.util.Map; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
5 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.artifacts.Artifact; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.CallContext; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.CallMeta; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
9 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifactdatabase.state.DefaultFacet; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifactdatabase.state.Facet; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
12 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.flys.artifacts.model.WQKms; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
14 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.model.Gauge; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
16 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
17 /** |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
18 * A Facet that returns discharge curve data at a gauge |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
19 * |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
20 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
21 */ |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
22 public class GaugeDischargeCurveFacet |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
23 extends DefaultFacet |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
24 { |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
25 private Gauge gauge; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
26 private String river; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
27 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
28 public GaugeDischargeCurveFacet(String river, Gauge gauge) { |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
29 super(0, "facet.gauge.discharge_curve", "facet.gauge.discharge_curve"); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
30 this.river = river; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
31 this.gauge = gauge; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
32 } |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
33 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
34 @Override |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
35 public Object getData(Artifact art, CallContext context) { |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
36 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
37 DischargeTables dt = new DischargeTables(river, gauge.getName()); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
38 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
39 Map<String, double [][]> map = dt.getValues(100d); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
40 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
41 double [][] values = map.get(name); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
42 if (values == null) { |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
43 return null; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
44 } |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
45 double [] kms = new double[values[0].length]; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
46 Arrays.fill(kms, gauge.getStation().doubleValue()); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
47 return new WQKms(kms, values[0], values[1], gauge.getName()); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
48 } |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
49 |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
50 @Override |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
51 public Facet deepCopy() { |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
52 GaugeDischargeCurveFacet copy = |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
53 new GaugeDischargeCurveFacet(this.river, this.gauge); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
54 copy.set(this); |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
55 return copy; |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
56 } |
4e1b3b4ef132
Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff
changeset
|
57 } |