diff flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java @ 5379:61bf64b102bc mapgenfix

Merge with default branch
author Christian Lins <christian.lins@intevation.de>
date Fri, 22 Mar 2013 11:25:54 +0100
parents 9d36ddf7dbd3
children fd07bcaff880
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Wed Mar 06 14:14:15 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Fri Mar 22 11:25:54 2013 +0100
@@ -30,6 +30,7 @@
 import org.geotools.geometry.jts.JTS;
 import org.geotools.geometry.jts.ReferencedEnvelope;
 import org.geotools.referencing.CRS;
+import org.hibernate.HibernateException;
 import org.opengis.feature.simple.SimpleFeature;
 import org.opengis.feature.simple.SimpleFeatureType;
 import org.opengis.referencing.FactoryException;
@@ -50,24 +51,30 @@
     }
 
     public static Envelope getRiverBoundary(String rivername) {
-        List<RiverAxis> axes = RiverAxis.getRiverAxis(rivername);
-        if (axes != null && axes.size() > 0) {
-            Envelope max = null;
-
-            for (RiverAxis axis: axes) {
-                // TODO Take the correct EPSG into account. Maybe, we need to
-                // reproject the geometry.
-                Envelope env = axis.getGeom().getEnvelopeInternal();
+        try {
+            List<RiverAxis> axes = RiverAxis.getRiverAxis(rivername);
+            if (axes != null && axes.size() > 0) {
+                Envelope max = null;
 
-                if (max == null) {
-                    max = env;
+                for (RiverAxis axis: axes) {
+                    // TODO Take the correct EPSG into account. Maybe, we need to
+                    // reproject the geometry.
+                    Envelope env = axis.getGeom().getEnvelopeInternal();
+
+                    if (max == null) {
+                        max = env;
+                    }
+                    else {
+                        max.expandToInclude(env);
+                    }
                 }
-                else {
-                    max.expandToInclude(env);
-                }
+
+                return max;
             }
-
-            return max;
+        }
+        catch(HibernateException iae) {
+            logger.warn("No vaild river axis forund for " + rivername);
+            return null;
         }
 
         return null;

http://dive4elements.wald.intevation.org