changeset 428:88cd37c3b5e4

Adjusted sql queries and configuration for verticalcrosssection products. Some code refactoring and improved error handling. gnv-artifacts/trunk@476 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 22 Dec 2009 13:18:07 +0000
parents a95aaeb206f7
children bed9735adf84
files gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/products/verticalcrosssection/conf_mesh.xml gnv-artifacts/doc/conf/queries.properties gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java
diffstat 5 files changed, 83 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Tue Dec 22 13:10:56 2009 +0000
+++ b/gnv-artifacts/ChangeLog	Tue Dec 22 13:18:07 2009 +0000
@@ -1,3 +1,15 @@
+2009-12-22  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* doc/conf/products/verticalcrosssection/conf_mesh.xml: Adjusted
+	  configuration for verticalcrosssection ('Profilschnitt') products.
+
+	* doc/conf/queries.properties: Adjusted sql query for chart generation of 
+	  verticalcrosssection products.
+
+	* src/main/java/de/intevation/gnv/state/StateBase.java,
+	  src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java: Code
+	  refactoring and better error handling.
+
 2009-12-22  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/math/HeightValue.java,
--- a/gnv-artifacts/doc/conf/products/verticalcrosssection/conf_mesh.xml	Tue Dec 22 13:10:56 2009 +0000
+++ b/gnv-artifacts/doc/conf/products/verticalcrosssection/conf_mesh.xml	Tue Dec 22 13:18:07 2009 +0000
@@ -117,6 +117,7 @@
                  <inputvalue name="parameterid" type="Integer" multiselect="true"  usedinquery="1"/>
                  <inputvalue name="fisname" type="String" multiselect="false" usedinquery="0"/>
                  <inputvalue name="dateid" type="Date" multiselect="true" usedinquery="0"/>
+                 <inputvalue name="mesh_linestring" type="String" multiselect="false" usedinquery="0"/>
              </inputvalues>
          </state>
          
@@ -131,10 +132,9 @@
              <inputvalues>
                  <inputvalue name="parameterid" type="Integer" multiselect="true" usedinquery="1"/>
                  <inputvalue name="dateid" type="Date" multiselect="true" usedinquery="1"/>
-                 <inputvalue name="meshid" type="Integer" multiselect="false" usedinquery="2"/>
-                 <inputvalue name="axisid" type="AttributeName" multiselect="false" usedinquery="2"/>
-                 <inputvalue name="mesh_point" type="Integer" multiselect="false" usedinquery="1"/> 
+                 <inputvalue name="meshid" type="Integer" multiselect="false" usedinquery="1"/>
                  <inputvalue name="fisname" type="String" multiselect="false" usedinquery="0"/>
+                 <inputvalue name="mesh_linestring" type="String" multiselect="false" usedinquery="0"/>
              </inputvalues>
              <value-names>
                  <value-name name="feature" value="mesh_point"></value-name>
--- a/gnv-artifacts/doc/conf/queries.properties	Tue Dec 22 13:10:56 2009 +0000
+++ b/gnv-artifacts/doc/conf/queries.properties	Tue Dec 22 13:18:07 2009 +0000
@@ -990,12 +990,11 @@
           msv.TIMEVALUE = ? AND \
           m.OBJECTID = ? AND \
           MEDIAN.MESHPOINT.FEATUREID in \
-            ( select FEATUREID \
-              from MEDIAN.MESHPOINT mp, \
-                   MEDIAN.MESH m \
-              where m.OBJECTID = ? AND \
-                    mp.MESHID = m.MESHID  AND \
-                    ? = (select ? from MEDIAN.MESHPOINT where FEATUREID = ?)) \
+              ( \
+               SELECT distinct FEATUREID \
+               FROM MEDIAN.MESHPOINT \
+               WHERE ? \
+               ) \
     order by msv.TIMEVALUE, \
              msv.PARAMETERID, \
              MEDIAN.MESHPOINT.JPOSITION, \
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java	Tue Dec 22 13:10:56 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/StateBase.java	Tue Dec 22 13:18:07 2009 +0000
@@ -408,7 +408,7 @@
                 }
             }
         }
-        String[] filterValues = list.toArray(new String[0]);
+        String[] filterValues = list.toArray(new String[list.size()]);
         return filterValues;
     }
     
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java	Tue Dec 22 13:10:56 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/TimeseriesStatistics.java	Tue Dec 22 13:18:07 2009 +0000
@@ -25,6 +25,7 @@
 import org.apache.log4j.Logger;
 
 import de.intevation.gnv.geobackend.base.Result;
+import de.intevation.gnv.geobackend.base.ResultDescriptor;
 import de.intevation.gnv.state.describedata.KeyValueDescibeData;
 import de.intevation.gnv.statistics.exception.StatisticsException;
 
