Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWQKmsArtifact.java @ 5798:febeb4bb10a5
StaticWQKmsArtifact: implement WaterLineArtifact .
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 24 Apr 2013 08:21:52 +0200 |
parents | a2735a4bf75e |
children | 948be49754c5 |
comparison
equal
deleted
inserted
replaced
5797:cce12c06466f | 5798:febeb4bb10a5 |
---|---|
1 package de.intevation.flys.artifacts; | 1 package de.intevation.flys.artifacts; |
2 | |
3 import java.awt.geom.Point2D; | |
2 | 4 |
3 import java.util.ArrayList; | 5 import java.util.ArrayList; |
4 import java.util.List; | 6 import java.util.List; |
5 | 7 |
6 import org.apache.log4j.Logger; | 8 import org.apache.log4j.Logger; |
10 import de.intevation.artifactdatabase.state.Facet; | 12 import de.intevation.artifactdatabase.state.Facet; |
11 import de.intevation.artifactdatabase.state.FacetActivity; | 13 import de.intevation.artifactdatabase.state.FacetActivity; |
12 | 14 |
13 import de.intevation.artifacts.Artifact; | 15 import de.intevation.artifacts.Artifact; |
14 import de.intevation.artifacts.ArtifactFactory; | 16 import de.intevation.artifacts.ArtifactFactory; |
17 import de.intevation.artifacts.CallContext; | |
15 import de.intevation.artifacts.CallMeta; | 18 import de.intevation.artifacts.CallMeta; |
16 | 19 |
17 import de.intevation.artifacts.common.utils.XMLUtils; | 20 import de.intevation.artifacts.common.utils.XMLUtils; |
18 | 21 |
22 import de.intevation.flys.artifacts.geom.Lines; | |
23 import de.intevation.flys.artifacts.math.Distance; | |
24 | |
19 import de.intevation.flys.artifacts.model.FacetTypes; | 25 import de.intevation.flys.artifacts.model.FacetTypes; |
26 import de.intevation.flys.model.FastCrossSectionLine; | |
27 import de.intevation.flys.artifacts.model.WKms; | |
20 import de.intevation.flys.artifacts.model.WQKms; | 28 import de.intevation.flys.artifacts.model.WQKms; |
21 import de.intevation.flys.artifacts.model.WKmsFactory; | 29 import de.intevation.flys.artifacts.model.WKmsFactory; |
30 import de.intevation.flys.artifacts.model.WQKmsFacet; | |
22 import de.intevation.flys.artifacts.model.WQKmsFactory; | 31 import de.intevation.flys.artifacts.model.WQKmsFactory; |
23 | 32 |
24 import de.intevation.flys.artifacts.states.DefaultState; | 33 import de.intevation.flys.artifacts.states.DefaultState; |
25 | 34 |
26 | 35 |
31 * This artifact neglects (Static)FLYSArtifacts capabilities of interaction | 40 * This artifact neglects (Static)FLYSArtifacts capabilities of interaction |
32 * with the StateEngine by overriding the getState*-methods. | 41 * with the StateEngine by overriding the getState*-methods. |
33 */ | 42 */ |
34 public class StaticWQKmsArtifact | 43 public class StaticWQKmsArtifact |
35 extends StaticFLYSArtifact | 44 extends StaticFLYSArtifact |
36 implements FacetTypes | 45 implements FacetTypes, WaterLineArtifact |
37 { | 46 { |
38 /** The logger for this class. */ | 47 /** The logger for this class. */ |
39 private static Logger logger = | 48 private static Logger logger = |
40 Logger.getLogger(StaticWQKmsArtifact.class); | 49 Logger.getLogger(StaticWQKmsArtifact.class); |
41 | 50 |
105 Artifact artifact, | 114 Artifact artifact, |
106 Object context, | 115 Object context, |
107 CallMeta meta) | 116 CallMeta meta) |
108 { | 117 { |
109 logger.debug("StaticWQKmsArtifact.initialize"); | 118 logger.debug("StaticWQKmsArtifact.initialize"); |
110 WINFOArtifact winfo = (WINFOArtifact) artifact; | 119 FLYSArtifact flys = (FLYSArtifact) artifact; |
111 // TODO: The river is of no interest, so far., also use importData | 120 // TODO: The river is of no interest, so far., also use importData |
112 importData(winfo, "river"); | 121 importData(flys, "river"); |
113 | 122 |
114 List<Facet> fs = new ArrayList<Facet>(); | 123 List<Facet> fs = new ArrayList<Facet>(); |
115 | 124 |
116 DefaultState state = (DefaultState) getCurrentState(context); | 125 DefaultState state = (DefaultState) getCurrentState(context); |
117 state.computeInit(this, hash(), context, meta, fs); | 126 state.computeInit(this, hash(), context, meta, fs); |
148 @Override | 157 @Override |
149 public String getName() { | 158 public String getName() { |
150 return NAME; | 159 return NAME; |
151 } | 160 } |
152 | 161 |
162 | |
163 /** | |
164 * Get points of line describing the surface of water at cross section. | |
165 * | |
166 * @param idx Index of facet and in wkms array. | |
167 * @param csl FastCrossSectionLine to compute water surface agains. | |
168 * @param next The km of the next crosssectionline. | |
169 * @param prev The km of the previous crosssectionline. | |
170 * @param context Ignored in this implementation. | |
171 * | |
172 * @return an array holding coordinates of points of surface of water ( | |
173 * in the form {{x1, x2}, {y1, y2}} ). | |
174 */ | |
175 @Override | |
176 public Lines.LineData getWaterLines(int idx, FastCrossSectionLine csl, | |
177 double next, double prev, CallContext context | |
178 ) { | |
179 logger.debug("getWaterLines(" + idx + ")/" + identifier()); | |
180 | |
181 List<Point2D> points = csl.getPoints(); | |
182 | |
183 WKms wkms = getWQKms(); | |
184 | |
185 double km = csl.getKm(); | |
186 | |
187 // Find W at km. | |
188 double wAtKm; | |
189 | |
190 // If heightmarks, only deliver if data snaps. | |
191 /* | |
192 if (getDataAsString(DATA_HEIGHT_TYPE) != null && | |
193 getDataAsString(DATA_HEIGHT_TYPE).equals("true")) { | |
194 wAtKm = getWAtCloseKm(wkms, km, next, prev); | |
195 } | |
196 else { | |
197 */ | |
198 wAtKm = StaticWKmsArtifact.getWAtKm(wkms, km); | |
199 //} | |
200 | |
201 if (wAtKm == -1 || Double.isNaN(wAtKm)) { | |
202 logger.warn("Waterlevel at km " + km + " unknown."); | |
203 return new Lines.LineData(new double[][] {{}}, 0d, 0d); | |
204 } | |
205 | |
206 return Lines.createWaterLines(points, wAtKm); | |
207 } | |
153 // TODO implement deepCopy. | 208 // TODO implement deepCopy. |
154 } | 209 } |
155 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : | 210 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |