diff flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java @ 5087:cbfdd7376009 mapgenfix

ArtifactMapfileGenerator can now generate user shape mapfiles again.
author Christian Lins <christian.lins@intevation.de>
date Mon, 25 Feb 2013 11:51:17 +0100
parents cc50e1b9fc60
children cfc5540a4eec
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java	Wed Feb 20 21:00:33 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java	Mon Feb 25 11:51:17 2013 +0100
@@ -64,7 +64,10 @@
 
             }
             else if (fileName.startsWith(MS_PREFIX_USER)) {
-                createUserShapeLayer(layerShape);
+                File userLayer = createUserShapeLayer(layerShape);
+                if (userLayer != null) {
+                    layerSnippets.add(userLayer.getCanonicalPath());
+                }
             }
             else if (fileName.startsWith(MS_PREFIX_WSPLGEN)) {
 
@@ -253,7 +256,7 @@
          * Creates a layer file used for Mapserver's mapfile which represents the
          * shape files uploaded by the user.
          */
-        protected void createUserShapeLayer(File file)
+        protected File createUserShapeLayer(File file)
         throws FileNotFoundException, IOException
         {
             String uuid = uuidFromPath(file.getAbsolutePath());
@@ -264,7 +267,7 @@
 
             if (!test.exists() || !test.canRead()) {
                 logger.debug("No user layer existing.");
-                return;
+                return null;
             }
 
             File userShape = new File(dir, WSPLGEN_USER_SHAPE);
@@ -284,7 +287,8 @@
                 info.setType("POLYGON");
             }
             else {
-                return;
+                logger.debug("createUserShapeLayer(): unexpected geometry type");
+                return null;
             }
             info.setDirectory(uuid);
             info.setData(WSPLGEN_USER_SHAPE);
@@ -298,17 +302,19 @@
             Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE);
             if (tpl == null) {
                 logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found.");
-                return;
+                return null;
             }
 
+            File layerFile = new File(dir, nameUser);
+
             try {
-                writeLayer(info, new File(dir, nameUser), tpl);
+                writeLayer(info, layerFile, tpl);
             }
             catch (FileNotFoundException fnfe) {
                 logger.error(fnfe, fnfe);
                 logger.warn("Unable to write layer: " + nameUser);
             }
-
+            return layerFile;
         }
 
 

http://dive4elements.wald.intevation.org