@@ -71,48 +72,73 @@
         Collection<StatisticSet> statisticSets = new ArrayList<StatisticSet>();
         String break1, break2, break3;
         int lSeries = 1;
+
+        int b1Idx = -1;
+        int b2Idx = -1;
+        int b3Idx = -1;
+        int yIdx  = -1;
         try {
 
             Iterator<Result> resultIterator = resultSet.iterator();
             if (resultIterator.hasNext()) {
                 Result row = resultIterator.next();
                 Result previousRow = row;
-                break1 = row.getString("GROUP1");
-                break2 = row.getString("GROUP2");
-                break3 = row.getString("GROUP3");
+
+                if (b1Idx == -1) {
+                    ResultDescriptor rd = row.getResultDescriptor();
+                    b1Idx = rd.getColumnIndex("GROUP1");
+                    b2Idx = rd.getColumnIndex("GROUP2");
+                    b3Idx = rd.getColumnIndex("GROUP3");
+                    yIdx  = rd.getColumnIndex("YORDINATE");
+
+                    if (b1Idx == -1 || b2Idx == -1 || b3Idx == -1 || yIdx == -1) {
+                        return statisticSets;
+                    }
+                }
+                break1 = row.getString(b1Idx);
+                break2 = row.getString(b2Idx);
+                break3 = row.getString(b3Idx);
                 lRegression = new SimpleRegression();
                 lStatistics = new DescriptiveStatistics();
                 while (resultIterator.hasNext()) {
 
-                    if (!break1.equals(row.getString("GROUP1"))
-                        || !break2.equals(row.getString("GROUP2"))
-                        || !break3.equals(row.getString("GROUP3"))
+                    if (!break1.equals(row.getString(b1Idx))
+                        || !break2.equals(row.getString(b2Idx))
+                        || !break3.equals(row.getString(b3Idx))
                         ) {
-                        String statisticsName = this.generateStatisticsName(break1, break2, 
-                                                                            break3, parameters, 
-                                                                            measurements, dates);
-                        statisticSets.add(this.generateStatisticsValues(lStatistics, 
-                                                                        lRegression,
-                                                                        statisticsName));
+                        String statisticsName = generateStatisticsName(
+                            break1, break2, 
+                            break3, parameters, 
+                            measurements, dates);
+
+                        statisticSets.add(
+                            generateStatisticsValues(
+                                lStatistics, 
+                                lRegression,
+                                statisticsName));
 
                         lStatistics.clear();
                         lRegression.clear();
                         
-                        this.clearStatistics();
+                        clearStatistics();
 
-                        lStatistics.addValue(row.getDouble("YORDINATE"));
-                        Double x = this.calculateXOrdinateValue(previousRow,row);
-                        lRegression.addData(x, row.getDouble("YORDINATE"));
+                        Double yValue = row.getDouble(yIdx);
 
-                        break1 = row.getString("GROUP1");
-                        break2 = row.getString("GROUP2");
-                        break3 = row.getString("GROUP3");
+                        if (yValue != null) {
+                            lStatistics.addValue(yValue);
+                            Double x = calculateXOrdinateValue(previousRow,row);
+                            lRegression.addData(x, yValue);
+                        }
+
+                        break1 = row.getString(b1Idx);
+                        break2 = row.getString(b2Idx);
+                        break3 = row.getString(b3Idx);
                         previousRow = row;
                         row = resultIterator.next();
                         lSeries++;
                     } else {
 
-                        Double value = row.getDouble("YORDINATE");
+                        Double value = row.getDouble(yIdx);
                         if (value != null) {
                             lStatistics.addValue(value.doubleValue());
                             Double x = calculateXOrdinateValue(previousRow,row);
@@ -123,18 +149,24 @@
                     }
 
                 }
-                
-                lStatistics.addValue(row.getDouble("YORDINATE"));
-                Double x = this.calculateXOrdinateValue(previousRow, row);
-                lRegression.addData(x, row.getDouble("YORDINATE"));
+
+                Double yValue = row.getDouble(yIdx);
+
+                if (yValue != null) {
+                    lStatistics.addValue(yValue);
+                    Double x = calculateXOrdinateValue(previousRow, row);
+                    lRegression.addData(x, yValue);
+                }
                 
-                String statisticsName = this.generateStatisticsName(break1, break2, 
-                                                                    break3, parameters, 
-                                                                    measurements, dates);
+                String statisticsName = generateStatisticsName(
+                    break1, break2, 
+                    break3, parameters, 
+                    measurements, dates);
                 
-                statisticSets.add(this.generateStatisticsValues(lStatistics, 
-                                                                lRegression, 
-                                                                statisticsName));
+                statisticSets.add(generateStatisticsValues(
+                    lStatistics, 
+                    lRegression, 
+                    statisticsName));
                 lStatistics.clear();
                 lRegression.clear();
             }

http://dive4elements.wald.intevation.org