changeset 1144:c07e9e9c7482

Set the river extent for WMSLayers in the FloodMapState. flys-artifacts/trunk@2667 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 07 Sep 2011 13:54:18 +0000
parents eed81499b0d2
children b33a350d79db
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java
diffstat 4 files changed, 31 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Sep 07 11:50:10 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Sep 07 13:54:18 2011 +0000
@@ -1,3 +1,14 @@
+2011-09-07  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java,
+	  src/main/java/de/intevation/flys/utils/GeometryUtils.java: Moved the
+	  code to determine the extent of a river based on its axis to
+	  GeometryUtils.
+
+	* src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java:
+	  Determine the extent of the selected river and set the WMSLayerFacet's
+	  extent attribute.
+
 2011-09-07  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	Added Themeing support for CrossSection Diagrams.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Wed Sep 07 11:50:10 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Wed Sep 07 13:54:18 2011 +0000
@@ -124,11 +124,13 @@
             hash,
             url);
 
-        String srid = FLYSUtils.getRiverSrid(artifact);
+        String srid  = FLYSUtils.getRiverSrid(artifact);
+        String river = artifact.getDataAsString("river");
 
         wsplgen.addLayer(
             artifact.identifier() + MapfileGenerator.MS_WSPLGEN_POSTFIX);
         wsplgen.setSrid(srid);
+        wsplgen.setExtent(GeometryUtils.getRiverBounds(river));
 
         WMSLayerFacet barriers = new WMSLayerFacet(
             1,
@@ -142,6 +144,7 @@
         barriers.addLayer(
             artifact.identifier() + MapfileGenerator.MS_BARRIERS_POSTFIX);
         barriers.setSrid(srid);
+        barriers.setExtent(GeometryUtils.getRiverBounds(river));
 
         facets.add(wsplgen);
         facets.add(barriers);
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java	Wed Sep 07 11:50:10 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java	Wed Sep 07 13:54:18 2011 +0000
@@ -12,8 +12,6 @@
 
 import de.intevation.artifactdatabase.state.Facet;
 
-import de.intevation.flys.model.RiverAxis;
-
 import de.intevation.flys.artifacts.FLYSArtifact;
 import de.intevation.flys.artifacts.context.FLYSContext;
 import de.intevation.flys.artifacts.model.WMSLayerFacet;
@@ -75,19 +73,7 @@
             url);
 
         facet.addLayer(WMS_LAYER_NAME);
-
-        RiverAxis axis = RiverAxis.getRiverAxis(river);
-        if (axis != null) {
-            // TODO Take the correct EPSG into account. Maybe, we need to
-            // reproject the geometry.
-            Geometry geom   = axis.getGeom().getBoundary();
-            String   bounds = GeometryUtils.jtsBoundsToOLBounds(geom);
-
-            logger.debug("River '" + river + "' bounds: " + bounds);
-
-            facet.setExtent(bounds);
-        }
-
+        facet.setExtent(GeometryUtils.getRiverBounds(river));
         facet.setSrid(FLYSUtils.getRiverSrid(artifact));
 
         facets.add(facet);
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Wed Sep 07 11:50:10 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Wed Sep 07 13:54:18 2011 +0000
@@ -32,6 +32,8 @@
 import org.geotools.geojson.feature.FeatureJSON;
 import org.geotools.referencing.CRS;
 
+import de.intevation.flys.model.RiverAxis;
+
 
 public class GeometryUtils {
 
@@ -42,6 +44,19 @@
     }
 
 
+    public static String getRiverBounds(String rivername) {
+        RiverAxis axis = RiverAxis.getRiverAxis(rivername);
+        if (axis != null) {
+            // TODO Take the correct EPSG into account. Maybe, we need to
+            // reproject the geometry.
+            Geometry geom   = axis.getGeom().getBoundary();
+            return jtsBoundsToOLBounds(geom);
+        }
+
+        return null;
+    }
+
+
     /**
      * Returns the boundary of Geometry <i>geom</i> in OpenLayers
      * representation.

http://dive4elements.wald.intevation.org