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

Work on ArtifactMapfileGenerator.createUserShapefileLayer()
author Christian Lins <christian.lins@intevation.de>
date Wed, 20 Feb 2013 21:00:33 +0100
parents 1da61095040c
children cbfdd7376009
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java	Tue Feb 19 14:25:38 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/mapserver/ArtifactMapfileGenerator.java	Wed Feb 20 21:00:33 2013 +0100
@@ -64,7 +64,7 @@
 
             }
             else if (fileName.startsWith(MS_PREFIX_USER)) {
-
+                createUserShapeLayer(layerShape);
             }
             else if (fileName.startsWith(MS_PREFIX_WSPLGEN)) {
 
@@ -91,7 +91,7 @@
         logger.debug("createUeskLayer");
 
         LayerInfo layerinfo = new LayerInfo();
-        layerinfo.setName(MS_WSPLGEN_PREFIX + flys.identifier());
+        layerinfo.setName(MS_PREFIX_WSPLGEN + flys.identifier());
         layerinfo.setType("POLYGON");
         layerinfo.setDirectory(flys.identifier());
         layerinfo.setData(WSPLGEN_RESULT_SHAPE);
@@ -149,7 +149,7 @@
     throws FileNotFoundException, IOException
     {
         String uuid       = flys.identifier();
-        String group      = MS_BARRIERS_PREFIX + uuid;
+        String group      = MS_PREFIX_BARRIERS + uuid;
         String groupTitle = "I18N_BARRIERS_TITLE";
 
         File dir  = new File(getShapefileBaseDir(), uuid);
@@ -194,7 +194,7 @@
         throws FileNotFoundException, IOException
         {
             String uuid       = flys.identifier();
-            String group      = uuid + MS_BARRIERS_PREFIX;
+            String group      = uuid + MS_PREFIX_BARRIERS;
             String groupTitle = "I18N_BARRIERS_TITLE";
 
             File dir  = new File(getShapefileBaseDir(), uuid);
@@ -232,20 +232,33 @@
             }
         }
 
+        protected String uuidFromPath(String path) {
+            logger.debug("uuidFromPath(" + path + ")");
+            int i1 = 0;
+            int i2 = 0;
+
+            for(;;) {
+                int i = path.indexOf('/', i2 + 1);
+                if (i == -1) {
+                    return path.substring(i1 + 1, i2);
+                }
+                else {
+                    i1 = i2;
+                    i2 = i;
+                }
+            }
+        }
 
         /**
          * Creates a layer file used for Mapserver's mapfile which represents the
          * shape files uploaded by the user.
-         *
-         * @param flys The FLYSArtifact that owns <i>wms</i>.
-         * @param wms The WMSLayerFacet that contains information for the layer.
          */
-        protected void createUserShapeLayer(FLYSArtifact flys, WMSLayerFacet wms)
+        protected void createUserShapeLayer(File file)
         throws FileNotFoundException, IOException
         {
-            logger.debug("createUserShapeLayer");
+            String uuid = uuidFromPath(file.getAbsolutePath());
+            logger.debug("createUserShapeLayer(): uuid=" + uuid);
 
-            String uuid = flys.identifier();
             File   dir  = new File(getShapefileBaseDir(), uuid);
             File   test = new File(dir, WSPLGEN_USER_SHAPE);
 
@@ -259,11 +272,11 @@
             ShapefileReader sfr = new ShapefileReader(sf, true, false, null);
             ShapefileHeader sfh = sfr.getHeader();
 
-            String group      = uuid + MS_USERSHAPE_PREFIX;
+            String group      = uuid + MS_PREFIX_USER;
             String groupTitle = "I18N_USER_SHAPE_TITLE";
 
             LayerInfo info = new LayerInfo();
-            info.setName(MS_USERSHAPE_PREFIX + uuid);
+            info.setName(MS_PREFIX_USER + uuid);
             if (sfh.getShapeType().isLineType()) {
                 info.setType("LINE");
             }
@@ -278,9 +291,9 @@
             info.setTitle("I18N_USER_SHAPE");
             info.setGroup(group);
             info.setGroupTitle(groupTitle);
-            info.setSrid(wms.getSrid());
+            //info.setSrid(wms.getSrid()); // FIXME: Required?
 
-            String nameUser = MS_LAYER_PREFIX + wms.getName();
+            String nameUser = "user.layer"; //MS_LAYER_PREFIX + wms.getName();
 
             Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE);
             if (tpl == null) {

http://dive4elements.wald.intevation.org