annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/GaugeDischargeCurveFacet.java @ 4040:363445873737

Documentation.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 05 Oct 2012 10:09:07 +0200
parents a5e1ca620f15
children 21f4e4b79121
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
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
9 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
10 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
11
3986
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
12 import de.intevation.flys.artifacts.FLYSArtifact;
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
13
3936
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
14 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
15
3986
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
16 import de.intevation.flys.utils.FLYSUtils;
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
17
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
18 import org.apache.log4j.Logger;
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
19
3936
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
20 /**
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
21 * 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
22 *
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
23 * @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
24 */
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
25 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
26 extends DefaultFacet
4032
a5e1ca620f15 Add description and set correct name for GaugeDischargeCurveFacet
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3986
diff changeset
27 implements FacetTypes
3936
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
28 {
3986
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
29 private static final Logger log =
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
30 Logger.getLogger(GaugeDischargeCurveFacet.class);
3936
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
31
4032
a5e1ca620f15 Add description and set correct name for GaugeDischargeCurveFacet
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3986
diff changeset
32 public GaugeDischargeCurveFacet(String description) {
a5e1ca620f15 Add description and set correct name for GaugeDischargeCurveFacet
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3986
diff changeset
33 super(0, GAUGE_DISCHARGE_CURVE, description);
3936
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
34 }
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
35
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
36 @Override
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
37 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
38
3986
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
39 if (!(art instanceof FLYSArtifact)) {
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
40 log.warn("Invalid artifact type");
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
41 return null;
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
42 }
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
43
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
44 FLYSArtifact flys = (FLYSArtifact)art;
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
45
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
46 String river = flys.getDataAsString("river");
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
47
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
48 Gauge gauge = FLYSUtils.getReferenceGauge(flys);
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
49
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
50 if (river == null || gauge == null) {
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
51 log.warn("Unknown river or gauge");
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
52 return null;
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
53 }
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
54
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
55 String name = gauge.getName();
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
56
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
57 DischargeTables dt = new DischargeTables(river, name);
3936
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
58
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
59 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
60
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
61 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
62 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
63 return null;
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
64 }
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
65 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
66 Arrays.fill(kms, gauge.getStation().doubleValue());
3986
b7bdef1831ac Removed heavy weight data from the gauge discharge curve facet.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3985
diff changeset
67 return new WQKms(kms, values[0], values[1], name);
3936
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
68 }
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
69
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
70 @Override
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
71 public Facet deepCopy() {
4032
a5e1ca620f15 Add description and set correct name for GaugeDischargeCurveFacet
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3986
diff changeset
72 GaugeDischargeCurveFacet copy = new GaugeDischargeCurveFacet(
a5e1ca620f15 Add description and set correct name for GaugeDischargeCurveFacet
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3986
diff changeset
73 this.description);
3936
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
74 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
75 return copy;
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
76 }
4e1b3b4ef132 Add new Artifacts and State for displaying discharge curves at a gauge
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
77 }

http://dive4elements.wald.intevation.org