annotate artifacts/src/main/java/org/dive4elements/river/artifacts/StaticWKmsArtifact.java @ 7686:7484132b2fbb

issue1577: Add W-Wrapping of wst-names in WKmsFactory if kind is one of a kind.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 12 Dec 2013 07:57:13 +0100
parents 25d890e3eb69
children 8d5ca5175038
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5994
af13ceeba52a Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5867
diff changeset
6 * documentation coming with Dive4Elements River for details.
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
9 package org.dive4elements.river.artifacts;
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
10
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
11 import org.dive4elements.artifactdatabase.state.DefaultOutput;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
12 import org.dive4elements.artifactdatabase.state.Facet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
13 import org.dive4elements.artifactdatabase.state.FacetActivity;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
14 import org.dive4elements.artifactdatabase.state.State;
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
16 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
17 import org.dive4elements.artifacts.ArtifactFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
18 import org.dive4elements.artifacts.CallContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
19 import org.dive4elements.artifacts.CallMeta;
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
21 import org.dive4elements.artifacts.common.utils.XMLUtils;
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
22
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
23 import org.dive4elements.river.artifacts.geom.Lines;
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2088
diff changeset
24
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
25 import org.dive4elements.river.artifacts.math.Distance;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
26 import org.dive4elements.river.artifacts.math.Linear;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
27
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
28 import org.dive4elements.river.artifacts.model.CrossSectionWaterLineFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
29 import org.dive4elements.river.artifacts.model.FacetTypes;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
30 import org.dive4elements.river.artifacts.model.RelativePointFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
31 import org.dive4elements.river.artifacts.model.WKms;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
32 import org.dive4elements.river.artifacts.model.WKmsFacet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
33 import org.dive4elements.river.artifacts.model.WKmsFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
34
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
35 import org.dive4elements.river.artifacts.resources.Resources;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
36
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
37 import org.dive4elements.river.artifacts.states.StaticState;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
38
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 4497
diff changeset
39 import org.dive4elements.river.model.FastCrossSectionLine;
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
40
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
41 import java.awt.geom.Point2D;
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
42
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 import java.util.ArrayList;
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 import java.util.List;
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 import org.apache.log4j.Logger;
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 import org.w3c.dom.Document;
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 * Artifact to access additional "waterlevel"-type of data, like the height
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 * of protective measures (dikes).
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
54 * This artifact neglects (Static)D4EArtifacts capabilities of interaction
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 * with the StateEngine by overriding the getState*-methods.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 public class StaticWKmsArtifact
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
58 extends StaticD4EArtifact
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
59 implements FacetTypes, WaterLineArtifact
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60 {
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 /** The logger for this class. */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 private static Logger logger =
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 Logger.getLogger(StaticWKmsArtifact.class);
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
65 private static final String NAME = "staticwkms";
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
66
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
67 static {
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
68 // TODO: Move to configuration.
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
69 FacetActivity.Registry.getInstance()
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
70 .register(NAME, FacetActivity.INACTIVE);
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
71 }
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72
1771
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
73 public static final String STATIC_STATE_NAME =
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
74 "state.additional_wkms.static";
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
75
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
76 /** Data Item name to know whether we are Heighmarks and reveive
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
77 * some data slightly different. */
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
78 public static final String DATA_HEIGHT_TYPE =
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
79 "height_marks";
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
80
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 /** One and only state to be in. */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 protected transient State state = null;
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 * Trivial Constructor.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
88 public StaticWKmsArtifact() {
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
89 logger.debug("StaticWKmsArtifact.StaticWKmsArtifact");
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
90 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
91
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
92 @Override
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
93 public String getName() {
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
94 return NAME;
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
95 }
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
96
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
97 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
98 * Gets called from factory, to set things up.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
99 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 @Override
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 public void setup(
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102 String identifier,
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
103 ArtifactFactory factory,
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
104 Object context,
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
105 CallMeta callMeta,
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
106 Document data)
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
107 {
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
108 logger.debug("StaticWKmsArtifact.setup");
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
109
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);
1725
d9afb16d1fd4 Store parameterization in data, not in fields.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1723
diff changeset
111
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
112 if (logger.isDebugEnabled()) {
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
113 logger.debug(XMLUtils.toString(data));
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
114 }
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
115
1771
c62ff9e72cea Restore mapping of state id to facets (revert, rev 3083 and 3088).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1765
diff changeset
116 List<Facet> fs = new ArrayList<Facet>();
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
117 String code = getDatacageIDValue(data);
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
118
1725
d9afb16d1fd4 Store parameterization in data, not in fields.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1723
diff changeset
119 // TODO Go for JSON, one day.
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
120 //ex.: flood_protection-wstv-114-12
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
121 if (code != null) {
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
122 String [] parts = code.split("-");
1725
d9afb16d1fd4 Store parameterization in data, not in fields.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1723
diff changeset
123
d9afb16d1fd4 Store parameterization in data, not in fields.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1723
diff changeset
124 if (parts.length >= 4) {
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
125 int col = -1;
3405
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3284
diff changeset
126 int wst = Integer.parseInt(parts[3]);
1729
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
127
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
128 if (!parts[2].equals("A")) {
3405
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3284
diff changeset
129 col = Integer.parseInt(parts[2]);
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
130 }
1729
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
131
3804
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
132 addStringData("col_pos", parts[2]);
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
133 addStringData("wst_id", parts[3]);
1815
a97764363ba2 Apply point theme to heightmark data imported via datacage to longitudinal section diagram.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1809
diff changeset
134
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
135 String wkmsName;
2088
701658081f4f Fix name for certain facets loaded via datacage.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1981
diff changeset
136 if (col >= 0) {
7686
7484132b2fbb issue1577: Add W-Wrapping of wst-names in WKmsFactory if kind is one
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7524
diff changeset
137 // The W-Wrapping could be done in here (like in
7484132b2fbb issue1577: Add W-Wrapping of wst-names in WKmsFactory if kind is one
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7524
diff changeset
138 // StaticWQKmsArtifact), with benefit of i18nation,
7484132b2fbb issue1577: Add W-Wrapping of wst-names in WKmsFactory if kind is one
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7524
diff changeset
139 // but slower execution (it wrappes based on kind
7484132b2fbb issue1577: Add W-Wrapping of wst-names in WKmsFactory if kind is one
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7524
diff changeset
140 // which can be fetched in same sql query).
7484132b2fbb issue1577: Add W-Wrapping of wst-names in WKmsFactory if kind is one
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7524
diff changeset
141 wkmsName = WKmsFactory.getWKmsNameWWrapped(col, wst);
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
142 }
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
143 else {
7686
7484132b2fbb issue1577: Add W-Wrapping of wst-names in WKmsFactory if kind is one
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7524
diff changeset
144 wkmsName = WKmsFactory.getWKmsNameWWrapped(wst);
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
145 }
3804
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
146
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
147 String name;
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
148 if (parts[0].equals(HEIGHTMARKS_POINTS)) {
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
149 name = HEIGHTMARKS_POINTS;
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
150 addStringData(DATA_HEIGHT_TYPE, "true");
1725
d9afb16d1fd4 Store parameterization in data, not in fields.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1723
diff changeset
151 }
4143
58864f4f6e3b Fix issue946 (own style for wkms annotation facets in wq diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4031
diff changeset
152 else if (parts[0].equals("additionalsmarks")) {
58864f4f6e3b Fix issue946 (own style for wkms annotation facets in wq diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4031
diff changeset
153 name = STATIC_WKMS_MARKS;
58864f4f6e3b Fix issue946 (own style for wkms annotation facets in wq diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4031
diff changeset
154 }
7524
25d890e3eb69 issue1664: Let DC instruct StaticWKmsArtifact to spawn facets
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6573
diff changeset
155 else if (parts[0].equals("delta_w")) {
25d890e3eb69 issue1664: Let DC instruct StaticWKmsArtifact to spawn facets
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6573
diff changeset
156 name = STATIC_DELTA_W;
25d890e3eb69 issue1664: Let DC instruct StaticWKmsArtifact to spawn facets
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6573
diff changeset
157 }
25d890e3eb69 issue1664: Let DC instruct StaticWKmsArtifact to spawn facets
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6573
diff changeset
158 else if (parts[0].equals("delta_w_cma")) {
25d890e3eb69 issue1664: Let DC instruct StaticWKmsArtifact to spawn facets
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6573
diff changeset
159 name = STATIC_DELTA_W_CMA;
25d890e3eb69 issue1664: Let DC instruct StaticWKmsArtifact to spawn facets
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6573
diff changeset
160 }
3804
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
161 else {
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
162 name = STATIC_WKMS;
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
163 }
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
164
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
165 String facetDescription = Resources.getMsg(
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
166 callMeta, wkmsName, wkmsName);
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
167 Facet wKmsFacet = new WKmsFacet(
3804
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
168 name,
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
169 facetDescription);
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
170 Facet csFacet = new CrossSectionWaterLineFacet(0,
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
171 facetDescription);
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
172 Facet rpFacet = new RelativePointFacet(facetDescription);
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
173
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
174 fs.add(wKmsFacet);
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
175 fs.add(csFacet);
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
176 fs.add(rpFacet);
4497
a2735a4bf75e Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4478
diff changeset
177 addFacets(state.getID(), fs);
1725
d9afb16d1fd4 Store parameterization in data, not in fields.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1723
diff changeset
178 }
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
179 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
180
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
181 spawnState();
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
182 super.setup(identifier, factory, context, callMeta, data);
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
183 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
184
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
185
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
186 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
187 * Initialize the static state with output.
1725
d9afb16d1fd4 Store parameterization in data, not in fields.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1723
diff changeset
188 * @return static state
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
189 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
190 protected State spawnState() {
1787
f3be8fa1ec62 Cosmetics, added simpler constructor for StaticState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1771
diff changeset
191 state = new StaticState(STATIC_STATE_NAME);
4497
a2735a4bf75e Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4478
diff changeset
192 List<Facet> fs = getFacets(STATIC_STATE_NAME);
3804
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
193 DefaultOutput output = new DefaultOutput(
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
194 "general",
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
195 "general", "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
196 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: 1749
diff changeset
197 "chart");
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
198
3804
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
199 state.getOutputs().add(output);
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
200 return state;
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
201 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
202
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
203
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
204 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
205 * Called via setup.
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
206 *
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1787
diff changeset
207 * @param artifact The master-artifact.
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
208 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
209 @Override
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
210 protected void initialize(
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1787
diff changeset
211 Artifact artifact,
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1787
diff changeset
212 Object context,
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1787
diff changeset
213 CallMeta meta)
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1787
diff changeset
214 {
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
215 logger.debug("StaticWKmsArtifact.initialize");
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
216 D4EArtifact winfo = (D4EArtifact) artifact;
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
217 // TODO: The river is of no interest, so far.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
218 addData("river", winfo.getData("river"));
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
219 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
220
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
221
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
222 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
223 * Get a list containing the one and only State.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
224 * @param context ignored.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
225 * @return list with one and only state.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
226 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
227 @Override
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
228 protected List<State> getStates(Object context) {
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
229 ArrayList<State> states = new ArrayList<State>();
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
230 states.add(getState());
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
231 return states;
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
232 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
233
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
234
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
235 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
236 * Get the "current" state (there is but one).
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
237 * @param cc ignored.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
238 * @return the "current" (only possible) state.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
239 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
240 @Override
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
241 public State getCurrentState(Object cc) {
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
242 return getState();
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
243 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
244
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
245
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
246 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
247 * Get the only possible state.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
248 * @return the state.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
249 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
250 protected State getState() {
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
251 return getState(null, null);
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
252 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
253
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
254
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
255 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
256 * Get the state.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
257 * @param context ignored.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
258 * @param stateID ignored.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
259 * @return the state.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
260 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
261 @Override
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
262 protected State getState(Object context, String stateID) {
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
263 return (state != null)
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1787
diff changeset
264 ? state
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1787
diff changeset
265 : spawnState();
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
266 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
267
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
268
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
269 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
270 * Get WKms from factory.
3284
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3273
diff changeset
271 * @param idx param is not needed (TODO?)
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
272 * @return WKms according to parameterization (can be null);
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
273 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
274 public WKms getWKms(int idx) {
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
275 logger.debug("StaticWKmsArtifact.getWKms");
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
276
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
277 return WKmsFactory.getWKms(
3405
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3284
diff changeset
278 Integer.parseInt(getDataAsString("col_pos")),
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3284
diff changeset
279 Integer.parseInt(getDataAsString("wst_id")));
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
280 }
1729
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
281
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
282
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
283 /**
2745
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
284 * Returns W at Km of WKms, linearly interpolated.
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
285 * Returns -1 if not found.
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
286 */
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
287 public static double getWAtKmLin(WKms wkms, double km) {
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
288 // Uninformed search.
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
289 int size = wkms.size();
4031
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
290 if (size == 0) {
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
291 return -1;
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
292 }
2745
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
293 int idx = 0;
4031
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
294
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
295 boolean kmIncreasing;
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
296 if (size == 1) {
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
297 kmIncreasing = true;
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
298 }
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
299 else {
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
300 kmIncreasing = (wkms.getKm(0) < wkms.getKm(wkms.size()-1))
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
301 ? true : false;
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
302 }
2745
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
303 if (kmIncreasing) {
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
304 while (idx < size && wkms.getKm(idx) < km) {
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
305 idx++;
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
306 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
307 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
308 else {
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
309 idx = wkms.size() -1;
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
310 while (idx > 0 && wkms.getKm(idx) > km) {
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
311 idx--;
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
312 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
313 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
314
4031
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
315 if (wkms.getKm(idx) == km) {
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
316 return wkms.getW(idx);
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
317 }
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
318
2745
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
319 if (idx == size -1 || idx == 0) {
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
320 return -1;
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
321 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
322
6573
7d86ed4537d9 Cosmetics, doc, obsolete import removal.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
323 // Do linear interpolation.
2745
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
324 int mod = kmIncreasing ? -1 : +1;
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
325 return Linear.linear(km, wkms.getKm(idx+mod), wkms.getKm(idx), wkms.getW(idx+mod), wkms.getW(idx));
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
326 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
327
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
328
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
329 /**
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
330 * Get the W at a specific km, only if it is closer to km than to any of
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
331 * the other given km.
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
332 * Return Double.NaN otherwise
1729
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
333 *
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
334 * @param wkms WKms in which to search for a spatially close W value.
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
335 * @param km the input km, which is compared to values from wkms.
3273
739aa90eb79e Fix issue694.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3272
diff changeset
336 * @param next the next available input km (-1 if unavailable).
739aa90eb79e Fix issue694.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3272
diff changeset
337 * @param prev the previous available input km (-1 if unavailable).
1729
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
338 *
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
339 * @return W in wkms that is closer to km than to next and prev, or Double.NaN.
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
340 */
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
341 public double getWAtCloseKm(WKms wkms, double km, double next, double prev) {
3903
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
342 // TODO symbolic "-1" pr next/prev is a bad idea (tm), as we compare
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
343 // distances to these values later.
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
344 // TODO issue888
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
345
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
346 int size = wkms.size();
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
347 for (int i = 0; i < size; i++) {
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
348 double wkmsKm = wkms.getKm(i);
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
349 double dist = Distance.distance(wkmsKm, km);
3903
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
350 if (dist == 0d) {
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
351 return wkms.getW(i);
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
352 }
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
353
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
354 // Problematic Cases:
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
355 // X == km , | and | == prev and next, (?) == wkmsKm
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
356 //
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
357 // Standard case:
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
358 // ----------|----X-----|-------
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
359 // (1) (2) (3) (4)
3909
fe70edde0897 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3903
diff changeset
360 //
3903
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
361 // With prev==-1
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
362 // -1 ------X-------|------
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
363 // (5) (6) (7)
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
364 //
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
365 // With next==-1
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
366 //
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
367 // ---|-----X----- -1
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
368 // (8) (9) (10)
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
369
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
370 if (dist <= Distance.distance(wkmsKm, prev)
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
371 && dist <= Distance.distance(wkmsKm, next)) {
3273
739aa90eb79e Fix issue694.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3272
diff changeset
372 return wkms.getW(i);
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
373 }
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
374 }
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
375
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
376 return Double.NaN;
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
377 }
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
378
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
379
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
380 /**
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
381 * Returns W at Km of WKms, searching linearly.
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
382 * Returns -1 if not found.
3044
37982acfe1a3 Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
383 * @param wkms the WKms object to search for given km.
37982acfe1a3 Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
384 * @param km The searched km.
37982acfe1a3 Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
385 * @return W at given km if in WKms, -1 if not found.
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
386 */
2745
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
387 public static double getWAtKm(WKms wkms, double km) {
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
388 // Uninformed search, intolerant.
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
389 double TOLERANCE = 0.0d;
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
390 int size = wkms.size();
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
391 for (int i = 0; i < size; i++) {
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
392 if (Distance.within(wkms.getKm(i), km, TOLERANCE)) {
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
393 return wkms.getW(i);
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
394 }
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
395 }
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
396
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
397 return -1;
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
398 }
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
399
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
400
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
401 /**
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
402 * Get points of line describing the surface of water at cross section.
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
403 *
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
404 * @param idx Index of facet and in wkms array.
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
405 * @param csl FastCrossSectionLine to compute water surface agains.
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
406 * @param next The km of the next crosssectionline.
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
407 * @param prev The km of the previous crosssectionline.
4478
6153c50f78cf WaterLineArtifact: Added callcontext-parameter to interfaces getWaterLine.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4143
diff changeset
408 * @param context Ignored in this implementation.
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
409 *
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
410 * @return an array holding coordinates of points of surface of water (
3044
37982acfe1a3 Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
411 * in the form {{x1, x2}, {y1, y2}} ).
1729
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
412 */
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
413 @Override
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
414 public Lines.LineData getWaterLines(int idx, FastCrossSectionLine csl,
4478
6153c50f78cf WaterLineArtifact: Added callcontext-parameter to interfaces getWaterLine.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4143
diff changeset
415 double next, double prev, CallContext context
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
416 ) {
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
417 logger.debug("getWaterLines(" + idx + ")/" + identifier());
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
418
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2088
diff changeset
419 List<Point2D> points = csl.getPoints();
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
420
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
421 WKms wkms = getWKms(0);
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
422
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2088
diff changeset
423 double km = csl.getKm();
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
424
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
425 // Find W at km.
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
426 double wAtKm;
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
427
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
428 // If heightmarks, only deliver if data snaps.
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
429 if (getDataAsString(DATA_HEIGHT_TYPE) != null &&
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
430 getDataAsString(DATA_HEIGHT_TYPE).equals("true")) {
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
431 wAtKm = getWAtCloseKm(wkms, km, next, prev);
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
432 }
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
433 else {
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
434 wAtKm = getWAtKm(wkms, km);
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
435 }
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
436
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
437 if (wAtKm == -1 || Double.isNaN(wAtKm)) {
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
438 logger.warn("Waterlevel at km " + km + " unknown.");
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
439 return new Lines.LineData(new double[][] {{}}, 0d, 0d);
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
440 }
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
441
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
442 return Lines.createWaterLines(points, wAtKm);
1729
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
443 }
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
444 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
445 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org