Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java @ 9801:1d7a72a50183 3.2.x tip
Assume Compose V2, consistently
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 23 Nov 2023 10:14:13 +0100 |
parents | 0a5239a1e46e |
children |
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 |
9726 | 14 import org.apache.logging.log4j.Logger; |
15 import org.apache.logging.log4j.LogManager; | |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 import org.w3c.dom.Document; |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
19 import org.dive4elements.artifactdatabase.data.DefaultStateData; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
20 import org.dive4elements.artifactdatabase.state.Facet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
21 import org.dive4elements.artifactdatabase.state.FacetActivity; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
22 import org.dive4elements.artifactdatabase.state.DefaultOutput; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
23 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
|
24 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
25 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
26 import org.dive4elements.artifacts.ArtifactFactory; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
27 import org.dive4elements.artifacts.CallMeta; |
1078
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
28 |
6038
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.ArtifactNamespaceContext; |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
30 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
|
31 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
32 import org.dive4elements.river.model.Gauge; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
33 import org.dive4elements.river.model.MainValue; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
34 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
|
35 |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
36 import org.dive4elements.river.artifacts.access.RiverAccess; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
37 import org.dive4elements.river.artifacts.access.RangeAccess; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
38 import org.dive4elements.river.artifacts.model.Calculation; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
39 import org.dive4elements.river.artifacts.model.FacetTypes; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
40 import org.dive4elements.river.artifacts.model.MainValuesQFacet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
41 import org.dive4elements.river.artifacts.model.MainValuesWFacet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
42 import org.dive4elements.river.artifacts.model.NamedDouble; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
43 import org.dive4elements.river.artifacts.model.WstValueTable; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
44 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
|
45 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
46 import org.dive4elements.river.artifacts.states.StaticState; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
diff
changeset
|
47 import org.dive4elements.river.artifacts.resources.Resources; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5398
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 { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
59 /** The log for this class. */ |
9726 | 60 private static Logger log = LogManager.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 ) { |
8333
be7864b4fabb
Let's be more generous with facet activity of main values.
"Tom Gottfried <tom@intevation.de>"
parents:
8331
diff
changeset
|
83 if (facet.getName().equals(MAINVALUES_Q) || |
be7864b4fabb
Let's be more generous with facet activity of main values.
"Tom Gottfried <tom@intevation.de>"
parents:
8331
diff
changeset
|
84 facet.getName().equals(MAINVALUES_W)) { |
be7864b4fabb
Let's be more generous with facet activity of main values.
"Tom Gottfried <tom@intevation.de>"
parents:
8331
diff
changeset
|
85 return Boolean.TRUE; |
be7864b4fabb
Let's be more generous with facet activity of main values.
"Tom Gottfried <tom@intevation.de>"
parents:
8331
diff
changeset
|
86 } |
be7864b4fabb
Let's be more generous with facet activity of main values.
"Tom Gottfried <tom@intevation.de>"
parents:
8331
diff
changeset
|
87 return null; |
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
|
88 } |
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
|
89 }); |
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
|
90 } |
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
|
91 |
5368
d3f170484455
MainValuesArtifact: Doc, cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5290
diff
changeset
|
92 |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
93 /** |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
94 * Trivial Constructor. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
95 */ |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 public MainValuesArtifact() { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
97 log.debug("MainValuesArtifact.MainValuesartifact()"); |
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 |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
100 |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
101 /** |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 * Gets called from factory, to set things up. |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
103 */ |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 @Override |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 public void setup( |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 String identifier, |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
107 ArtifactFactory factory, |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
108 Object context, |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
109 CallMeta callMeta, |
7842
8d5ca5175038
Updated signature of artifacts setup method; Removed unnecessary setup overrides.
Raimund Renkert <rrenkert@intevation.de>
parents:
7507
diff
changeset
|
110 Document data, |
8d5ca5175038
Updated signature of artifacts setup method; Removed unnecessary setup overrides.
Raimund Renkert <rrenkert@intevation.de>
parents:
7507
diff
changeset
|
111 List<Class> loadFacets) |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
112 { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
113 log.debug("MainValuesArtifact.setup"); |
1787
f3be8fa1ec62
Cosmetics, added simpler constructor for StaticState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
114 state = new StaticState(STATIC_STATE_NAME); |
f3be8fa1ec62
Cosmetics, added simpler constructor for StaticState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
115 |
6038
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
116 initFromGaugeDoc(data, callMeta); |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
117 |
4126
e0354aed0cd3
Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3558
diff
changeset
|
118 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
|
119 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
|
120 spawnState(); |
e0354aed0cd3
Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3558
diff
changeset
|
121 String restriction = getDatacageIDValue(data); |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
122 log.debug("mainvalue restriction " + restriction); |
8856 | 123 boolean restricted = restriction.endsWith("q") |
124 || restriction.endsWith("w"); | |
4126
e0354aed0cd3
Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3558
diff
changeset
|
125 if (!restricted || restriction.endsWith("q")) { |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
126 fs.add(new MainValuesQFacet( |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
127 MAINVALUES_Q, |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
128 Resources.getMsg( |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
129 callMeta, |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
130 "facet.discharge_curves.mainvalues.q"))); |
4126
e0354aed0cd3
Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3558
diff
changeset
|
131 } |
e0354aed0cd3
Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3558
diff
changeset
|
132 if (!restricted || restriction.endsWith("w")) { |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
133 fs.add(new MainValuesWFacet( |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
134 MAINVALUES_W, |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
135 Resources.getMsg( |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
136 callMeta, |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
137 "facet.discharge_curves.mainvalues.w"))); |
4126
e0354aed0cd3
Improvements for issue945/6 (separate w and q mainvalues in DC).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3558
diff
changeset
|
138 } |
8340
8679875f2c09
Create mainvalue facets before setting up the artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
8339
diff
changeset
|
139 super.setup(identifier, factory, context, callMeta, data, loadFacets); |
1080
fa01c3602f66
Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1079
diff
changeset
|
140 } |
fa01c3602f66
Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1079
diff
changeset
|
141 |
7507
a9eb777463e1
cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6686
diff
changeset
|
142 |
6038
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
143 /** |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
144 * 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
|
145 * 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
|
146 * 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
|
147 */ |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
148 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
|
149 String gaugeref = XMLUtils.xpathString( |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
150 data, GaugeDischargeCurveArtifact.XPATH_GAUGE, |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
151 ArtifactNamespaceContext.INSTANCE); |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
152 String rivername = XMLUtils.xpathString( |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
153 data, GaugeDischargeCurveArtifact.XPATH_RIVER, |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
154 ArtifactNamespaceContext.INSTANCE); |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
155 |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
156 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
|
157 || gaugeref.equals("")) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
158 log.debug("Not setting MainValuesArtifact up from gauge doc."); |
6038
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
159 return; |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
160 } |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
161 |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
162 addData("river", new DefaultStateData("river", |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
163 Resources.getMsg(callMeta, |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
164 "facet.gauge_discharge_curve.river", |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
165 "Name of the river"), |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
166 "String", rivername)); |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
167 |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
168 try { |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
169 Long officialNumber = Long.valueOf(gaugeref); |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
170 Gauge gauge = Gauge.getGaugeByOfficialNumber(officialNumber); |
8856 | 171 addData( |
172 "ld_locations", | |
173 new DefaultStateData("ld_locations", null, null, | |
174 String.valueOf(gauge.getStation())) | |
175 ); | |
6038
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
176 } catch (NumberFormatException nfe) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
177 log.debug("MainValuesArtifact could not parse gaugeref from doc."); |
6038
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
178 } |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
179 } |
a0dd303f4a08
MainValuesArtifact: prepare to be created by crafted document.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
180 |
1771
c62ff9e72cea
Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1765
diff
changeset
|
181 |
c62ff9e72cea
Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1765
diff
changeset
|
182 /** |
7507
a9eb777463e1
cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6686
diff
changeset
|
183 * Create "the" (one possible) state. |
1771
c62ff9e72cea
Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1765
diff
changeset
|
184 */ |
1112
aeae4d20f32f
Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1101
diff
changeset
|
185 protected State spawnState() { |
1787
f3be8fa1ec62
Cosmetics, added simpler constructor for StaticState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1771
diff
changeset
|
186 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
|
187 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
|
188 |
1847
8e5b4ea2851c
Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1811
diff
changeset
|
189 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
|
190 "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
|
191 "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
|
192 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
|
193 "chart"); |
1112
aeae4d20f32f
Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1101
diff
changeset
|
194 |
1847
8e5b4ea2851c
Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1811
diff
changeset
|
195 state.getOutputs().add(mainValuesOutput); |
1112
aeae4d20f32f
Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1101
diff
changeset
|
196 return state; |
aeae4d20f32f
Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1101
diff
changeset
|
197 } |
aeae4d20f32f
Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1101
diff
changeset
|
198 |
1080
fa01c3602f66
Added MainValue-Fetching-Capabilities to MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1079
diff
changeset
|
199 |
5368
d3f170484455
MainValuesArtifact: Doc, cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5290
diff
changeset
|
200 /** 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
|
201 @Override |
8856 | 202 protected void initialize( |
203 Artifact artifact, | |
204 Object context, | |
205 CallMeta meta | |
206 ) { | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
207 log.debug("MainValuesArtifact.initialize"); |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5865
diff
changeset
|
208 D4EArtifact winfo = (D4EArtifact) artifact; |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
209 River river = new RiverAccess(winfo).getRiver(); |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
210 double [] locations = new RangeAccess(winfo).getKmRange(); |
5290
394841a66c14
MainValuesArtifact: Possible NPE fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4937
diff
changeset
|
211 |
1847
8e5b4ea2851c
Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1811
diff
changeset
|
212 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
|
213 double location = locations[0]; |
8856 | 214 addData( |
215 "ld_locations", | |
216 new DefaultStateData("ld_locations", null, null, | |
217 String.valueOf(location)) | |
218 ); | |
1847
8e5b4ea2851c
Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1811
diff
changeset
|
219 } |
8e5b4ea2851c
Minor cosmetics and let facets be inactive in duration curve diagrams.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1811
diff
changeset
|
220 else { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
221 log.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
|
222 } |
1922
7e7522c9e663
Use importData convenvience function.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1847
diff
changeset
|
223 importData(winfo, "river"); |
8856 | 224 // In the case of DischargeWQCurves, there are no locations, |
225 // but a gauge. | |
5371
92c07d5c433c
MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5370
diff
changeset
|
226 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
|
227 // 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
|
228 // do this. |
92c07d5c433c
MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5370
diff
changeset
|
229 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
|
230 if (refGaugeID != null) { |
8856 | 231 Gauge g = Gauge.getGaugeByOfficialNumber( |
232 Integer.parseInt(refGaugeID)); | |
233 addData( | |
234 "ld_locations", | |
235 new DefaultStateData("ld_locations", null, null, | |
236 String.valueOf(g.getStation())) | |
237 ); | |
5371
92c07d5c433c
MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5370
diff
changeset
|
238 } |
92c07d5c433c
MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5370
diff
changeset
|
239 else { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
240 log.error("MainValuesArtifact: No location/gauge."); |
5371
92c07d5c433c
MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5370
diff
changeset
|
241 } |
92c07d5c433c
MainValuesArtifact: For hist. W/Q diagram mainvalues, get location from gauge.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5370
diff
changeset
|
242 } |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
243 } |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
244 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
245 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
246 /** |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
247 * 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
|
248 * @param context ignored. |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
249 * @return list with one and only state. |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
250 */ |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
251 @Override |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
252 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
|
253 ArrayList<State> states = new ArrayList<State>(); |
1112
aeae4d20f32f
Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1101
diff
changeset
|
254 states.add(getState()); |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
255 return states; |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
256 } |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
257 |
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
258 |
1072
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
259 /** |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
260 * Get the "current" state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
261 * @param cc ignored. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
262 * @return the "current" state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
263 */ |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
264 @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
|
265 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
|
266 return getState(); |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
267 } |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
268 |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
269 |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
270 /** |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
271 * Get the only possible state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
272 * @return the state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
273 */ |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
274 protected State getState() { |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
275 return getState(null, null); |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
276 } |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
277 |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
278 |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
279 /** |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
280 * Get the state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
281 * @param context ignored. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
282 * @param stateID ignored. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
283 * @return the state. |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
284 */ |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
285 @Override |
80aecb01d79a
Let MainValuesArtifact have a state, outputmode and facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1065
diff
changeset
|
286 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
|
287 if (state != null) |
aeae4d20f32f
Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1101
diff
changeset
|
288 return state; |
aeae4d20f32f
Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1101
diff
changeset
|
289 else |
aeae4d20f32f
Fix translations of Main Values Facets.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1101
diff
changeset
|
290 return spawnState(); |
1078
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
291 } |
048517d67215
Changed state spawning mechanism of MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1074
diff
changeset
|
292 |
6524
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
293 /** |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
294 * 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
|
295 * @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
|
296 * invalid parameterization. |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
297 */ |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
298 protected Gauge getGauge(double km) { |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
299 River river = new RiverAccess((D4EArtifact)this).getRiver(); |
6524
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
300 |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
301 if (river == null) { |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7842
diff
changeset
|
302 log.error("River is null"); |
6524
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
303 return null; |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
304 } |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
305 |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
306 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
|
307 } |
1093
139e7df1787c
Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1089
diff
changeset
|
308 |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
309 /** |
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
|
310 * 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
|
311 * @return the location. |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
312 */ |
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
|
313 public double getLocation() { |
4937
ce7d8e2a7e02
Fixed mainvalues artifact.
Raimund Renkert <rrenkert@intevation.de>
parents:
4845
diff
changeset
|
314 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
|
315 return location; |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
316 } |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
317 |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
318 |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
319 /** |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
320 * Get a list of "Q" main values. |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
321 * @param Array of length 1 (isn't it lovely?) giving the station for |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
322 * which the main values should be returned |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
323 * @return list of Q main values. |
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
324 */ |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
325 public List<NamedDouble> getMainValuesQ(double[] kms, Object pnpObject) { |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
326 if (kms.length > 1) { |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
327 log.error("How did you dare to give an array of lenght >1! " + |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
328 "DAS GEHT GARNICHT!!!! (we'll just take the first value)"); |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
329 } |
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
|
330 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
|
331 Gauge gauge = getGauge(kms[0]); |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
332 River river = new RiverAccess((D4EArtifact)this).getRiver(); |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
333 WstValueTable interpolator = WstValueTableFactory.getTable(river); |
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
|
334 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
|
335 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
|
336 double q_out[] = {0.0f}; |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
337 double pnp = Double.NaN; |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
338 |
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
|
339 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
|
340 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
|
341 List<MainValue> orig = gauge.getMainValues(); |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
342 if (pnpObject instanceof Number) { |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
343 pnp = Double.valueOf(pnpObject.toString()); |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
344 } |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
345 |
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
|
346 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
|
347 if (mv.getMainValue().getType().getName().equals("Q")) { |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
348 if (pnpObject instanceof Number) { |
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
|
349 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
|
350 } |
30c6da3bfc86
In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6532
diff
changeset
|
351 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
|
352 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
|
353 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
|
354 } |
30c6da3bfc86
In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6532
diff
changeset
|
355 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
|
356 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
|
357 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
|
358 )); |
30c6da3bfc86
In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6532
diff
changeset
|
359 } |
30c6da3bfc86
In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6532
diff
changeset
|
360 } |
30c6da3bfc86
In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6532
diff
changeset
|
361 } |
30c6da3bfc86
In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6532
diff
changeset
|
362 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
|
363 } |
30c6da3bfc86
In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6532
diff
changeset
|
364 |
30c6da3bfc86
In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6532
diff
changeset
|
365 /** |
30c6da3bfc86
In analogy to w values allow q values to be calculated at the
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6532
diff
changeset
|
366 * 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
|
367 * @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
|
368 */ |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
369 public List<NamedDouble> getMainValuesQ(Object pnpObject) { |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
370 double kms[] = {getLocation()}; |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
371 return getMainValuesQ(kms, pnpObject); |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
372 } |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
373 |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
374 |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
375 public List<NamedDouble> getMainValuesW(double[] kms, Object pnpObject) { |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
376 List<NamedDouble> filteredList = new ArrayList<NamedDouble>(); |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
377 Gauge gauge = getGauge(kms[0]); |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
378 River river = new RiverAccess((D4EArtifact)this).getRiver(); |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
379 WstValueTable interpolator = WstValueTableFactory.getTable(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
|
380 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
|
381 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
|
382 double q_out[] = {0.0f}; |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
383 double pnp = Double.NaN; |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
384 |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
385 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
|
386 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
|
387 List<MainValue> orig = gauge.getMainValues(); |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
388 if (pnpObject instanceof Number) { |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
389 pnp = Double.valueOf(pnpObject.toString()); |
1085
07878836ee0d
Plot "real" (respecting parameters) W and Q MainValues, yet in wrong scale.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1080
diff
changeset
|
390 } |
1089
e298c4d28927
Improved mainvalues rendering.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1085
diff
changeset
|
391 |
6524
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
392 for (MainValue mv : orig) { |
8724
47199406994a
(issue1801) Determine gauge at a station always with same tolerance.
Tom Gottfried <tom@intevation.de>
parents:
8344
diff
changeset
|
393 Gauge g = river.determineGaugeAtStation(kms[0]); |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
394 if (pnpObject instanceof Number) { |
6524
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
395 if (mv.getMainValue().getType().getName().equals("W")) { |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
396 filteredList.add(new NamedDouble( |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
397 mv.getMainValue().getName(), |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
398 mv.getValue().doubleValue()/100 + pnp |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
399 )); |
6524
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
400 } |
8339
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
401 } |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
402 else if (!(pnpObject instanceof Number) && |
8344
840bc78cd333
Use ws in m for duration curve.
Raimund Renkert <rrenkert@intevation.de>
parents:
8340
diff
changeset
|
403 g != null && |
840bc78cd333
Use ws in m for duration curve.
Raimund Renkert <rrenkert@intevation.de>
parents:
8340
diff
changeset
|
404 !"duration_curve".equals(getBoundToOut()) |
8339
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
405 ) { |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
406 if (mv.getMainValue().getType().getName().equals("W")) { |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
407 filteredList.add(new NamedDouble( |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
408 mv.getMainValue().getName(), |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
409 mv.getValue().doubleValue() |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
410 )); |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
411 } |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
412 } |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
413 else { |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
414 // We cannot interpolate the W values, so derive them |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
415 // from given Q values. |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
416 if (mv.getMainValue().getType().getName().equals("Q")) { |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
417 interpolator.interpolate(mv.getValue().doubleValue(), |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
418 gaugeStation, kms, w_out, q_out, c); |
6524
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
419 |
8339
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
420 filteredList.add(new NamedDouble( |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
421 "W(" + mv.getMainValue().getName() +")", |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
422 w_out[0] |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
423 )); |
d6e71158222a
Look for gauge if no pnp is set in the context and return w in cm if at gauge.
Raimund Renkert <rrenkert@intevation.de>
parents:
8333
diff
changeset
|
424 } |
6524
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
425 } |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
426 } |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
427 } |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
428 return filteredList; |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
429 } |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
430 |
641ec405c4ac
MainValuesArtifact: Added method to determine whether at gauge or not.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6523
diff
changeset
|
431 |
5398
a916e1202f0f
MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5371
diff
changeset
|
432 /** |
6523
5afb1cda5885
Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
433 * Get a list of "W" main values. |
5afb1cda5885
Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
434 * @return list of W main values. |
5afb1cda5885
Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
435 */ |
8331
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
436 public List<NamedDouble> getMainValuesW(Object pnpObject) { |
27d42c9ee367
Main values: Reduce code duplication and correct logic to specify whether we are at gauge or not.
"Tom Gottfried <tom@intevation.de>"
parents:
8316
diff
changeset
|
437 return getMainValuesW(new double[] {getLocation()}, pnpObject); |
6523
5afb1cda5885
Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
438 } |
5afb1cda5885
Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
439 |
5afb1cda5885
Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
440 |
5afb1cda5885
Minor refactoring in MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6101
diff
changeset
|
441 /** |
5398
a916e1202f0f
MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5371
diff
changeset
|
442 * 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
|
443 * |
a916e1202f0f
MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5371
diff
changeset
|
444 * @return 'mainvalue' |
a916e1202f0f
MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5371
diff
changeset
|
445 */ |
a916e1202f0f
MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5371
diff
changeset
|
446 public String getName() { |
a916e1202f0f
MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5371
diff
changeset
|
447 return ARTIFACT_NAME; |
a916e1202f0f
MainValuesArtifact: Override getName to make FacetActivityRegistry working.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5371
diff
changeset
|
448 } |
1047
38088c982db6
Added stub implementation of new MainValuesArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
449 } |
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
|
450 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |