changeset 176:bff7bbb7c6f0

Add Spatial-Query-Syntax to HorizontalProfile-Queries and use Geometry to Calculate the X-Ordinate of the Chart. gnv-artifacts/trunk@219 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Wed, 14 Oct 2009 10:49:35 +0000 (2009-10-14)
parents 14263534255b
children 08b8b79b30ff
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java gnv-artifacts/src/test/ressources/queries.properties
diffstat 3 files changed, 41 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Tue Oct 13 10:30:01 2009 +0000
+++ b/gnv-artifacts/ChangeLog	Wed Oct 14 10:49:35 2009 +0000
@@ -1,3 +1,10 @@
+2009-10-14  Tim Englich  <tim.englich@intevation.de>
+
+	* src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java (createXYSeries):
+	  Load WKT from ResultSet and calculate Distance to last point.
+	* src/test/ressources/queries.properties: 
+	  Switch Chart-Queries to Spatial-Queries.
+
 2009-10-13  Tim Englich  <tim.englich@intevation.de>
 
 	* src/test/ressources/queries.properties,
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java	Tue Oct 13 10:30:01 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java	Wed Oct 14 10:49:35 2009 +0000
@@ -22,6 +22,9 @@
 import org.jfree.chart.plot.PlotOrientation;
 import org.jfree.data.xy.XYSeries;
 
+import com.vividsolutions.jts.geom.Point;
+import com.vividsolutions.jts.io.WKTReader;
+
 import de.intevation.gnv.chart.exception.TechnicalChartException;
 import de.intevation.gnv.geobackend.base.Result;
 
@@ -38,6 +41,8 @@
     private static Logger sLogger = Logger
             .getLogger(HorizontalProfileChartFactory.class);
     private static boolean sDebug = sLogger.isDebugEnabled();
+    
+    private WKTReader wktReader = new WKTReader();
 
     public HorizontalProfileChartFactory() {
         super();
@@ -64,32 +69,22 @@
             sLogger.debug("createXYSeries()");
         XYSeries series = new XYSeries(seriesName);
         try {
-            double xValue = 0;
-            double yValue = 0;
-            double xStartCoord = 0;
-            double yStartCoord = 0;
+            Point lastPoint = null;
+            double distance = 0;
             int i = 0;
             Iterator<Result> resultIterator = resultSet.iterator();
             while (resultIterator.hasNext()) {
                 Result lRow = resultIterator.next();
                 if (i >= pStart && i <= pEnd) {
-                    if (xStartCoord == 0 && yStartCoord == 0) {
-                        xStartCoord = lRow.getDouble("XORDINATE_XCOORD");
-                        yStartCoord = lRow.getDouble("XORDINATE_YCOORD");
+                    Point p = (Point)wktReader.read(lRow.getString("SHAPE"));
+                    if (lastPoint != null) {
+                        distance = distance +p.distance(lastPoint); // TODO in Meter umrechnen
                     }
-
-                    double currentXCoord = lRow.getDouble("XORDINATE_XCOORD");
-                    ;
-                    double currentYCoord = lRow.getDouble("XORDINATE_YCOORD");
-
-                    xValue = this.calculateDistance(xStartCoord, yStartCoord,
-                            currentXCoord, currentYCoord);
-
-                    yValue = lRow.getDouble("YORDINATE");
-                    series.add(xValue, yValue);
-                    sLogger.debug(seriesName + " Added Value " + xValue + " / "
+                    lastPoint = p;
+                    double yValue = lRow.getDouble("YORDINATE");
+                    series.add(distance, yValue);
+                    sLogger.debug(seriesName + " Added Value " + distance + " / "
                                   + yValue);
-
                 } else if (i > pEnd) {
                     return series;
                 }
@@ -103,14 +98,6 @@
             sLogger.error(e.getMessage(), e);
         } finally {
         }
-
         return series;
     }
-
-    private double calculateDistance(double xStartCoord, double yStartCoord,
-                                     double currentXCoord, double currentYCoord) {
-        double dx = xStartCoord - currentXCoord;
-        double dy = yStartCoord - currentYCoord;
-        return Math.sqrt((dx * dx) + (dy * dy));
-    }
 }
--- a/gnv-artifacts/src/test/ressources/queries.properties	Tue Oct 13 10:30:01 2009 +0000
+++ b/gnv-artifacts/src/test/ressources/queries.properties	Wed Oct 14 10:49:35 2009 +0000
@@ -425,22 +425,23 @@
     WHERE M.FEATUREID = IP.FEATUREID AND \
           IP.SURVEYID = ? \
     ORDER BY M.ZLOCATION
-horizontalprofile_instantaneouspoint_chart_data = SELECT MSV.OBJECTID XORDINATE_XCOORD , \
-        MSV.OBJECTID XORDINATE_YCOORD , \
+horizontalprofile_instantaneouspoint_chart_data = SELECT ST_ASTEXT(SHAPE) , \
+        MEDIAN.INSTANTANEOUSPOINT.TIMEVALUE TIME , \
         MSV.DATAVALUE  YORDINATE , \
         MSV.PARAMETERID GROUP1 , \
         ZLOCATION GROUP2 , \
         1 GROUP3 \
-    FROM MEDIAN.INSTANTANEOUSPOINT IP, \
+    FROM MEDIAN.INSTANTANEOUSPOINT, \
          MEDIAN.MEASUREMENT M, \
          MEDIAN.MEASUREDSCALARVALUE MSV \
-    WHERE IP.FEATUREID = M.FEATUREID AND \
+    WHERE MEDIAN.INSTANTANEOUSPOINT.FEATUREID = M.FEATUREID AND \
           M.MEASUREMENTID = MSV.MEASUREMENTID AND \
-          IP.SURVEYID = ? AND \
+          MEDIAN.INSTANTANEOUSPOINT.SURVEYID = ? AND \
           M.ZLOCATION IN (?) AND \
           MSV.PARAMETERID in (?) \
     ORDER BY MSV.PARAMETERID, \
-             M.ZLOCATION
+             M.ZLOCATION, \
+             MEDIAN.INSTANTANEOUSPOINT.TIMEVALUE
              
 #############################################
 #############################################
@@ -464,25 +465,27 @@
             JPOSITION = (select JPOSITION from MEDIAN.MESHPOINT where FEATUREID = ?)) \
     order by mp.KPOSITION
     
-horizontalprofile_mesh_chart_data = select mp.IPOSITION XORDINATE_XCOORD, mp.JPOSITION XORDINATE_YCOORD, \
+horizontalprofile_mesh_chart_data =  SELECT ST_ASTEXT(SHAPE), \
            msv.DATAVALUE YORDINATE, \
            msv.PARAMETERID GROUP1, \
            msv.TIMEVALUE GROUP2, \
-           mp.KPOSITION GROUP3 \
+           MEDIAN.MESHPOINT.KPOSITION GROUP3, \
+           MEDIAN.MESHPOINT.JPOSITION , \
+           MEDIAN.MESHPOINT.IPOSITION \
     from MEDIAN.MESHLAYER ml, \
-         MEDIAN.MESHPOINT mp, \
+         MEDIAN.MESHPOINT , \
          MEDIAN.MESH m, \
          MEDIAN.MESHSCALARVALUE msv \
-    where msv.FEATUREID = mp. FEATUREID AND \
-          ml.KPOSITION = mp.KPOSITION and \
-          ml.MESHID = mp.MESHID and \
-          m.MESHID = mp.MESHID AND \
+    where msv.FEATUREID = MEDIAN.MESHPOINT. FEATUREID AND \
+          ml.KPOSITION = MEDIAN.MESHPOINT.KPOSITION and \
+          ml.MESHID = MEDIAN.MESHPOINT.MESHID and \
+          m.MESHID = MEDIAN.MESHPOINT.MESHID AND \
           m.PARTIDMIN <= msv.PARTID AND \
           m.PARTIDMAX >= msv.PARTID AND \
           msv.PARAMETERID in (?) AND \
           msv.TIMEVALUE in (?) AND \
           m.OBJECTID = ? AND \
-          mp.FEATUREID in \
+          MEDIAN.MESHPOINT.FEATUREID in \
             ( select FEATUREID \
               from MEDIAN.MESHPOINT mp, \
                    MEDIAN.MESH m \
@@ -490,9 +493,9 @@
                     mp.MESHID = m.MESHID  AND \
                     KPOSITION in ( ? ) and \
                     ? = (select ? from MEDIAN.MESHPOINT where FEATUREID = ?)) \
-   order by mp.KPOSITION, \
+   order by MEDIAN.MESHPOINT.KPOSITION, \
             msv.TIMEVALUE, \
             msv.PARAMETERID, \
-            mp.JPOSITION , \
-            mp.IPOSITION
+            MEDIAN.MESHPOINT.JPOSITION , \
+            MEDIAN.MESHPOINT.IPOSITION
              
\ No newline at end of file

http://dive4elements.wald.intevation.org