Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java @ 482:64e65daa65e9
Fixed some bugs with calculating "Horizontalschnitte".
gnv-artifacts/trunk@557 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 17 Jan 2010 21:26:21 +0000 |
parents | 20dde2b6f1b5 |
children | 823e4f808418 |
comparison
equal
deleted
inserted
replaced
481:20dde2b6f1b5 | 482:64e65daa65e9 |
---|---|
22 | 22 |
23 import de.intevation.gnv.geobackend.base.query.exception.QueryException; | 23 import de.intevation.gnv.geobackend.base.query.exception.QueryException; |
24 | 24 |
25 import de.intevation.gnv.geobackend.sde.datasources.RasterObject; | 25 import de.intevation.gnv.geobackend.sde.datasources.RasterObject; |
26 | 26 |
27 import de.intevation.gnv.math.AreaInterpolation; | |
27 import de.intevation.gnv.math.AttributedPoint2ds; | 28 import de.intevation.gnv.math.AttributedPoint2ds; |
29 import de.intevation.gnv.math.Point2d; | |
30 import de.intevation.gnv.math.QueriedXYDepth; | |
28 | 31 |
29 import de.intevation.gnv.state.InputData; | 32 import de.intevation.gnv.state.InputData; |
30 import de.intevation.gnv.state.OutputStateBase; | 33 import de.intevation.gnv.state.OutputStateBase; |
31 | 34 |
32 import de.intevation.gnv.state.exception.StateException; | 35 import de.intevation.gnv.state.exception.StateException; |
35 | 38 |
36 import de.intevation.gnv.utils.FileUtils; | 39 import de.intevation.gnv.utils.FileUtils; |
37 import de.intevation.gnv.utils.StringUtils; | 40 import de.intevation.gnv.utils.StringUtils; |
38 import de.intevation.gnv.utils.WKTUtils; | 41 import de.intevation.gnv.utils.WKTUtils; |
39 | 42 |
43 import java.awt.Dimension; | |
44 | |
40 import java.io.File; | 45 import java.io.File; |
41 import java.io.IOException; | 46 import java.io.IOException; |
42 import java.io.OutputStream; | 47 import java.io.OutputStream; |
43 | 48 |
49 import java.util.ArrayList; | |
44 import java.util.Collection; | 50 import java.util.Collection; |
51 import java.util.List; | |
45 | 52 |
46 import org.apache.log4j.Logger; | 53 import org.apache.log4j.Logger; |
47 | 54 |
48 import org.w3c.dom.Document; | 55 import org.w3c.dom.Document; |
49 import org.w3c.dom.Element; | 56 import org.w3c.dom.Element; |
322 p, | 329 p, |
323 numSamples(callContext), | 330 numSamples(callContext), |
324 preprocess( | 331 preprocess( |
325 queryExecutor.executeQuery( | 332 queryExecutor.executeQuery( |
326 queryID, | 333 queryID, |
327 addedFilterValues))); | 334 addedFilterValues)), |
335 getGroundInterpolation(callContext)); | |
328 } | 336 } |
329 catch (QueryException e) { | 337 catch (QueryException e) { |
330 log.error(e,e); | 338 log.error(e,e); |
331 } | 339 } |
332 | 340 |
341 log.debug("--- preprocess: " + results.size() + " results"); | 349 log.debug("--- preprocess: " + results.size() + " results"); |
342 } | 350 } |
343 | 351 |
344 AttributedPoint2ds ap2ds = new AttributedPoint2ds(); | 352 AttributedPoint2ds ap2ds = new AttributedPoint2ds(); |
345 | 353 |
346 boolean first = true; | 354 ArrayList<Point2d> points = new ArrayList<Point2d>(results.size()); |
355 | |
356 int sIdx = -1; | |
357 int iIdx = -1; | |
358 int jIdx = -1; | |
359 int vIdx = -1; | |
360 int kIdx = -1; | |
361 | |
362 boolean firstWarn = true; | |
347 | 363 |
348 for (Result result: results) { | 364 for (Result result: results) { |
349 | 365 |
350 if (debug && first) { | 366 if (sIdx == -1) { |
351 first = false; | |
352 ResultDescriptor rd = result.getResultDescriptor(); | 367 ResultDescriptor rd = result.getResultDescriptor(); |
353 log.debug(rd); | 368 sIdx = rd.getColumnIndex("SHAPE"); |
354 } | 369 iIdx = rd.getColumnIndex("IPOSITION"); |
355 } | 370 jIdx = rd.getColumnIndex("JPOSITION"); |
356 | 371 kIdx = rd.getColumnIndex("KPOSITION"); |
357 // TODO: do the interpolation | 372 vIdx = rd.getColumnIndex("YORDINATE"); |
373 int tIdx = rd.getColumnIndex("TIMEVALUE"); | |
374 int pIdx = rd.getColumnIndex("PARAMETERID"); | |
375 | |
376 if (sIdx == -1 || iIdx == -1 | |
377 || jIdx == -1 || kIdx == -1 | |
378 || vIdx == -1 || tIdx == -1 | |
379 || pIdx == -1 | |
380 ) { | |
381 log.error("missing column in result set"); | |
382 return null; | |
383 } | |
384 | |
385 ap2ds.setAttribute("date", result.getDate(tIdx)); | |
386 ap2ds.setAttribute("parameter", result.getInteger(pIdx)); | |
387 } | |
388 Coordinate coord = WKTUtils.toCoordinate(result.getString(sIdx)); | |
389 if (coord == null) { | |
390 if (firstWarn) { | |
391 firstWarn = false; | |
392 log.warn("cannot fetch coordinate from result"); | |
393 } | |
394 continue; | |
395 } | |
396 double v = result.getDouble(vIdx); | |
397 int i = result.getInteger(iIdx); | |
398 int j = result.getInteger(jIdx); | |
399 | |
400 Point2d p2d = new Point2d(coord.x, coord.y, v, i, j); | |
401 points.add(p2d); | |
402 | |
403 } | |
404 ap2ds.setPoints(points); | |
358 | 405 |
359 return ap2ds; | 406 return ap2ds; |
360 } | 407 } |
361 | 408 |
362 public AttributedPoint2ds process( | 409 public AttributedPoint2ds process( |
363 Envelope env, | 410 Envelope boundingBox, |
364 Polygon polygon, | 411 Polygon polygon, |
365 int numSamples, | 412 int numSamples, |
366 AttributedPoint2ds input | 413 AttributedPoint2ds input, |
414 int groundInterpolation | |
367 ) { | 415 ) { |
368 return input; | 416 if (input == null) { |
417 log.error("no data to interpolate"); | |
418 return null; | |
419 } | |
420 | |
421 boolean debug = log.isDebugEnabled(); | |
422 | |
423 if (debug) { | |
424 log.debug("before interpolation"); | |
425 } | |
426 | |
427 AreaInterpolation interpolation = | |
428 new AreaInterpolation(); | |
429 | |
430 List<? extends Point2d> points = input.getPoints(); | |
431 | |
432 if (!interpolation.interpolate( | |
433 points, | |
434 boundingBox, | |
435 new Dimension(numSamples, numSamples), | |
436 new QueriedXYDepth(groundInterpolation) | |
437 )) { | |
438 log.error("interpolation failed"); | |
439 return null; | |
440 } | |
441 | |
442 if (debug) { | |
443 log.debug("after interpolation"); | |
444 } | |
445 | |
446 return null; | |
369 } | 447 } |
370 | 448 |
371 | 449 |
372 /** | 450 /** |
373 * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#setup(org.w3c.dom.Node) | 451 * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#setup(org.w3c.dom.Node) |