changeset 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 04cfb4e3da4f
children b8080695ea62
files gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/queries.properties gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java
diffstat 4 files changed, 85 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Mon Jan 04 15:20:14 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Mon Jan 04 15:27:33 2010 +0000
@@ -1,3 +1,14 @@
+2010-01-04  Tim Englich  <tim.englich@intevation.de>
+
+    * src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java (process): 
+      Changed the XYDepth-Interface-Implementation to QueriedXYDepth
+    * doc/conf/queries.properties: 
+      Added the Query for Rasterdataaccess.
+    * src/main/java/de/intevation/gnv/math/QueriedXYDepth.java (QueriedXYDepth): 
+      Added Implementation of the XYDepth-Interface for Querying the height
+      of an Position using the geo-backend interface.
+      It is only nessesary to add a Query with the id rasterQuery to the query-Properties.
+
 2010-01-04	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/gnv/statistics/Statistics.java:
--- a/gnv-artifacts/doc/conf/queries.properties	Mon Jan 04 15:20:14 2010 +0000
+++ b/gnv-artifacts/doc/conf/queries.properties	Mon Jan 04 15:27:33 2010 +0000
@@ -1137,3 +1137,7 @@
     WHERE (FEATURETYPE = 7 OR FEATURETYPE = 8) AND \
           FEATUREID = ? \
     ORDER BY NAME
+    
+rasterQuery = SELECT ST_ASTEXT(RASTER) \
+    FROM MEDIAN.TOPO_WORLD_2MIN \
+    WHERE INTERSECTS(RASTER, "?")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java	Mon Jan 04 15:27:33 2010 +0000
@@ -0,0 +1,67 @@
+/**
+ *
+ */
+package de.intevation.gnv.math;
+
+import java.util.Collection;
+
+import org.apache.log4j.Logger;
+
+import com.vividsolutions.jts.geom.Coordinate;
+
+import de.intevation.gnv.geobackend.base.Result;
+import de.intevation.gnv.geobackend.base.query.QueryExecutor;
+import de.intevation.gnv.geobackend.base.query.QueryExecutorFactory;
+import de.intevation.gnv.geobackend.base.query.exception.QueryException;
+
+
+/**
+ * @author Tim Englich <tim.englich@intevation.de>
+ *
+ */
+public class QueriedXYDepth implements XYDepth {
+
+    /**
+     * the logger, used to log exceptions and additonaly information
+     */
+    private static Logger log = Logger.getLogger(QueriedXYDepth.class);
+    
+    private String queryID = "rasterQuery";
+    
+    private QueryExecutor queryExecutor = null;
+    
+    /**
+     * Constructor
+     */
+    public QueriedXYDepth() {
+        this.queryExecutor = QueryExecutorFactory.getInstance().getQueryExecutor();
+    }
+
+    /**
+     * @see de.intevation.gnv.math.XYDepth#depth(com.vividsolutions.jts.geom.Coordinate)
+     */
+    public double depth(Coordinate coordinate) {
+        log.debug("QueriedXYDepth.depth for " + coordinate.x+" "+ coordinate.y);
+        double resultValue = 0;
+        Collection<Result> result = null;
+        try {
+            String[] filterValues = new String[]{"Point ("+coordinate.x+" "+coordinate.y+")"};
+            result = this.queryExecutor.executeQuery(this.queryID,filterValues);
+        } catch (QueryException e) {
+            log.error(e,e);
+        }
+        
+        if (result != null){
+            if (!result.isEmpty()){
+                Result row = result.iterator().next();
+                resultValue = row.getDouble(0);
+            }else{
+                resultValue = Double.NaN;
+            }
+        }else{
+            resultValue = Double.NaN;
+        }
+        return resultValue;
+    }
+
+}
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java	Mon Jan 04 15:20:14 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java	Mon Jan 04 15:27:33 2010 +0000
@@ -52,6 +52,7 @@
 
 import de.intevation.gnv.math.AttributedXYColumns;
 import de.intevation.gnv.math.HeightValue;
+import de.intevation.gnv.math.QueriedXYDepth;
 import de.intevation.gnv.math.XYColumn;
 import de.intevation.gnv.math.IJKey;
 import de.intevation.gnv.math.LinearMetrics;
@@ -264,7 +265,8 @@
             0d,
             distance,
             LinearMetrics.INSTANCE,
-            new ConstantXYDepth(-75d)); // TODO: Use DEM here!!
+            new QueriedXYDepth());
+            //new ConstantXYDepth(-75d)); // TODO: Use DEM here!!
 
         if (!success) {
             log.warn("interpolation failed");

http://dive4elements.wald.intevation.org