Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileMeshCrossOutputState.java @ 443:da21c256a0ba
"horizontale Schnittprofile" are now configured via conf.xml
gnv-artifacts/trunk@491 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 29 Dec 2009 14:54:17 +0000 |
parents | eb2ac62e853a |
children | 4e347624ee7c |
comparison
equal
deleted
inserted
replaced
442:52e031261eaa | 443:da21c256a0ba |
---|---|
34 | 34 |
35 import de.intevation.gnv.utils.DistanceCalculator; | 35 import de.intevation.gnv.utils.DistanceCalculator; |
36 import de.intevation.gnv.utils.WKTUtils; | 36 import de.intevation.gnv.utils.WKTUtils; |
37 import de.intevation.gnv.utils.StringUtils; | 37 import de.intevation.gnv.utils.StringUtils; |
38 | 38 |
39 import de.intevation.gnv.artifacts.context.GNVArtifactContext; | |
40 | |
39 import de.intevation.artifacts.CallContext; | 41 import de.intevation.artifacts.CallContext; |
40 | 42 |
41 import org.jfree.chart.ChartTheme; | 43 import org.jfree.chart.ChartTheme; |
42 | 44 |
43 import com.vividsolutions.jts.geom.Coordinate; | 45 import com.vividsolutions.jts.geom.Coordinate; |
44 | 46 |
45 /** | 47 /** |
46 * @author Tim Englich <tim.englich@intevation.de> | 48 * @author Tim Englich (tim.englich@intevation.de) |
47 * | 49 * @author Ingo Weinzierl (iweinzierl@intevation.de) |
50 * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) | |
48 */ | 51 */ |
49 public class HorizontalProfileMeshCrossOutputState extends | 52 public class HorizontalProfileMeshCrossOutputState extends |
50 HorizontalProfileOutputState { | 53 HorizontalProfileOutputState { |
51 | 54 |
52 /** | 55 /** |
125 } | 128 } |
126 | 129 |
127 return chart; | 130 return chart; |
128 } | 131 } |
129 | 132 |
133 private static int numSamples(CallContext callContext) { | |
134 GNVArtifactContext context = | |
135 (GNVArtifactContext)callContext.globalContext(); | |
136 Integer samples = (Integer)context.get( | |
137 GNVArtifactContext.HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES_KEY); | |
138 return samples != null | |
139 ? samples.intValue() | |
140 : GNVArtifactContext.DEFAULT_HORIZONTAL_CROSS_SECTION_PROFILE_SAMPLES; | |
141 } | |
142 | |
130 @Override | 143 @Override |
131 protected Object getChartResult(String uuid, CallContext callContext) { | 144 protected Object getChartResult(String uuid, CallContext callContext) { |
132 log.debug("HorizontalProfileMeshCrossOutputState.getChartResult"); | 145 log.debug("HorizontalProfileMeshCrossOutputState.getChartResult"); |
133 Collection<Result> result = null; | 146 Collection<Result> result = null; |
134 if (CacheFactory.getInstance().isInitialized()) { | 147 if (CacheFactory.getInstance().isInitialized()) { |
175 .getInstance() | 188 .getInstance() |
176 .getQueryExecutor(); | 189 .getQueryExecutor(); |
177 | 190 |
178 result = process( | 191 result = process( |
179 Arrays.asList(coords), | 192 Arrays.asList(coords), |
193 numSamples(callContext), | |
180 queryExecutor.executeQuery( | 194 queryExecutor.executeQuery( |
181 queryID, | 195 queryID, |
182 addedFilterValues)); | 196 addedFilterValues)); |
183 } | 197 } |
184 catch (QueryException e) { | 198 catch (QueryException e) { |
204 } | 218 } |
205 | 219 |
206 | 220 |
207 public static Collection<Result> process( | 221 public static Collection<Result> process( |
208 List<Coordinate> path, | 222 List<Coordinate> path, |
223 int numSamples, | |
209 Collection<Result> input | 224 Collection<Result> input |
210 ) { | 225 ) { |
211 log.debug("------ number of points before processing: " + input.size()); | 226 boolean debug = log.isDebugEnabled(); |
227 | |
228 if (debug) { | |
229 log.debug("--- number of points before processing: " + input.size()); | |
230 log.debug(" number samples: " + numSamples); | |
231 } | |
232 | |
212 ArrayList<Result> output = new ArrayList<Result>(); | 233 ArrayList<Result> output = new ArrayList<Result>(); |
213 | 234 |
214 Result last = null; | 235 Result last = null; |
215 | 236 |
216 int [] diffColums = null; | 237 int [] diffColums = null; |
237 } | 258 } |
238 } | 259 } |
239 | 260 |
240 sectionHandler = new SectionHandler( | 261 sectionHandler = new SectionHandler( |
241 path, | 262 path, |
263 numSamples, | |
242 output, | 264 output, |
243 resultDescriptor); | 265 resultDescriptor); |
244 | 266 |
245 sectionHandler.setPrototyp(result); | 267 sectionHandler.setPrototyp(result); |
246 } | 268 } |
257 | 279 |
258 if (sectionHandler != null) { | 280 if (sectionHandler != null) { |
259 sectionHandler.finish(); | 281 sectionHandler.finish(); |
260 } | 282 } |
261 | 283 |
262 log.debug("------ number of points after processing: " + output.size()); | 284 if (debug) { |
285 log.debug("--- number of points after processing: " + output.size()); | |
286 } | |
263 | 287 |
264 return output; | 288 return output; |
265 } | 289 } |
266 | 290 |
267 | 291 |
275 "MEDIAN.MESHPOINT.JPOSITION", | 299 "MEDIAN.MESHPOINT.JPOSITION", |
276 "MEDIAN.MESHPOINT.IPOSITION" | 300 "MEDIAN.MESHPOINT.IPOSITION" |
277 }; | 301 }; |
278 | 302 |
279 public static final double EPSILON = 1e-5d; | 303 public static final double EPSILON = 1e-5d; |
280 | |
281 public static final int INTERPOLATION_STEPS = | |
282 Integer.getInteger("interpolation.steps", 500).intValue(); | |
283 | 304 |
284 public static final class SectionHandler | 305 public static final class SectionHandler |
285 implements Interpolation2D.Consumer | 306 implements Interpolation2D.Consumer |
286 { | 307 { |
287 private ArrayList<Point2d> points; | 308 private ArrayList<Point2d> points; |
288 private List<Coordinate> path; | 309 private List<Coordinate> path; |
289 private Collection<Result> output; | 310 private Collection<Result> output; |
290 private Result prototyp; | 311 private Result prototyp; |
291 private ResultDescriptor descriptor; | 312 private ResultDescriptor descriptor; |
292 private boolean lastWasSuccess; | 313 private boolean lastWasSuccess; |
314 private int numSamples; | |
293 | 315 |
294 public SectionHandler() { | 316 public SectionHandler() { |
295 } | 317 } |
296 | 318 |
297 public SectionHandler( | 319 public SectionHandler( |
298 List<Coordinate> path, | 320 List<Coordinate> path, |
321 int numSamples, | |
299 Collection<Result> output, | 322 Collection<Result> output, |
300 ResultDescriptor descriptor | 323 ResultDescriptor descriptor |
301 ) { | 324 ) { |
302 this.path = path; | 325 this.path = path; |
326 this.numSamples = numSamples; | |
303 this.output = output; | 327 this.output = output; |
304 this.descriptor = descriptor; | 328 this.descriptor = descriptor; |
305 points = new ArrayList<Point2d>(); | 329 points = new ArrayList<Point2d>(); |
306 lastWasSuccess = true; | 330 lastWasSuccess = true; |
307 } | 331 } |
316 Interpolation2D.interpolate( | 340 Interpolation2D.interpolate( |
317 path, | 341 path, |
318 points, | 342 points, |
319 0d, | 343 0d, |
320 distance, | 344 distance, |
321 INTERPOLATION_STEPS, | 345 numSamples, |
322 LinearMetrics.INSTANCE, | 346 LinearMetrics.INSTANCE, |
323 this); | 347 this); |
324 } | 348 } |
325 | 349 |
326 points.clear(); | 350 points.clear(); |