annotate artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java @ 6533:30c6da3bfc86

In analogy to w values allow q values to be calculated at the correct km in fix settings (bug spotted while working on issue1370).
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 03 Jul 2013 09:34:02 +0200
parents cf3065a17057
children ed61ffc0687e
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: 5398
diff changeset
9 package org.dive4elements.river.artifacts;
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
11 import java.util.ArrayList;
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
12 import java.util.List;
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import org.apache.log4j.Logger;
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
16 import org.w3c.dom.Document;
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
17
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
18 import org.dive4elements.artifactdatabase.data.DefaultStateData;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
19 import org.dive4elements.artifactdatabase.state.Facet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
20 import org.dive4elements.artifactdatabase.state.FacetActivity;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
21 import org.dive4elements.artifactdatabase.state.DefaultOutput;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
22 import org.dive4elements.artifactdatabase.state.State;
1095
f465785ed1ae Refactored the code to fetch the km range/locations into a utility class.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1093
diff changeset
23
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
24 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
25 import org.dive4elements.artifacts.ArtifactFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
26 import org.dive4elements.artifacts.CallMeta;
1078
048517d67215 Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1074
diff changeset
27
6038
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
28 import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
29 import org.dive4elements.artifacts.common.utils.XMLUtils;
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
30
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
31 import org.dive4elements.river.model.Gauge;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
32 import org.dive4elements.river.model.MainValue;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
33 import org.dive4elements.river.model.River;
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
34
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
35 import org.dive4elements.river.artifacts.access.RangeAccess;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
36 import org.dive4elements.river.artifacts.model.Calculation;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
37 import org.dive4elements.river.artifacts.model.FacetTypes;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
38 import org.dive4elements.river.artifacts.model.MainValuesQFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
39 import org.dive4elements.river.artifacts.model.MainValuesWFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
40 import org.dive4elements.river.artifacts.model.NamedDouble;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
41 import org.dive4elements.river.artifacts.model.WstValueTable;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
42 import org.dive4elements.river.artifacts.model.WstValueTableFactory;
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
43
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
44 import org.dive4elements.river.artifacts.states.StaticState;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
45 import org.dive4elements.river.artifacts.resources.Resources;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5398
diff changeset
46
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
47 import org.dive4elements.river.utils.RiverUtils;
1078
048517d67215 Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1074
diff changeset
48
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 /**
4126
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
51 * Artifact to access main and extreme values of a river.
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
52 * This artifact neglects (Static)D4EArtifacts capabilities of interaction
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
53 * with the StateEngine by overriding the getState*-methods.
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 */
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 public class MainValuesArtifact
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
56 extends StaticD4EArtifact
1809
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1787
diff changeset
57 implements FacetTypes
1059
fdb0f4ef96f0 Made FLYS artifacts cloneable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1051
diff changeset
58 {
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 /** The logger for this class. */
1065
193c49b7f6a3 Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1061
diff changeset
60 private static Logger logger = Logger.getLogger(MainValuesArtifact.class);
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 /** The name of the artifact. */
1065
193c49b7f6a3 Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1061
diff changeset
63 public static final String ARTIFACT_NAME = "mainvalue";
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
64
1771
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
65 /** The name of the static state for this artifact. */
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
66 public static final String STATIC_STATE_NAME = "state.mainvalue.static";
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
67
1078
048517d67215 Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1074
diff changeset
68 /** One and only state to be in. */
048517d67215 Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1074
diff changeset
69 protected transient State state = null;
048517d67215 Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1074
diff changeset
70
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
71
3558
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
72 static {
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
73 // TODO: Move to configuration.
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
74 FacetActivity.Registry.getInstance().register(
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
75 ARTIFACT_NAME,
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
76 new FacetActivity() {
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
77 @Override
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
78 public Boolean isInitialActive(
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
79 Artifact artifact,
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
80 Facet facet,
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
81 String outputName
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
82 ) {
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
83 return outputName.equals("computed_discharge_curve")
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
84 || outputName.equals("duration_curve");
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
85 }
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
86 });
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
87 }
c3cd414982fe Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3556
diff changeset
88
5368
d3f170484455 MainValuesArtifact: Doc, cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5290
diff changeset
89
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
90 /**
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
91 * Trivial Constructor.
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
92 */
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
93 public MainValuesArtifact() {
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
94 logger.debug("MainValuesArtifact.MainValuesartifact()");
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
95 }
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
96
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
97
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
98 /**
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
99 * Gets called from factory, to set things up.
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 */
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 @Override
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102 public void setup(
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
103 String identifier,
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
104 ArtifactFactory factory,
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
105 Object context,
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
106 CallMeta callMeta,
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
107 Document data)
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
108 {
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
109 logger.debug("MainValuesArtifact.setup");
1787
f3be8fa1ec62 Cosmetics, added simpler constructor for StaticState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1771
diff changeset
110 state = new StaticState(STATIC_STATE_NAME);
f3be8fa1ec62 Cosmetics, added simpler constructor for StaticState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1771
diff changeset
111
6038
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
112 initFromGaugeDoc(data, callMeta);
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
113
4126
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
114 List<Facet> fs = new ArrayList<Facet>();
4497
a2735a4bf75e Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4126
diff changeset
115 addFacets(state.getID(), fs);
4126
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
116 spawnState();
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
117 super.setup(identifier, factory, context, callMeta, data);
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
118 String restriction = getDatacageIDValue(data);
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
119 logger.debug("mainvalue restriction " + restriction);
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
120 boolean restricted = restriction.endsWith("q") || restriction.endsWith("w");
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
121 if (!restricted || restriction.endsWith("q")) {
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
122 Facet qfacet0 = new MainValuesQFacet(
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
123 DURATION_MAINVALUES_Q,
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
124 Resources.getMsg(
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
125 callMeta,
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
126 "facet.discharge_curves.mainvalues.q",
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
127 "facet.discharge_curves.mainvalues.q"),
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
128 false);
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
129 Facet qfacet1 = new MainValuesQFacet(
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
130 COMPUTED_DISCHARGE_MAINVALUES_Q,
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
131 Resources.getMsg(
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
132 callMeta,
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
133 "facet.discharge_curves.mainvalues.q",
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
134 "facet.discharge_curves.mainvalues.q"),
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
135 false);
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
136 Facet qfacet2 = new MainValuesQFacet(
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
137 MAINVALUES_Q,
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
138 Resources.getMsg(
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
139 callMeta,
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
140 "facet.discharge_curves.mainvalues.q",
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
141 "facet.discharge_curves.mainvalues.q"),
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
142 true);
5370
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
143 Facet qfacet3 = new MainValuesQFacet(
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
144 HISTORICAL_DISCHARGE_MAINVALUES_Q,
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
145 Resources.getMsg(
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
146 callMeta,
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
147 "historical_discharge.mainvalues.q",
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
148 "historical_discharge.mainvalues.q"),
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
149 false);
4736
b195fede1c3b Remove trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
150
4126
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
151 fs.add(qfacet0);
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
152 fs.add(qfacet1);
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
153 fs.add(qfacet2);
5370
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
154 fs.add(qfacet3);
4126
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
155 }
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
156 if (!restricted || restriction.endsWith("w")) {
5370
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
157 Facet wfacet1 = new MainValuesWFacet(
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
158 COMPUTED_DISCHARGE_MAINVALUES_W,
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
159 Resources.getMsg(
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
160 callMeta,
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
161 "facet.discharge_curves.mainvalues.w",
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
162 "facet.discharge_curves.mainvalues.w"),
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
163 false);
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
164 Facet wfacet2 = new MainValuesWFacet(
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
165 MAINVALUES_W,
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
166 Resources.getMsg(
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
167 callMeta,
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
168 "facet.discharge_curves.mainvalues.w",
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
169 "facet.discharge_curves.mainvalues.w"),
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
170 true);
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
171 Facet wfacet3 = new MainValuesWFacet(
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
172 HISTORICAL_DISCHARGE_MAINVALUES_W,
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
173 Resources.getMsg(
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
174 callMeta,
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
175 "historical_discharge.mainvalues.w",
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
176 "historical_discharge.mainvalues.w"),
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
177 true);
4126
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
178 fs.add(wfacet1);
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
179 fs.add(wfacet2);
5370
2a5d7f9f268f MainValuesArtifact: Spawn two new facets (for his. w/q diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5368
diff changeset
180 fs.add(wfacet3);
4126
e0354aed0cd3 Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3558
diff changeset
181 }
1080
fa01c3602f66 Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1079
diff changeset
182 }
fa01c3602f66 Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1079
diff changeset
183
6038
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
184 /**
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
185 * The MainValueArtifact can be set up with a document giving the
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
186 * river and gauge. This happens in context of GaugeDischargeArtifact.
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
187 * In that case, initalize() is not called.
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
188 */
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
189 private void initFromGaugeDoc(Document data, CallMeta callMeta) {
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
190 String gaugeref = XMLUtils.xpathString(
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
191 data, GaugeDischargeCurveArtifact.XPATH_GAUGE,
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
192 ArtifactNamespaceContext.INSTANCE);
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
193 String rivername = XMLUtils.xpathString(
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
194 data, GaugeDischargeCurveArtifact.XPATH_RIVER,
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
195 ArtifactNamespaceContext.INSTANCE);
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
196
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
197 if (rivername == null || gaugeref == null || rivername.equals("")
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
198 || gaugeref.equals("")) {
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
199 logger.debug("Not setting MainValuesArtifact up from gauge doc.");
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
200 return;
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
201 }
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
202
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
203 addData("river", new DefaultStateData("river",
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
204 Resources.getMsg(callMeta,
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
205 "facet.gauge_discharge_curve.river",
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
206 "Name of the river"),
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
207 "String", rivername));
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
208
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
209 try {
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
210 Long officialNumber = Long.valueOf(gaugeref);
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
211 Gauge gauge = Gauge.getGaugeByOfficialNumber(officialNumber);
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
212 addData("ld_locations", new DefaultStateData("ld_locations", null, null,
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
213 String.valueOf(gauge.getStation())));
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
214 } catch (NumberFormatException nfe) {
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
215 logger.debug("MainValuesArtifact could not parse gaugeref from doc.");
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
216 }
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
217 }
a0dd303f4a08 MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
218
1771
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
219
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
220 /**
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
221 * Create "the" state.
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
222 */
1112
aeae4d20f32f Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1101
diff changeset
223 protected State spawnState() {
1787
f3be8fa1ec62 Cosmetics, added simpler constructor for StaticState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1771
diff changeset
224 state = new StaticState(STATIC_STATE_NAME);
4497
a2735a4bf75e Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4126
diff changeset
225 List<Facet> fs = (List<Facet>) getFacets(STATIC_STATE_NAME);
1771
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
226
1847
8e5b4ea2851c Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1811
diff changeset
227 DefaultOutput mainValuesOutput = new DefaultOutput(
1765
5d8b3880a553 Do not store association of states to facets, let artifacts keep facets in a pure list.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1654
diff changeset
228 "computed_discharge_curve",
5d8b3880a553 Do not store association of states to facets, let artifacts keep facets in a pure list.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1654
diff changeset
229 "output.computed_discharge_curve", "image/png",
1771
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
230 fs,
1765
5d8b3880a553 Do not store association of states to facets, let artifacts keep facets in a pure list.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1654
diff changeset
231 "chart");
1112
aeae4d20f32f Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1101
diff changeset
232
1847
8e5b4ea2851c Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1811
diff changeset
233 state.getOutputs().add(mainValuesOutput);
1112
aeae4d20f32f Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1101
diff changeset
234 return state;
aeae4d20f32f Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1101
diff changeset
235 }
aeae4d20f32f Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1101
diff changeset
236
1080
fa01c3602f66 Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1079
diff changeset
237
5368
d3f170484455 MainValuesArtifact: Doc, cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5290
diff changeset
238 /** Get important data from the 'calling' artifact. */
1080
fa01c3602f66 Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1079
diff changeset
239 @Override
fa01c3602f66 Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1079
diff changeset
240 protected void initialize(Artifact artifact, Object context, CallMeta meta) {
fa01c3602f66 Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1079
diff changeset
241 logger.debug("MainValuesArtifact.initialize");
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5865
diff changeset
242 D4EArtifact winfo = (D4EArtifact) artifact;
6101
a0078e5e3b39 Removed unused context from RangeAccess and subclasses leading to some dead code removal.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 6038
diff changeset
243 RangeAccess rangeAccess = new RangeAccess(winfo);
5290
394841a66c14 MainValuesArtifact: Possible NPE fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4937
diff changeset
244 double [] locations = rangeAccess.getKmRange();
394841a66c14 MainValuesArtifact: Possible NPE fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4937
diff changeset
245
1847
8e5b4ea2851c Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1811
diff changeset
246 if (locations != null) {
8e5b4ea2851c Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1811
diff changeset
247 double location = locations[0];
4937
ce7d8e2a7e02 Fixed mainvalues artifact.
Raimund Renkert <rrenkert@intevation.de>
parents: 4845
diff changeset
248 addData("ld_locations", new DefaultStateData("ld_locations", null, null,
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
249 String.valueOf(location)));
1847
8e5b4ea2851c Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1811
diff changeset
250 }
8e5b4ea2851c Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1811
diff changeset
251 else {
5290
394841a66c14 MainValuesArtifact: Possible NPE fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4937
diff changeset
252 logger.error("No location for mainvalues given.");
1847
8e5b4ea2851c Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1811
diff changeset
253 }
1922
7e7522c9e663 Use importData convenvience function.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1847
diff changeset
254 importData(winfo, "river");
5371
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
255 // In the case of DischargeWQCurves, there are no locations, but a gauge.
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
256 if (getDataAsString("ld_locations") == null) {
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
257 // TODO its a tad difficult to remodel Range/Gauge-Access to
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
258 // do this.
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
259 String refGaugeID = winfo.getDataAsString("reference_gauge");
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
260 if (refGaugeID != null) {
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
261 Gauge g = Gauge.getGaugeByOfficialNumber(Integer.parseInt(refGaugeID));
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
262 addData("ld_locations", new DefaultStateData("ld_locations", null, null,
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
263 String.valueOf(g.getStation())));
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
264 }
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
265 else {
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
266 logger.error("MainValuesArtifact: No location/gauge.");
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
267 }
92c07d5c433c MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5370
diff changeset
268 }
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
269 }
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
270
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
271
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
272 /**
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
273 * Get a list containing the one and only State.
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
274 * @param context ignored.
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
275 * @return list with one and only state.
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
276 */
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
277 @Override
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
278 protected List<State> getStates(Object context) {
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
279 ArrayList<State> states = new ArrayList<State>();
1112
aeae4d20f32f Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1101
diff changeset
280 states.add(getState());
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
281 return states;
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
282 }
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
283
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
284
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
285 /**
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
286 * Get the "current" state.
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
287 * @param cc ignored.
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
288 * @return the "current" state.
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
289 */
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
290 @Override
1654
33ade8153d74 Little modifications for making recommendations - will now work for states with background calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1113
diff changeset
291 public State getCurrentState(Object cc) {
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
292 return getState();
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
293 }
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
294
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
295
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
296 /**
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
297 * Get the only possible state.
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
298 * @return the state.
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
299 */
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
300 protected State getState() {
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
301 return getState(null, null);
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
302 }
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
303
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
304
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
305 /**
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
306 * Get the state.
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
307 * @param context ignored.
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
308 * @param stateID ignored.
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
309 * @return the state.
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
310 */
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
311 @Override
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
312 protected State getState(Object context, String stateID) {
1112
aeae4d20f32f Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1101
diff changeset
313 if (state != null)
aeae4d20f32f Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1101
diff changeset
314 return state;
aeae4d20f32f Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1101
diff changeset
315 else
aeae4d20f32f Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1101
diff changeset
316 return spawnState();
1078
048517d67215 Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1074
diff changeset
317 }
048517d67215 Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1074
diff changeset
318
6524
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
319 /**
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
320 * Access the Gauge that the mainvalues are taken from.
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
321 * @return Gauge that main values are taken from or null in case of
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
322 * invalid parameterization.
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
323 */
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
324 protected Gauge getGauge(double km) {
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
325 River river = RiverUtils.getRiver(this);
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
326
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
327 if (river == null) {
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
328 logger.error("River is null");
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
329 return null;
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
330 }
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
331
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
332 return river.determineGaugeByPosition(km);
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
333 }
1093
139e7df1787c Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1089
diff changeset
334
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
335 /**
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
336 * Access the Gauge that the mainvalues are taken from.
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
337 * @return Gauge that main values are taken from or null in case of
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
338 * invalid parameterization.
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
339 */
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
340 protected Gauge getGauge() {
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
341 River river = RiverUtils.getRiver(this);
1065
193c49b7f6a3 Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1061
diff changeset
342
1847
8e5b4ea2851c Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1811
diff changeset
343 // TODO use helper to get location as double
4937
ce7d8e2a7e02 Fixed mainvalues artifact.
Raimund Renkert <rrenkert@intevation.de>
parents: 4845
diff changeset
344 String locationStr = getDataAsString("ld_locations");
1847
8e5b4ea2851c Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1811
diff changeset
345
5290
394841a66c14 MainValuesArtifact: Possible NPE fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4937
diff changeset
346 if (river == null) {
394841a66c14 MainValuesArtifact: Possible NPE fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4937
diff changeset
347 logger.error("River is null");
394841a66c14 MainValuesArtifact: Possible NPE fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4937
diff changeset
348 return null;
394841a66c14 MainValuesArtifact: Possible NPE fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4937
diff changeset
349 }
394841a66c14 MainValuesArtifact: Possible NPE fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4937
diff changeset
350
394841a66c14 MainValuesArtifact: Possible NPE fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4937
diff changeset
351 if (locationStr == null) {
394841a66c14 MainValuesArtifact: Possible NPE fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4937
diff changeset
352 logger.error("Locationstr is null");
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
353 return null;
1072
80aecb01d79a Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1065
diff changeset
354 }
1065
193c49b7f6a3 Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1061
diff changeset
355
1847
8e5b4ea2851c Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1811
diff changeset
356 double location = Double.parseDouble(locationStr);
1079
ef756e166154 Improved implementation of MainValueArtifact#MainValueFacet .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1078
diff changeset
357
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
358 return river.determineGaugeByPosition(location);
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
359 }
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
360
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
361
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
362 /**
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
363 * Get current location.
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
364 * @return the location.
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
365 */
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
366 public double getLocation() {
4937
ce7d8e2a7e02 Fixed mainvalues artifact.
Raimund Renkert <rrenkert@intevation.de>
parents: 4845
diff changeset
367 double location = Double.parseDouble(getDataAsString("ld_locations"));
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
368 return location;
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
369 }
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
370
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
371
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
372 /**
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
373 * Get a list of "Q" main values.
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
374 * @return list of Q main values.
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
375 */
6533
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
376 public List<NamedDouble> getMainValuesQ(double[] kms) {
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
377 List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
378 boolean atGauge = false;
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
379 Gauge gauge = getGauge(kms[0]);
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
380 WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
381 Calculation c = new Calculation();
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
382 double w_out[] = {0.0f};
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
383 double q_out[] = {0.0f};
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
384 if (gauge != null) {
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
385 double gaugeStation = gauge.getStation().doubleValue();
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
386 atGauge = Math.abs(kms[0] - gaugeStation) < 1e-4;
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
387 List<MainValue> orig = gauge.getMainValues();
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
388 for (MainValue mv : orig) {
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
389 if (mv.getMainValue().getType().getName().equals("Q")) {
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
390 if (atGauge) {
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
391 q_out[0] = mv.getValue().doubleValue();
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
392 }
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
393 else {
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
394 interpolator.interpolate(mv.getValue().doubleValue(),
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
395 gaugeStation, kms, w_out, q_out, c);
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
396 }
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
397 filteredList.add(new NamedDouble(
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
398 mv.getMainValue().getName(),
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
399 q_out[0]
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
400 ));
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
401 }
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
402 }
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
403 }
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
404 return filteredList;
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
405 }
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
406
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
407 /**
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
408 * Get a list of "Q" main values.
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
409 * @return list of Q main values.
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
410 */
1957
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
411 public List<NamedDouble> getMainValuesQ(boolean atGauge) {
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
412 List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
413 Gauge gauge = getGauge();
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
414 WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
415 Calculation c = new Calculation();
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
416 double w_out[] = {0.0f};
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
417 double q_out[] = {0.0f};
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
418 double kms[] = {getLocation()};
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
419 if (gauge != null) {
6533
30c6da3bfc86 In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6532
diff changeset
420 double gaugeStation = gauge.getStation().doubleValue();
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
421 List<MainValue> orig = gauge.getMainValues();
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
422 for (MainValue mv : orig) {
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
423 if (mv.getMainValue().getType().getName().equals("Q")) {
1957
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
424 if (atGauge) {
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
425 q_out[0] = mv.getValue().doubleValue();
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
426 }
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
427 else {
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
428 interpolator.interpolate(mv.getValue().doubleValue(),
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
429 gaugeStation, kms, w_out, q_out, c);
1957
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
430 }
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
431 filteredList.add(new NamedDouble(
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
432 mv.getMainValue().getName(),
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
433 q_out[0]
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
434 ));
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
435 }
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
436 }
1065
193c49b7f6a3 Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1061
diff changeset
437 }
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
438 return filteredList;
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
439 }
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
440
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
441
6524
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
442 /** Get main values of km. */
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
443 public List<NamedDouble> getMainValuesW(double[] kms) {
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
444 List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
445 boolean atGauge = false;
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
446 double gaugeDatum = 0d;
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
447 Gauge gauge = getGauge(kms[0]);
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
448 if (gauge == null) {
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
449 return filteredList;
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
450 }
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
451 else if (Math.abs(kms[0] - gauge.getStation().doubleValue()) < 1e-4) {
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
452 atGauge = true;
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
453 gaugeDatum = gauge.getDatum().doubleValue();
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
454 }
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
455
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
456 WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
457 Calculation c = new Calculation();
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
458
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
459 double gaugeStation = gauge.getStation().doubleValue();
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
460 double w_out[] = {0.0f};
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
461 double q_out[] = {0.0f};
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
462 if (gauge != null) {
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
463 List<MainValue> orig = gauge.getMainValues();
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
464 for (MainValue mv : orig) {
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
465 if (atGauge) {
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
466 if (mv.getMainValue().getType().getName().equals("W")) {
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
467 filteredList.add(new NamedDouble(mv.getMainValue().getName(),
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
468 mv.getValue().doubleValue()));
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
469 }
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
470 } else
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
471 // We cannot interpolate the W values, so derive them
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
472 // from given Q values.
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
473 if (mv.getMainValue().getType().getName().equals("Q")) {
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
474 interpolator.interpolate(mv.getValue().doubleValue(),
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
475 gaugeStation, kms, w_out, q_out, c);
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
476
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
477 filteredList.add(new NamedDouble(
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
478 "W(" + mv.getMainValue().getName() +")",
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
479 w_out[0]
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
480 ));
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
481 }
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
482 }
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
483 }
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
484 return filteredList;
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
485 }
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
486
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
487
641ec405c4ac MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6523
diff changeset
488 public List<NamedDouble> getMainValuesW(boolean atGauge, double[] kms) {
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
489 List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
490 Gauge gauge = getGauge();
5865
73da40528cf2 River artifacts: Renamed FLYSUtils to RiverUtils.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
491 WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
492 Calculation c = new Calculation();
1847
8e5b4ea2851c Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1811
diff changeset
493
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
494 double w_out[] = {0.0f};
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
495 double q_out[] = {0.0f};
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
496 if (gauge != null) {
6532
cf3065a17057 MainValuesArtifact: Prevent NPE.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6524
diff changeset
497 double gaugeStation = gauge.getStation().doubleValue();
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
498 List<MainValue> orig = gauge.getMainValues();
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
499 for (MainValue mv : orig) {
1957
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
500 if (atGauge) {
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
501 if (mv.getMainValue().getType().getName().equals("W")) {
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
502 filteredList.add(new NamedDouble(mv.getMainValue().getName(),
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
503 mv.getValue().doubleValue()));
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2163
diff changeset
504
1957
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
505 }
3b08b8aacfb0 Fix flys/issue423, do not interpolate main values at gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1922
diff changeset
506 } else
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
507 // We cannot interpolate the W values, so derive them
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
508 // from given Q values.
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
509 if (mv.getMainValue().getType().getName().equals("Q")) {
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
510 interpolator.interpolate(mv.getValue().doubleValue(),
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
511 gaugeStation, kms, w_out, q_out, c);
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
512 filteredList.add(new NamedDouble(
1101
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
513 "W(" + mv.getMainValue().getName() +")",
82798c992975 Interpolate Q main values, generate interpolated W main values on the fly from
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1100
diff changeset
514 w_out[0]
1089
e298c4d28927 Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1085
diff changeset
515 ));
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
516 }
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
517 }
1065
193c49b7f6a3 Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1061
diff changeset
518 }
1085
07878836ee0d Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1080
diff changeset
519 return filteredList;
1065
193c49b7f6a3 Minor changes to stub MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1061
diff changeset
520 }
5398
a916e1202f0f MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5371
diff changeset
521
a916e1202f0f MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5371
diff changeset
522
a916e1202f0f MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5371
diff changeset
523 /**
6523
5afb1cda5885 Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
524 * Get a list of "W" main values.
5afb1cda5885 Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
525 * @param atGauge if true, do not interpolate
5afb1cda5885 Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
526 * @return list of W main values.
5afb1cda5885 Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
527 */
5afb1cda5885 Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
528 public List<NamedDouble> getMainValuesW(boolean atGauge) {
5afb1cda5885 Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
529 return getMainValuesW(atGauge, new double[] {getLocation()});
5afb1cda5885 Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
530 }
5afb1cda5885 Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
531
5afb1cda5885 Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
532
5afb1cda5885 Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6101
diff changeset
533 /**
5398
a916e1202f0f MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5371
diff changeset
534 * Returns the name of this artifact ('mainvalue').
a916e1202f0f MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5371
diff changeset
535 *
a916e1202f0f MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5371
diff changeset
536 * @return 'mainvalue'
a916e1202f0f MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5371
diff changeset
537 */
a916e1202f0f MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5371
diff changeset
538 public String getName() {
a916e1202f0f MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5371
diff changeset
539 return ARTIFACT_NAME;
a916e1202f0f MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5371
diff changeset
540 }
1047
38088c982db6 Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
541 }
1809
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1787
diff changeset
542 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org