comparison gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java @ 455:363236fc462d

Added Rasterdatasupport to VerticalCrossSections gnv-artifacts/trunk@505 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Mon, 04 Jan 2010 15:27:33 +0000
parents
children 47ad9721e692
comparison
equal deleted inserted replaced
454:04cfb4e3da4f 455:363236fc462d
1 /**
2 *
3 */
4 package de.intevation.gnv.math;
5
6 import java.util.Collection;
7
8 import org.apache.log4j.Logger;
9
10 import com.vividsolutions.jts.geom.Coordinate;
11
12 import de.intevation.gnv.geobackend.base.Result;
13 import de.intevation.gnv.geobackend.base.query.QueryExecutor;
14 import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory;
15 import de.intevation.gnv.geobackend.base.query.exception.QueryException;
16
17
18 /**
19 * @author Tim Englich <tim.englich@intevation.de>
20 *
21 */
22 public class QueriedXYDepth implements XYDepth {
23
24 /**
25 * the logger, used to log exceptions and additonaly information
26 */
27 private static Logger log = Logger.getLogger(QueriedXYDepth.class);
28
29 private String queryID = "rasterQuery";
30
31 private QueryExecutor queryExecutor = null;
32
33 /**
34 * Constructor
35 */
36 public QueriedXYDepth() {
37 this.queryExecutor = QueryExecutorFactory.getInstance().getQueryExecutor();
38 }
39
40 /**
41 * @see de.intevation.gnv.math.XYDepth#depth(com.vividsolutions.jts.geom.Coordinate)
42 */
43 public double depth(Coordinate coordinate) {
44 log.debug("QueriedXYDepth.depth for " + coordinate.x+" "+ coordinate.y);
45 double resultValue = 0;
46 Collection<Result> result = null;
47 try {
48 String[] filterValues = new String[]{"Point ("+coordinate.x+" "+coordinate.y+")"};
49 result = this.queryExecutor.executeQuery(this.queryID,filterValues);
50 } catch (QueryException e) {
51 log.error(e,e);
52 }
53
54 if (result != null){
55 if (!result.isEmpty()){
56 Result row = result.iterator().next();
57 resultValue = row.getDouble(0);
58 }else{
59 resultValue = Double.NaN;
60 }
61 }else{
62 resultValue = Double.NaN;
63 }
64 return resultValue;
65 }
66
67 }

http://dive4elements.wald.intevation.org