annotate artifacts/src/main/java/org/dive4elements/river/artifacts/GaugeDischargeArtifact.java @ 8202:e4606eae8ea5

sed src/**/*.java 's/logger/log/g'
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 05 Sep 2014 12:58:17 +0200
parents d3a4b0d5bcd8
children c494f9a61490
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
9 package org.dive4elements.river.artifacts;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import java.util.ArrayList;
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
12 import java.util.Arrays;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import java.util.List;
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
14 import java.util.Map;
6693
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
15 import java.util.HashMap;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17 import org.apache.log4j.Logger;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import org.w3c.dom.Document;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
21 import org.dive4elements.artifactdatabase.state.Facet;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
23 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
24 import org.dive4elements.artifacts.ArtifactFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
25 import org.dive4elements.artifacts.CallMeta;
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
26
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
27 import org.dive4elements.river.artifacts.model.FacetTypes;
7930
d3a4b0d5bcd8 Small Java related cosmetics.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
28 import org.dive4elements.river.artifacts.model.W;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
29 import org.dive4elements.river.artifacts.model.WQKms;
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
30
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
31 import org.dive4elements.river.artifacts.states.DefaultState;
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
32
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
33 import org.dive4elements.river.artifacts.model.Calculation;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
34 import org.dive4elements.river.artifacts.model.CalculationResult;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
35
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
36 import org.dive4elements.river.artifacts.model.DischargeTables;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
37
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
38 import org.dive4elements.river.model.Gauge;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
39 import org.dive4elements.river.model.River;
6693
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
40 import org.dive4elements.river.model.DischargeTable;
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
41
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
42 import org.dive4elements.river.utils.RiverUtils;
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
43
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 /**
3046
6e4ad35bcb11 Fix certain GaugeDischargeArtifact-issues, import river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
46 * Artifact to get discharge curves at gauges.
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 public class GaugeDischargeArtifact
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 extends WINFOArtifact
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 implements FacetTypes
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
52 /** The log for this class. */
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
53 private static Logger log = Logger.getLogger(GaugeDischargeArtifact.class);
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 /** The name of the artifact. */
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
56 public static final String ARTIFACT_NAME = "gaugedischarge";
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57
6693
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
58 /** The name a facet should have */
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
59 protected String facetWishName;
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 /**
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 * Trivial Constructor.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 public GaugeDischargeArtifact() {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
65 log.debug("GaugeDischargeArtifact.GaugeDischargeArtifact()");
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 /**
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 * Gets called from factory, to set things up.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 * Especially, when loaded via datacage mechanisms, provide the
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 * data document.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 * @param data filled with stuff from dc, if any.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 @Override
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76 public void setup(
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77 String identifier,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
78 ArtifactFactory factory,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 Object context,
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80 CallMeta callMeta,
7842
8d5ca5175038 Updated signature of artifacts setup method; Removed unnecessary setup overrides.
Raimund Renkert <rrenkert@intevation.de>
parents: 6693
diff changeset
81 Document data,
8d5ca5175038 Updated signature of artifacts setup method; Removed unnecessary setup overrides.
Raimund Renkert <rrenkert@intevation.de>
parents: 6693
diff changeset
82 List<Class> loadFacets)
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
84 log.debug("GaugeDischargeArtifact.setup");
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
85 String ids = StaticD4EArtifact.getDatacageIDValue(data);
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
86 addStringData("ids", ids);
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
87 log.debug("id for gaugedischarge: " + ids);
6693
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
88 String[] splitIds = ids.split(";");
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
89 /* We assume that if an id's string with a ; is given that the
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
90 * format is <gauge_name>;<discharge_table_id>;<facet_desc>
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
91 * so that a specific discharge table can be selected */
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
92 if (splitIds.length > 2) {
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
93 facetWishName = splitIds[2];
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
94 }
7842
8d5ca5175038 Updated signature of artifacts setup method; Removed unnecessary setup overrides.
Raimund Renkert <rrenkert@intevation.de>
parents: 6693
diff changeset
95 super.setup(identifier, factory, context, callMeta, data, loadFacets);
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
96 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
97
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
98
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
99 /** Return the name of this artifact. */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 public String getName() {
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 return ARTIFACT_NAME;
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
103
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
104
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
105 /**
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
106 * Setup state and facet, copy from master artifact.
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
107 */
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
108 @Override
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
109 protected void initialize(Artifact art, Object context, CallMeta meta) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
110 log.debug("GaugeDischargeArtifact.initialize");
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
111 List<Facet> fs = new ArrayList<Facet>();
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
112 D4EArtifact artifact = (D4EArtifact) art;
3046
6e4ad35bcb11 Fix certain GaugeDischargeArtifact-issues, import river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
113 importData(artifact, "river");
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
114
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
115 // Get the location(s)
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
116 //importData(artifact, "ld_mode", ld_from, ld_to, ld_locations
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
117 addStringData("ld_from", "0");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
118 addStringData("ld_to", "1000");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
119 addStringData("ld_mode", "distance");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
120
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
121 DefaultState state = (DefaultState) getCurrentState(context);
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
122 state.computeInit(this, hash(), context, meta, fs);
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
123 if (!fs.isEmpty()) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
124 log.debug("Facets to add in GaugeDischargeArtifact.initialize. ("
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
125 + state.getID() + "/ " + getCurrentStateId() + ").");
4497
a2735a4bf75e Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3591
diff changeset
126 addFacets(getCurrentStateId(), fs);
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
127 }
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3051
diff changeset
128 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
129 log.debug("No facets to add in GaugeDischargeArtifact.initialize ("
3046
6e4ad35bcb11 Fix certain GaugeDischargeArtifact-issues, import river.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
130 + state.getID() + "/ "+getCurrentStateId()+").");
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
131 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
132 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
133
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
134
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
135 /** Get the Gauges name which came with datacage data-document. */
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
136 public String getGaugeName() {
6693
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
137 if (getDataAsString("ids") == null) {
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
138 return null;
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
139 }
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
140 return getDataAsString("ids").split(";")[0];
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
141 }
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
142
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
143
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
144 /** Get the Gauges which came with datacage data-document. */
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
145 public Gauge getGauge() {
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
146 River river = RiverUtils.getRiver(this);
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
147 return river.determineGaugeByName(getGaugeName());
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
148 }
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
149
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
150
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
151 /**
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
152 * Returns the data that is used to create discharge curves.
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
153 * @return CalculationResult with WQKms.
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
154 */
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
155 public CalculationResult getDischargeCurveData() {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
156
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
157 River river = RiverUtils.getRiver(this);
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
158 if (river == null) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
159 return error(new WQKms[0], "no.river.selected");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
160 }
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
161 /*
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
162 // This one would allow to automatically pick the right Gauge.
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
163 double [] distance = RiverUtils.getKmRange(this);
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
164 log.debug("getDischargeCurveData: get range");
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
165
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
166 if (distance == null) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
167 return error(new WQKms[0], "no.range.found");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
168 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
169
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
170 List<Gauge> gauges = river.determineGauges(distance[0], distance[1]);
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
171 log.debug("getDischargeCurveData: got " + gauges.size() + " gauges");
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
172
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
173 if (gauges.isEmpty()) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
174 return error(new WQKms[0], "no.gauge.selected");
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
175 }
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
176
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
177 String [] names = new String[gauges.size()];
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
178
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
179 for (int i = 0; i < names.length; ++i) {
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
180 names[i] = gauges.get(i).getName();
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
181 log.debug("getDischargeCurveData: name " + names[i]);
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
182 }
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
183 */
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
184
6693
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
185 Map<String, double [][]> map;
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
186
6693
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
187 String[] ids = getDataAsString("ids").split(";");
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
188 if (ids.length > 1) {
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
189 /* We assume that if an id's string with a ; is given that the
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
190 * format is <gauge_name>;<discharge_table_id>;<facet_desc>
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
191 * so that a specific discharge table can be selected */
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
192 int tableId = 0;
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
193 try {
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
194 tableId = Integer.parseInt(ids[1]);
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
195 } catch (NumberFormatException e) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
196 log.error("Discharge tables ids string is wrong." +
6693
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
197 " Fromat is <gauge_name>;<discharge_table_id>;<facet_desc>" +
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
198 " Fix your Datacage!");
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
199 // Let's rather break down completly then show the wrong data.
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
200 return null;
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
201 }
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
202 DischargeTable table = DischargeTable.getDischargeTableById(tableId);
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
203 map = new HashMap<String, double [][]>();
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
204 map.put(getGaugeName(), DischargeTables.loadDischargeTableValues(table));
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
205 } else {
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
206 DischargeTables dt = new DischargeTables(river.getName(), getGaugeName());
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
207 map = dt.getValues();
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
208 }
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
209
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
210 ArrayList<WQKms> res = new ArrayList<WQKms>();
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
211
6693
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
212 Gauge gauge = river.determineGaugeByName(getGaugeName());
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
213
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
214 String name = getGaugeName();
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
215 double [][] values = map.get(name);
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
216 if (values == null) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7930
diff changeset
217 log.error("No values for this gauge / discharge found.");
3591
7500c7fbfaa9 Fail more gracefully.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
218 return error(new WQKms[0], "no.gauge.found");
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
219 }
3051
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
220 for (int i = 0 ; i < values[0].length; i++) {
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
221 values[0][i] += gauge.getDatum().doubleValue();
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
222 }
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
223 double [] kms = new double[values[0].length];
49727e9dcfde Polished Gauge Discharges in computed discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3046
diff changeset
224 Arrays.fill(kms, gauge.getStation().doubleValue());
7930
d3a4b0d5bcd8 Small Java related cosmetics.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
225 res.add(new WQKms(kms, values[0], values[1], name, W.CENTIMETER_AT_GAUGE));
2733
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
226
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
227 return new CalculationResult(
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
228 res.toArray(new WQKms[res.size()]),
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
229 new Calculation());
ac9a03ed32c1 More debugging of discharge-curve issue.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2723
diff changeset
230 }
6693
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
231
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
232 /** Gets the facet wish name.
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
233 *
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
234 * This is a hack to enable setting the name of the facet / theme in the
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
235 * UI from the datacage setting. */
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
236 public String getFacetWishName() {
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
237 return facetWishName;
88bb0c794833 issue1391: Enable GaugeDischarge artifact to directly load a table by its ID
Andre Heinecke <aheinecke@intevation.de>
parents: 6301
diff changeset
238 }
2723
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
239 }
5ce5abd173b9 Added skeleton for gauge discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
240 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org