changeset 7168:81416a62fa57

Saveguard range access in case an artifact has no range
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 26 Sep 2013 12:22:22 +0200
parents 2fd238b681a9
children a2989d4e13f7
files artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java	Thu Sep 26 12:22:01 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/LongitudinalSectionGenerator2.java	Thu Sep 26 12:22:22 2013 +0200
@@ -71,16 +71,20 @@
         }
         else if (getXBounds(0) == null && getDomainAxisRange() == null) {
             RangeAccess access = new RangeAccess(artifact);
-            context.putContextValue("startkm", access.getFrom());
-            context.putContextValue("endkm", access.getTo());
+            if (access.hasFrom() && access.hasTo()) {
+                context.putContextValue("startkm", access.getFrom());
+                context.putContextValue("endkm", access.getTo());
+            }
         }
         else if (getXBounds(0) == null && getDomainAxisRange() != null){
             RangeAccess access = new RangeAccess(artifact);
-            Bounds b = new DoubleBounds(access.getFrom(), access.getTo());
-            Bounds bounds =
-                calculateZoom(b, getDomainAxisRange());
-            context.putContextValue("startkm", bounds.getLower());
-            context.putContextValue("endkm", bounds.getUpper());
+            if (access.hasFrom() && access.hasTo()) {
+                Bounds b = new DoubleBounds(access.getFrom(), access.getTo());
+                Bounds bounds =
+                    calculateZoom(b, getDomainAxisRange());
+                context.putContextValue("startkm", bounds.getLower());
+                context.putContextValue("endkm", bounds.getUpper());
+            }
         }
         super.doOut(bundle, theme, visible);
     }

http://dive4elements.wald.intevation.org