[Dive4elements-commits] [PATCH 1 of 2] Add instanceof guard around boundary handling

Wald Commits scm-commit at wald.intevation.org
Tue May 21 16:39:28 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1369123945 -7200
# Node ID e56f0d618f9682af0453cd2839f3e336912132b6
# Parent  06450ef553cc7264b24fed79d9369fe124b540aa
Add instanceof guard around boundary handling

    Otherwise there could be a class cast exception when the class
    was an annotation object

diff -r 06450ef553cc -r e56f0d618f96 artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java	Tue May 21 16:30:14 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java	Tue May 21 10:12:25 2013 +0200
@@ -90,28 +90,30 @@
             return;
         }
 
-        if (getXBounds(0) != null && getDomainAxisRange() != null) {
-            Bounds bounds =
-                calculateZoom(getXBounds(0), getDomainAxisRange());
-            context.putContextValue("startkm", bounds.getLower());
-            context.putContextValue("endkm", bounds.getUpper());
-        }
-        else if (getXBounds(0) != null && getDomainAxisRange() == null) {
-            context.putContextValue("startkm", getXBounds(0).getLower());
-            context.putContextValue("endkm", getXBounds(0).getUpper());
-        }
-        else if (getXBounds(0) == null && getDomainAxisRange() == null) {
-            BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
-            context.putContextValue("startkm", data.getKms().min());
-            context.putContextValue("endkm", data.getKms().max());
-        }
-        else if (getXBounds(0) == null && getDomainAxisRange() != null){
-            BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
-            Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max());
-            Bounds bounds =
-                calculateZoom(b, getDomainAxisRange());
-            context.putContextValue("startkm", bounds.getLower());
-            context.putContextValue("endkm", bounds.getUpper());
+        if (bundle.getData(context) instanceof BedDifferencesResult) {
+            if (getXBounds(0) != null && getDomainAxisRange() != null) {
+                Bounds bounds =
+                    calculateZoom(getXBounds(0), getDomainAxisRange());
+                context.putContextValue("startkm", bounds.getLower());
+                context.putContextValue("endkm", bounds.getUpper());
+            }
+            else if (getXBounds(0) != null && getDomainAxisRange() == null) {
+                context.putContextValue("startkm", getXBounds(0).getLower());
+                context.putContextValue("endkm", getXBounds(0).getUpper());
+            }
+            else if (getXBounds(0) == null && getDomainAxisRange() == null) {
+                BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
+                context.putContextValue("startkm", data.getKms().min());
+                context.putContextValue("endkm", data.getKms().max());
+            }
+            else if (getXBounds(0) == null && getDomainAxisRange() != null){
+                BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context);
+                Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max());
+                Bounds bounds =
+                    calculateZoom(b, getDomainAxisRange());
+                context.putContextValue("startkm", bounds.getLower());
+                context.putContextValue("endkm", bounds.getUpper());
+            }
         }
         Processor processor = new KMIndexProcessor();
         if (name.equals(BED_DIFFERENCE_HEIGHT_YEAR)) {


More information about the Dive4elements-commits mailing list