changeset 2078:cbeeaaad1056

#440 Support river axes that consist of more than a single geometry. flys-artifacts/trunk@3593 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 05 Jan 2012 10:46:32 +0000
parents 29459ddb6f30
children ca6ccf722c24
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java
diffstat 4 files changed, 51 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Thu Jan 05 08:34:47 2012 +0000
+++ b/flys-artifacts/ChangeLog	Thu Jan 05 10:46:32 2012 +0000
@@ -1,3 +1,21 @@
+2012-01-05  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue440 (Karte: WSPLGEN Berechnungen für Mosel schlagen fehl)
+
+	* src/main/java/de/intevation/flys/utils/GeometryUtils.java: Modified the
+	  getRiverBoundary() method because the signature of
+	  RiverAxis.getRiverAxis() has changed. This method will now take each
+	  geometry into account, that is retrieved by
+	  RiverAxis.getRiverBoundary().
+
+	* src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java:
+	  Use GeometryUtils.getRiverBoundary() to determine the boundary of a
+	  river.
+
+	* src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java:
+	  Create the riveraxis shapefile with all geometries returned by
+	  RiverAxis.getRiverAxis().
+
 2012-01-05  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java: Repaired
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java	Thu Jan 05 08:34:47 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java	Thu Jan 05 10:46:32 2012 +0000
@@ -77,12 +77,11 @@
         cr.addAttr(root, "name", river);
         mapinfo.appendChild(root);
 
-        RiverAxis axis = RiverAxis.getRiverAxis(river);
-        if (axis != null) {
-            Envelope env    = axis.getGeom().getEnvelopeInternal();
-            String   bounds = GeometryUtils.jtsBoundsToOLBounds(env);
+        Envelope env = GeometryUtils.getRiverBoundary(river);
+        if (env != null) {
+            String bounds = GeometryUtils.jtsBoundsToOLBounds(env);
+            logger.debug("River '" + river + "' bounds: " + bounds);
 
-            logger.debug("River '" + river + "' bounds: " + bounds);
             Element bbox = cr.create("bbox");
             cr.addAttr(bbox, "value", bounds);
             root.appendChild(bbox);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Thu Jan 05 08:34:47 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Thu Jan 05 10:46:32 2012 +0000
@@ -510,22 +510,26 @@
         String srid    = FLYSUtils.getRiverSrid(artifact);
         String srs     = "EPSG:" + srid;
 
-        RiverAxis axis = RiverAxis.getRiverAxis(river);
-        if (axis == null) {
+        List<RiverAxis> axes = RiverAxis.getRiverAxis(river);
+        if (axes == null || axes.size() == 0) {
             logger.warn("Could not find river axis for: '" + river + "'");
             return;
         }
 
-        Geometry geom = axis.getGeom();
-
         SimpleFeatureType ft = GeometryUtils.buildFeatureType(
             "axis", srs, LineString.class);
 
         SimpleFeatureBuilder builder = new SimpleFeatureBuilder(ft);
-        builder.add(geom);
+        FeatureCollection collection = FeatureCollections.newCollection();
 
-        FeatureCollection collection = FeatureCollections.newCollection();
-        collection.add(builder.buildFeature("0"));
+        for (int i = 0, n = axes.size(); i < n; i++) {
+            RiverAxis axis = axes.get(i);
+
+            builder.add(axis.getGeom());
+            collection.add(builder.buildFeature(String.valueOf(i)));
+
+            builder.reset();
+        }
 
         File axisShape = new File(dir, WSPLGEN_AXIS);
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Thu Jan 05 08:34:47 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Thu Jan 05 10:46:32 2012 +0000
@@ -46,11 +46,24 @@
 
 
     public static Envelope getRiverBoundary(String rivername) {
-        RiverAxis axis = RiverAxis.getRiverAxis(rivername);
-        if (axis != null) {
-            // TODO Take the correct EPSG into account. Maybe, we need to
-            // reproject the geometry.
-            return axis.getGeom().getEnvelopeInternal();
+        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();
+
+                if (max == null) {
+                    max = env;
+                }
+                else {
+                    max.expandToInclude(env);
+                }
+            }
+
+            return max;
         }
 
         return null;

http://dive4elements.wald.intevation.org