annotate artifacts/src/main/java/org/dive4elements/river/artifacts/StaticWQKmsArtifact.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
parents 0a5239a1e46e
children
rev   line source
5863
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5859
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: 5859
diff changeset
2 * Software engineering by Intevation GmbH
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5859
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: 5859
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: 5859
diff changeset
7 */
4897a58c8746 River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5859
diff changeset
8
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
9 package org.dive4elements.river.artifacts;
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
5798
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
11 import java.awt.geom.Point2D;
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
12
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
13 import java.util.ArrayList;
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import java.util.List;
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
16 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
17 import org.apache.logging.log4j.LogManager;
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import org.w3c.dom.Document;
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
21 import org.dive4elements.artifactdatabase.state.Facet;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
22 import org.dive4elements.artifactdatabase.state.FacetActivity;
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
23
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
24 import org.dive4elements.artifacts.Artifact;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
25 import org.dive4elements.artifacts.ArtifactFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
26 import org.dive4elements.artifacts.CallContext;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
27 import org.dive4elements.artifacts.CallMeta;
5798
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
28
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
29 import org.dive4elements.artifacts.common.utils.XMLUtils;
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
30
5831
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
31 import org.dive4elements.river.artifacts.geom.Lines;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
32
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
33 import org.dive4elements.river.artifacts.model.FacetTypes;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
34 import org.dive4elements.river.model.FastCrossSectionLine;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
35 import org.dive4elements.river.artifacts.model.WKms;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
36 import org.dive4elements.river.artifacts.model.WQKms;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
37 import org.dive4elements.river.artifacts.model.WKmsFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
38 import org.dive4elements.river.artifacts.model.WQKmsFactory;
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
39
bd047b71ab37 Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5803
diff changeset
40 import org.dive4elements.river.artifacts.states.DefaultState;
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 /**
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
44 * Artifact to access additional "waterlevel/discharge"-type of data, like
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
45 * fixation measurements.
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 *
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
47 * This artifact neglects (Static)D4EArtifacts capabilities of interaction
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 * with the StateEngine by overriding the getState*-methods.
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 */
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 public class StaticWQKmsArtifact
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
51 extends StaticD4EArtifact
5798
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
52 implements FacetTypes, WaterLineArtifact
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
54 /** The log for this class. */
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
55 private static Logger log =
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8856
diff changeset
56 LogManager.getLogger(StaticWQKmsArtifact.class);
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 public static final String STATIC_STATE_NAME =
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59 "state.additional_wqkms.static";
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
61 private static final String NAME = "staticwqkms";
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
62
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
63 static {
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
64 // TODO: Move to configuration.
6000
2e57fb04aa6f issue949: staticwqkms/W facets are active.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
65 FacetActivity.Registry.getInstance().register(
2e57fb04aa6f issue949: staticwqkms/W facets are active.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
66 NAME,
2e57fb04aa6f issue949: staticwqkms/W facets are active.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
67 new FacetActivity() {
2e57fb04aa6f issue949: staticwqkms/W facets are active.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
68 @Override
2e57fb04aa6f issue949: staticwqkms/W facets are active.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
69 public Boolean isInitialActive(
2e57fb04aa6f issue949: staticwqkms/W facets are active.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
70 Artifact artifact,
2e57fb04aa6f issue949: staticwqkms/W facets are active.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
71 Facet facet,
2e57fb04aa6f issue949: staticwqkms/W facets are active.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
72 String outputName
2e57fb04aa6f issue949: staticwqkms/W facets are active.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
73 ) {
2e57fb04aa6f issue949: staticwqkms/W facets are active.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
74 String fname = facet.getName();
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
75 return (fname.equals(STATIC_WQKMS)
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
76 || fname.equals(STATIC_WQKMS_W));
6000
2e57fb04aa6f issue949: staticwqkms/W facets are active.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 5994
diff changeset
77 }});
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
78 }
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80 /**
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 * Trivial Constructor.
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 */
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 public StaticWQKmsArtifact() {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
84 log.debug("StaticWQKmsArtifact.StaticWQKmsArtifact");
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 }
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
88 /**
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
89 * Gets called from factory, to set things up.
6598
ca56c4e6a755 Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents: 6000
diff changeset
90 *
ca56c4e6a755 Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents: 6000
diff changeset
91 * If the id's string starts with official- it will be treated as
ca56c4e6a755 Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents: 6000
diff changeset
92 * an Artifact containing official data for the according special
ca56c4e6a755 Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents: 6000
diff changeset
93 * case handling.
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
94 */
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
95 @Override
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
96 public void setup(
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
97 String identifier,
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
98 ArtifactFactory factory,
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
99 Object context,
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 CallMeta callMeta,
7842
8d5ca5175038 Updated signature of artifacts setup method; Removed unnecessary setup overrides.
Raimund Renkert <rrenkert@intevation.de>
parents: 7637
diff changeset
101 Document data,
8d5ca5175038 Updated signature of artifacts setup method; Removed unnecessary setup overrides.
Raimund Renkert <rrenkert@intevation.de>
parents: 7637
diff changeset
102 List<Class> loadFacets)
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
103 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
104 log.debug("StaticWQKmsArtifact.setup");
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
105
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
106 // Store the 'ids' (from datacage).
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
107 if (log.isDebugEnabled()) {
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
108 log.debug("StaticWQKmsArtifact.setup" + XMLUtils.toString(data));
3405
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
109 }
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
110
2741
0251393f037c Refactor usage of now static xpath, other artifacts will follow in later commits.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 2740
diff changeset
111 String code = getDatacageIDValue(data);
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
112 addStringData("ids", code);
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
113 if (code != null) {
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
114 String [] parts = code.split("-");
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
115
6598
ca56c4e6a755 Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents: 6000
diff changeset
116 if (parts.length >= 1) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
117 boolean official = parts[0].toLowerCase()
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8202
diff changeset
118 .startsWith("official");
7637
49a92f7e2017 issue1020: Do not set a data with value null, this breaks stuff further
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 7619
diff changeset
119 addStringData("official", official ? "1" : "0");
6598
ca56c4e6a755 Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents: 6000
diff changeset
120 }
ca56c4e6a755 Mark staticwqkms that are loaded as officiallines recommendation as official
Andre Heinecke <aheinecke@intevation.de>
parents: 6000
diff changeset
121
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
122 if (parts.length >= 4) {
3405
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
123 int col = Integer.parseInt(parts[2]);
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
124 int wst = Integer.parseInt(parts[3]);
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
125
1900
64ffc371afe7 Adjusted implementation to match implementation in StaticWKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1825
diff changeset
126 addStringData("col_pos", parts[2]);
64ffc371afe7 Adjusted implementation to match implementation in StaticWKmsArtifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1825
diff changeset
127 addStringData("wst_id", parts[3]);
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
128 }
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
129 }
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
130
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
131 // Do this AFTER we have set the col_pos etc.
7842
8d5ca5175038 Updated signature of artifacts setup method; Removed unnecessary setup overrides.
Raimund Renkert <rrenkert@intevation.de>
parents: 7637
diff changeset
132 super.setup(identifier, factory, context, callMeta, data, loadFacets);
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
133 }
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
134
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
135
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
136 /**
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
137 * Called via setup.
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
138 *
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
139 * @param artifact The master-artifact.
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
140 */
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
141 @Override
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
142 protected void initialize(
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
143 Artifact artifact,
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
144 Object context,
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
145 CallMeta meta)
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
146 {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
147 log.debug("StaticWQKmsArtifact.initialize");
5867
59ff03ff48f1 River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5863
diff changeset
148 D4EArtifact flys = (D4EArtifact) artifact;
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
149 // TODO: The river is of no interest, so far., also use importData
5798
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
150 importData(flys, "river");
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
151
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
152 List<Facet> fs = new ArrayList<Facet>();
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
153
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
154 DefaultState state = (DefaultState) getCurrentState(context);
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
155 state.computeInit(this, hash(), context, meta, fs);
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2763
diff changeset
156 if (!fs.isEmpty()) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
157 log.debug("Facets to add in StaticWQKmsArtifact.initialize .");
4497
a2735a4bf75e Change facets member variable to private
Björn Ricks <bjoern.ricks@intevation.de>
parents: 3556
diff changeset
158 addFacets(getCurrentStateId(), fs);
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2763
diff changeset
159 }
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2763
diff changeset
160 else {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
161 log.debug("No facets to add in StaticWQKmsArtifact.initialize ("
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
162 + state.getID() + ").");
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
163 }
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
164 }
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
165
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
166
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
167 /**
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
168 * Get WQKms from factory.
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
169 * @return WQKms according to parameterization (can be null);
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
170 */
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
171 public WQKms getWQKms() {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
172 log.debug("StaticWQKmsArtifact.getWQKms");
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
173
3405
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
174 int col = Integer.parseInt(getDataAsString("col_pos"));
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
175 int wst = Integer.parseInt(getDataAsString("wst_id"));
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
176
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
177 /** TODO do not run twice against db to do this. */
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
178 String wkmsName = WKmsFactory.getWKmsName(col, wst);
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
179
3405
b0ba96bbf01d Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
180 WQKms res = WQKmsFactory.getWQKms(col, wst);
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
181 res.setName(wkmsName);
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
182 return res;
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
183 }
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
184
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
185 /** Return specific name. */
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
186 @Override
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
187 public String getName() {
3556
afc7bfb4800b Use the new infrastructure to figure out if a facet should
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3405
diff changeset
188 return NAME;
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
189 }
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
190
5798
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
191
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
192 /**
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
193 * Get points of line describing the surface of water at cross section.
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
194 *
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
195 * @param idx Index of facet and in wkms array.
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
196 * @param csl FastCrossSectionLine to compute water surface agains.
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
197 * @param next The km of the next crosssectionline.
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
198 * @param prev The km of the previous crosssectionline.
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
199 * @param context Ignored in this implementation.
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
200 *
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
201 * @return an array holding coordinates of points of surface of water (
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
202 * in the form {{x1, x2}, {y1, y2}} ).
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
203 */
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
204 @Override
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
205 public Lines.LineData getWaterLines(int idx, FastCrossSectionLine csl,
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
206 double next, double prev, CallContext context
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
207 ) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
208 log.debug("getWaterLines(" + idx + ")/" + identifier());
5798
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
209
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
210 List<Point2D> points = csl.getPoints();
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
211
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
212 WKms wkms = getWQKms();
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
213
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
214 double km = csl.getKm();
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
215
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
216 // Find W at km.
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
217 double wAtKm;
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
218
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
219 // If heightmarks, only deliver if data snaps.
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
220 /*
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
221 if (getDataAsString(DATA_HEIGHT_TYPE) != null &&
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
222 getDataAsString(DATA_HEIGHT_TYPE).equals("true")) {
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
223 wAtKm = getWAtCloseKm(wkms, km, next, prev);
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
224 }
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
225 else {
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
226 */
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
227 wAtKm = StaticWKmsArtifact.getWAtKm(wkms, km);
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
228 //}
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
229
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
230 if (wAtKm == -1 || Double.isNaN(wAtKm)) {
8202
e4606eae8ea5 sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7842
diff changeset
231 log.warn("Waterlevel at km " + km + " unknown.");
5798
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
232 return new Lines.LineData(new double[][] {{}}, 0d, 0d);
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
233 }
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
234
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
235 return Lines.createWaterLines(points, wAtKm);
febeb4bb10a5 StaticWQKmsArtifact: implement WaterLineArtifact .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 4497
diff changeset
236 }
2124
a202a9e048a5 Made StaticWQKmsArtifact a fully featured Artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1900
diff changeset
237 // TODO implement deepCopy.
1825
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
238 }
02cd002205a3 Added 'static' wqkms data access.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
239 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org