changeset 462:912797826099

Use new raster access. gnv-artifacts/trunk@519 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sat, 09 Jan 2010 12:45:42 +0000
parents 3ddc22aab764
children 07672838fa5f
files gnv-artifacts/ChangeLog 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 3 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Fri Jan 08 14:27:49 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Sat Jan 09 12:45:42 2010 +0000
@@ -1,3 +1,13 @@
+2010-01-09	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java:
+	  Prevent NPE if no results are produced by vertical cross sections.
+
+	* src/main/java/de/intevation/gnv/math/QueriedXYDepth.java: Replaced
+	  envelope checking by direct coordinate checking in tile cache.
+	  Store the last used tile explicitly to save it from being collected
+	  by the garbage collector.
+
 2010-01-08  Tim Englich  <tim.englich@intevation.de>
 
 	* src/main/java/de/intevation/gnv/utils/InputValidator.java (getPointValue),
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java	Fri Jan 08 14:27:49 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/math/QueriedXYDepth.java	Sat Jan 09 12:45:42 2010 +0000
@@ -37,6 +37,8 @@
     private QueryExecutor queryExecutor;
     
     private ArrayList<SoftReference<RasterObject>> rasterData;
+
+    private RasterObject last;
     
     /**
      * Constructor
@@ -60,7 +62,7 @@
                 Collection<Result> result = queryExecutor.executeQuery(this.queryID,filterValues);
                 for (Result row: result) {
                     if ((ro = (RasterObject)row.getObject(0)) != null) {
-                        rasterData.add(new SoftReference<RasterObject>(ro));
+                        rasterData.add(new SoftReference<RasterObject>(last = ro));
                     }
                     break;
                 }
@@ -74,11 +76,14 @@
     }
     
     private RasterObject getRasterObject(Coordinate coordinate){
+        if (last != null && last.contains(coordinate)) {
+            return last;
+        }
         for (int i = rasterData.size()-1; i >= 0; --i) {
             SoftReference<RasterObject> ref = rasterData.get(i);
             RasterObject ro = ref.get();
-            if (ro != null && ro.getEnvelope().contains(coordinate)) {
-                return ro;
+            if (ro != null && ro.contains(coordinate)) {
+                return last = ro;
             }
         }
         return null;
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java	Fri Jan 08 14:27:49 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/verticalcrosssection/VerticalCrossSectionOutputState.java	Sat Jan 09 12:45:42 2010 +0000
@@ -450,6 +450,11 @@
 
         log.info("Chart not in cache yet.");
 
+        if (!(result instanceof AttributedXYColumns)) {
+            log.error("result of wrong type");
+            return null;
+        }
+
         AttributedXYColumns columns =
             (AttributedXYColumns)result;
 

http://dive4elements.wald.intevation.org