diff flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java @ 4809:8062b571884d

Bugs in generated RiverAxis Mapfile fixed. Now the river axes are drawn by the WMS.
author Christian Lins <christian.lins@intevation.de>
date Wed, 16 Jan 2013 22:53:58 +0100
parents d93748043cbc
children ad0990a82ab8
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java	Wed Jan 16 11:39:37 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java	Wed Jan 16 22:53:58 2013 +0100
@@ -1,8 +1,12 @@
 package de.intevation.flys.utils;
 
+import com.vividsolutions.jts.geom.Envelope;
+import com.vividsolutions.jts.geom.LineString;
+
 import de.intevation.flys.artifacts.model.LayerInfo;
 import de.intevation.flys.artifacts.model.RiverFactory;
 import de.intevation.flys.model.River;
+import de.intevation.flys.model.RiverAxis;
 
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -48,11 +52,26 @@
         List<String> riverFiles = new ArrayList<String>();
 
         for (River river : rivers) {
+            // We expect that every river has only one RiverAxis.
+            // This is not correct but currently the case here, see
+            // RiverAxis.java.
+            List<RiverAxis> riverAxis = RiverAxis.getRiverAxis(river.getName());
+            if (riverAxis == null) {
+                logger.warn("River " + river.getName() + " has no river axis!");
+                continue;
+            }
+            LineString geom = riverAxis.get(0).getGeom();
+            Envelope extent = geom.getEnvelopeInternal();
+
             createRiverAxisLayer(
                     river.getName(),
                     river.getId(),
-                    "41677",
-                    "-10000 -10000 10000 10000");
+                    Integer.toString(geom.getSRID()),
+                    extent.getMinX() + " " +
+                    extent.getMinY() + " " +
+                    extent.getMaxX() + " " +
+                    extent.getMaxY());
+
             riverFiles.add("river-" + river.getName() + ".map");
         }
         writeMapfile(riverFiles);
@@ -64,7 +83,7 @@
         layerInfo.setSrid(srid);
         layerInfo.setExtent(extend);
         layerInfo.setType("line");
-        layerInfo.setData("geom FROM river_axis");      // FIXME: Use templates for that
+        layerInfo.setData("geom FROM river_axes");      // FIXME: Use templates for that
         layerInfo.setFilter("river_id = " + riverID);
         layerInfo.setTitle(riverName + " RiverAxis");
 

http://dive4elements.wald.intevation.org