annotate artifacts/src/main/java/org/dive4elements/river/artifacts/StaticWKmsArtifact.java @ 7524:25d890e3eb69

issue1664: Let DC instruct StaticWKmsArtifact to spawn facets for cm and cm/a axis for delta ws from fix analysis.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 06 Nov 2013 12:07:48 +0100
parents 7d86ed4537d9
children 7484132b2fbb
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) {
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
137 wkmsName = WKmsFactory.getWKmsName(col, wst);
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
138 }
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
139 else {
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
140 wkmsName = WKmsFactory.getWKmsName(wst);
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
141 }
3804
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
142
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
143 String name;
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
144 if (parts[0].equals(HEIGHTMARKS_POINTS)) {
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
145 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
146 addStringData(DATA_HEIGHT_TYPE, "true");
1725
d9afb16d1fd4 Store parameterization in data, not in fields.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1723
diff changeset
147 }
4143
58864f4f6e3b Fix issue946 (own style for wkms annotation facets in wq diagrams).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4031
diff changeset
148 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
149 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
150 }
7524
25d890e3eb69 issue1664: Let DC instruct StaticWKmsArtifact to spawn facets
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6573
diff changeset
151 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
152 name = STATIC_DELTA_W;
25d890e3eb69 issue1664: Let DC instruct StaticWKmsArtifact to spawn facets
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6573
diff changeset
153 }
25d890e3eb69 issue1664: Let DC instruct StaticWKmsArtifact to spawn facets
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6573
diff changeset
154 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
155 name = STATIC_DELTA_W_CMA;
25d890e3eb69 issue1664: Let DC instruct StaticWKmsArtifact to spawn facets
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 6573
diff changeset
156 }
3804
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
157 else {
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
158 name = STATIC_WKMS;
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
159 }
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
160
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
161 String facetDescription = Resources.getMsg(
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
162 callMeta, wkmsName, wkmsName);
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
163 Facet wKmsFacet = new WKmsFacet(
3804
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
164 name,
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
165 facetDescription);
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
166 Facet csFacet = new CrossSectionWaterLineFacet(0,
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
167 facetDescription);
2743
10e6400d4166 Added (dummy-) implementation of relative point facet in staticwkms case.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2673
diff changeset
168 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
169
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
170 fs.add(wKmsFacet);
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
171 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
172 fs.add(rpFacet);
4497
a2735a4bf75e Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents: 4478
diff changeset
173 addFacets(state.getID(), fs);
1725
d9afb16d1fd4 Store parameterization in data, not in fields.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1723
diff changeset
174 }
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
175 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
176
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
177 spawnState();
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
178 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
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
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
182 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
183 * 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
184 * @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
185 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
186 protected State spawnState() {
1787
f3be8fa1ec62 Cosmetics, added simpler constructor for StaticState.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1771
diff changeset
187 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
188 List<Facet> fs = getFacets(STATIC_STATE_NAME);
3804
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
189 DefaultOutput output = new DefaultOutput(
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
190 "general",
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
191 "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
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: 1749
diff changeset
193 "chart");
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
194
3804
bfaa5578e79d Picked rev3180 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1826
diff changeset
195 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
196 return state;
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
197 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
198
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
199
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
200 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
201 * 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
202 *
f6a190f6aaff Give outputname to artifacts getInitialFacetActivity, generate second pair of MainvalueFacets for discharge curves.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1787
diff changeset
203 * @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
204 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
205 @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
206 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
207 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
208 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
209 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
210 {
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
211 logger.debug("StaticWKmsArtifact.initialize");
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
212 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
213 // 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
214 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
215 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
216
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
217
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
218 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
219 * 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
220 * @param context ignored.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
221 * @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
222 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
223 @Override
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
224 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
225 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
226 states.add(getState());
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
227 return states;
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
228 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
229
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
230
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
231 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
232 * 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
233 * @param cc ignored.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
234 * @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
235 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
236 @Override
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
237 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
238 return getState();
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
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
241
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
242 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
243 * 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
244 * @return the state.
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 protected State getState() {
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
247 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
248 }
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
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
251 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
252 * Get the state.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
253 * @param context ignored.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
254 * @param stateID ignored.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
255 * @return the state.
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
256 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
257 @Override
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
258 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
259 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
260 ? 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
261 : spawnState();
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
262 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
263
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
264
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
265 /**
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
266 * Get WKms from factory.
3284
d9af29a4bb85 Various cosmetic doc fixes.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3273
diff changeset
267 * @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
268 * @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
269 */
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
270 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
271 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
272
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
273 return WKmsFactory.getWKms(
3405
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3284
diff changeset
274 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
275 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
276 }
1729
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
277
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
278
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
diff changeset
279 /**
2745
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
280 * 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
281 * 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
282 */
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
283 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
284 // Uninformed search.
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
285 int size = wkms.size();
4031
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
286 if (size == 0) {
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
287 return -1;
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
288 }
2745
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
289 int idx = 0;
4031
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
290
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
291 boolean kmIncreasing;
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
292 if (size == 1) {
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
293 kmIncreasing = true;
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 else {
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
296 kmIncreasing = (wkms.getKm(0) < wkms.getKm(wkms.size()-1))
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
297 ? true : false;
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
298 }
2745
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
299 if (kmIncreasing) {
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
300 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
301 idx++;
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
302 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
303 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
304 else {
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
305 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
306 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
307 idx--;
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
308 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
309 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
310
4031
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
311 if (wkms.getKm(idx) == km) {
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
312 return wkms.getW(idx);
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
313 }
e4e345d81a65 issue889/2
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3975
diff changeset
314
2745
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
315 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
316 return -1;
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
317 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
318
6573
7d86ed4537d9 Cosmetics, doc, obsolete import removal.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
319 // 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
320 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
321 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
322 }
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
323
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
324
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
325 /**
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
326 * 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
327 * 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
328 * Return Double.NaN otherwise
1729
2e5ebdeb8af9 Give StaticWKmsArtifacts proper names, and pre-deselect them.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1726
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 * @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
331 * @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
332 * @param next the next available input km (-1 if unavailable).
739aa90eb79e Fix issue694.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3272
diff changeset
333 * @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
334 *
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
335 * @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
336 */
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
337 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
338 // 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
339 // distances to these values later.
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
340 // TODO issue888
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
341
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
342 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
343 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
344 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
345 double dist = Distance.distance(wkmsKm, km);
3903
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
346 if (dist == 0d) {
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
347 return wkms.getW(i);
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
348 }
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
349
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
350 // Problematic Cases:
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
351 // X == km , | and | == prev and next, (?) == wkmsKm
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 // Standard case:
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
354 // ----------|----X-----|-------
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
355 // (1) (2) (3) (4)
3909
fe70edde0897 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3903
diff changeset
356 //
3903
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
357 // With prev==-1
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
358 // -1 ------X-------|------
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
359 // (5) (6) (7)
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
360 //
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
361 // With next==-1
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
362 //
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
363 // ---|-----X----- -1
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
364 // (8) (9) (10)
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
365
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
366 if (dist <= Distance.distance(wkmsKm, prev)
0623cdf32b38 Document issue880
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3556
diff changeset
367 && dist <= Distance.distance(wkmsKm, next)) {
3273
739aa90eb79e Fix issue694.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3272
diff changeset
368 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
369 }
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
370 }
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
371
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
372 return Double.NaN;
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 /**
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
377 * Returns W at Km of WKms, searching linearly.
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
378 * Returns -1 if not found.
3044
37982acfe1a3 Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
379 * @param wkms the WKms object to search for given km.
37982acfe1a3 Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
380 * @param km The searched km.
37982acfe1a3 Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2763
diff changeset
381 * @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
382 */
2745
b63017afbca8 Add helper to allow for points at duration curve facet.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2743
diff changeset
383 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
384 // Uninformed search, intolerant.
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
385 double TOLERANCE = 0.0d;
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
386 int size = wkms.size();
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
387 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
388 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
389 return wkms.getW(i);
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
390 }
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
391 }
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
392
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
393 return -1;
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 /**
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
398 * 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
399 *
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
400 * @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
401 * @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
402 * @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
403 * @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
404 * @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
405 *
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
406 * @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
407 * 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
408 */
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
409 @Override
3272
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
410 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
411 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
412 ) {
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
413 logger.debug("getWaterLines(" + idx + ")/" + identifier());
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
414
2120
f021080cb409 Use improved caching for cross section lines data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2088
diff changeset
415 List<Point2D> points = csl.getPoints();
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
416
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
417 WKms wkms = getWKms(0);
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 double km = csl.getKm();
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 // 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
422 double wAtKm;
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
423
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
424 // 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
425 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
426 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
427 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
428 }
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
429 else {
31168ac9c7e7 Partial fix for issue694 (heightmarks snap to nearest cross section).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3227
diff changeset
430 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
431 }
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 if (wAtKm == -1 || Double.isNaN(wAtKm)) {
1981
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
434 logger.warn("Waterlevel at km " + km + " unknown.");
2673
0143b44631cc Beginnings of mittlere hoehe calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2652
diff changeset
435 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
436 }
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
437
bf62cc7052d4 Implement and use WaterLineArtifact interface.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1843
diff changeset
438 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
439 }
1723
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
440 }
690037105542 Added new Artifact and Facet to access 'static' data via WKmsFactory.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
441 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org