diff flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java @ 5170:c1b60f8c3390

Made river mapfile generator more tolerant. * Ignores missing river axes. * Ignores invalid river axes. * Ignores invalid geometries.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 04 Mar 2013 17:11:31 +0100
parents 1b41dc00b1f7
children 14d19313268a
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Mon Mar 04 17:08:14 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Mon Mar 04 17:11:31 2013 +0100
@@ -50,24 +50,29 @@
     }
 
     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(RuntimeException e) {
+            return null;
         }
 
         return null;

http://dive4elements.wald.intevation.org