[Dive4elements-commits] [PATCH 4 of 4] Remove createBarriersLayer and createBarriers

Wald Commits scm-commit at wald.intevation.org
Thu Jun 13 17:25:48 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1371137096 -7200
# Node ID f5bb53106ae82f6111825a370808eba8a93c86de
# Parent  91dfd6425f1181d9457cded2ae25175efeeaf1d1
Remove createBarriersLayer and createBarriers

    The generated mapfiles did not work and were just confusing. This
    looks like historical cruft that was never deleted. The real barrier
    mapfiles are created in the Floodmap state

diff -r 91dfd6425f11 -r f5bb53106ae8 artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java	Thu Jun 13 17:23:51 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java	Thu Jun 13 17:24:56 2013 +0200
@@ -120,9 +120,6 @@
                 setInitialExtent(extent);
                 createWSPLGENLayer(flys, wms, attr);
             }
-            else if (FLOODMAP_BARRIERS.equals(name)) {
-                createBarriersLayer(flys, wms);
-            }
             else if (FLOODMAP_USERSHAPE.equals(name)) {
                 createUserShapeLayer(flys, wms);
             }
@@ -175,21 +172,6 @@
     }
 
 
-    protected void createBarriersLayer(D4EArtifact flys, WMSLayerFacet wms) {
-        ArtifactMapfileGenerator mfg = new ArtifactMapfileGenerator();
-
-        try {
-            mfg.createBarriersLayer(flys, wms);
-        }
-        catch (FileNotFoundException fnfe) {
-            logger.error(fnfe, fnfe);
-        }
-        catch (IOException ioe) {
-            logger.error(ioe, ioe);
-        }
-    }
-
-
     protected void createUserShapeLayer(D4EArtifact flys, WMSLayerFacet wms) {
         ArtifactMapfileGenerator mfg = new ArtifactMapfileGenerator();
 
diff -r 91dfd6425f11 -r f5bb53106ae8 artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java	Thu Jun 13 17:23:51 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java	Thu Jun 13 17:24:56 2013 +0200
@@ -111,53 +111,52 @@
 
     /**
      * Creates a layer file used for Mapserver's mapfile which represents the
-     * user defined barriers.
+     * shape files uploaded by the user.
      *
      * @param flys The D4EArtifact that owns <i>wms</i>.
      * @param wms The WMSLayerFacet that contains information for the layer.
      */
-    public void createBarriersLayer(D4EArtifact flys, WMSLayerFacet wms)
-    throws FileNotFoundException, IOException
+    public void createUserShapeLayer(D4EArtifact flys, WMSLayerFacet wms)
+        throws FileNotFoundException, IOException
     {
-        logger.debug("createBarriersLayer");
+        logger.debug("createUserShapeLayer");
 
-        //String uuid = flys.identifier();
-        //File   dir  = new File(getShapefileBaseDir(), uuid);
-
-        createBarriersLineLayer(flys, wms);
-        createBarriersPolygonLayer(flys, wms);
-    }
-
-
-    protected void createBarriersLineLayer(
-        D4EArtifact  flys,
-        WMSLayerFacet wms
-    )
-    throws FileNotFoundException, IOException
-    {
-        String uuid       = flys.identifier();
-        String group      = MS_BARRIERS_PREFIX + uuid;
-        String groupTitle = "I18N_BARRIERS_TITLE";
-
-        File dir  = new File(getShapefileBaseDir(), uuid);
-        File test = new File(dir, WSPLGEN_LINES_SHAPE);
+        String uuid = flys.identifier();
+        File   dir  = new File(getShapefileBaseDir(), uuid);
+        File   test = new File(dir, WSPLGEN_USER_SHAPE);
 
         if (!test.exists() || !test.canRead()) {
-            logger.debug("No barrier line layer existing.");
+            logger.debug("No user layer existing.");
             return;
         }
 
-        LayerInfo lineInfo = new LayerInfo();
-        lineInfo.setName(MS_LINE_PREFIX + uuid);
-        lineInfo.setType("LINE");
-        lineInfo.setDirectory(uuid);
-        lineInfo.setData(WSPLGEN_LINES_SHAPE);
-        lineInfo.setTitle("I18N_LINE_SHAPE");
-        lineInfo.setGroup(group);
-        lineInfo.setGroupTitle(groupTitle);
-        lineInfo.setSrid(wms.getSrid());
+        File userShape = new File(dir, WSPLGEN_USER_SHAPE);
+        ShpFiles sf = new ShpFiles(userShape);
+        ShapefileReader sfr = new ShapefileReader(sf, true, false, null);
+        ShapefileHeader sfh = sfr.getHeader();
 
-        String nameLines = MS_LAYER_PREFIX + wms.getName() + "-lines";
+        String group      = uuid + MS_USERSHAPE_PREFIX;
+        String groupTitle = "I18N_USER_SHAPE_TITLE";
+
+        LayerInfo info = new LayerInfo();
+        info.setName(MS_USERSHAPE_PREFIX + uuid);
+        if (sfh.getShapeType().isLineType()) {
+            info.setType("LINE");
+        }
+        else if (sfh.getShapeType().isPolygonType()) {
+            info.setType("POLYGON");
+        }
+        else {
+            return;
+        }
+        info.setDirectory(uuid);
+        info.setData(WSPLGEN_USER_SHAPE);
+        info.setTitle("I18N_USER_SHAPE");
+        info.setGroup(group);
+        info.setGroupTitle(groupTitle);
+        info.setSrid(wms.getSrid());
+
+        String nameUser = MS_LAYER_PREFIX + wms.getName();
 
         Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE);
         if (tpl == null) {
@@ -166,181 +165,71 @@
         }
 
         try {
-            writeLayer(lineInfo, new File(dir, nameLines), tpl);
+            writeLayer(info, new File(dir, nameUser), tpl);
         }
         catch (FileNotFoundException fnfe) {
             logger.error(fnfe, fnfe);
-            logger.warn("Unable to write layer: " + nameLines);
+            logger.warn("Unable to write layer: " + nameUser);
+        }
+
+    }
+
+
+    /**
+     * Creates a layer file used for Mapserver's mapfile which represents
+     * geometries from database.
+     *
+     * @param flys The D4EArtifact that owns <i>wms</i>.
+     * @param wms The WMSLayerFacet that contains information for the layer.
+     */
+    public void createDatabaseLayer(
+            D4EArtifact    flys,
+            WMSDBLayerFacet wms,
+            String          style
+            )
+        throws FileNotFoundException, IOException
+    {
+        logger.debug("createDatabaseLayer");
+
+        LayerInfo layerinfo = new LayerInfo();
+        layerinfo.setName(wms.getName() + "-" + flys.identifier());
+        layerinfo.setType(wms.getGeometryType());
+        layerinfo.setFilter(wms.getFilter());
+        layerinfo.setData(wms.getData());
+        layerinfo.setTitle(wms.getDescription());
+        layerinfo.setStyle(style);
+        if(wms.getExtent() != null) {
+            layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent()));
+        }
+        layerinfo.setConnection(wms.getConnection());
+        layerinfo.setConnectionType(wms.getConnectionType());
+        layerinfo.setLabelItem(wms.getLabelItem());
+        layerinfo.setSrid(wms.getSrid());
+
+        String name = MS_LAYER_PREFIX + wms.getName();
+
+        Template template = getTemplateByName(DB_LAYER_TEMPLATE);
+        if (template == null) {
+            logger.warn("Template '" + DB_LAYER_TEMPLATE + "' found.");
+            return;
+        }
+
+        try {
+            File dir = new File(getShapefileBaseDir(), flys.identifier());
+            writeLayer(layerinfo, new File(dir, name), template);
+        }
+        catch (FileNotFoundException fnfe) {
+            logger.error(fnfe, fnfe);
+            logger.warn("Unable to write layer: " + name);
         }
     }
 
-    protected void createBarriersPolygonLayer(
-            D4EArtifact  flys,
-            WMSLayerFacet wms
-        )
-        throws FileNotFoundException, IOException
-        {
-            String uuid       = flys.identifier();
-            String group      = uuid + MS_BARRIERS_PREFIX;
-            String groupTitle = "I18N_BARRIERS_TITLE";
-
-            File dir  = new File(getShapefileBaseDir(), uuid);
-            File test = new File(dir, WSPLGEN_POLYGONS_SHAPE);
-
-            if (!test.exists() || !test.canRead()) {
-                logger.debug("No barrier line layer existing.");
-                return;
-            }
-
-            LayerInfo polygonInfo = new LayerInfo();
-            polygonInfo.setName(MS_POLYGONS_PREFIX + uuid);
-            polygonInfo.setType("POLYGON");
-            polygonInfo.setDirectory(uuid);
-            polygonInfo.setData(WSPLGEN_POLYGONS_SHAPE);
-            polygonInfo.setTitle("I18N_POLYGON_SHAPE");
-            polygonInfo.setGroup(group);
-            polygonInfo.setGroupTitle(groupTitle);
-            polygonInfo.setSrid(wms.getSrid());
-
-            String namePolygons = MS_LAYER_PREFIX + wms.getName() + "-polygons";
-
-            Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE);
-            if (tpl == null) {
-                logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found.");
-                return;
-            }
-
-            try {
-                writeLayer(polygonInfo, new File(dir, namePolygons), tpl);
-            }
-            catch (FileNotFoundException fnfe) {
-                logger.error(fnfe, fnfe);
-                logger.warn("Unable to write layer: " + namePolygons);
-            }
-        }
-
-
-        /**
-         * Creates a layer file used for Mapserver's mapfile which represents the
-         * shape files uploaded by the user.
-         *
-         * @param flys The D4EArtifact that owns <i>wms</i>.
-         * @param wms The WMSLayerFacet that contains information for the layer.
-         */
-        public void createUserShapeLayer(D4EArtifact flys, WMSLayerFacet wms)
-        throws FileNotFoundException, IOException
-        {
-            logger.debug("createUserShapeLayer");
-
-            String uuid = flys.identifier();
-            File   dir  = new File(getShapefileBaseDir(), uuid);
-            File   test = new File(dir, WSPLGEN_USER_SHAPE);
-
-            if (!test.exists() || !test.canRead()) {
-                logger.debug("No user layer existing.");
-                return;
-            }
-
-            File userShape = new File(dir, WSPLGEN_USER_SHAPE);
-            ShpFiles sf = new ShpFiles(userShape);
-            ShapefileReader sfr = new ShapefileReader(sf, true, false, null);
-            ShapefileHeader sfh = sfr.getHeader();
-
-            String group      = uuid + MS_USERSHAPE_PREFIX;
-            String groupTitle = "I18N_USER_SHAPE_TITLE";
-
-            LayerInfo info = new LayerInfo();
-            info.setName(MS_USERSHAPE_PREFIX + uuid);
-            if (sfh.getShapeType().isLineType()) {
-                info.setType("LINE");
-            }
-            else if (sfh.getShapeType().isPolygonType()) {
-                info.setType("POLYGON");
-            }
-            else {
-                return;
-            }
-            info.setDirectory(uuid);
-            info.setData(WSPLGEN_USER_SHAPE);
-            info.setTitle("I18N_USER_SHAPE");
-            info.setGroup(group);
-            info.setGroupTitle(groupTitle);
-            info.setSrid(wms.getSrid());
-
-            String nameUser = MS_LAYER_PREFIX + wms.getName();
-
-            Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE);
-            if (tpl == null) {
-                logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found.");
-                return;
-            }
-
-            try {
-                writeLayer(info, new File(dir, nameUser), tpl);
-            }
-            catch (FileNotFoundException fnfe) {
-                logger.error(fnfe, fnfe);
-                logger.warn("Unable to write layer: " + nameUser);
-            }
-
-        }
-
-
-        /**
-         * Creates a layer file used for Mapserver's mapfile which represents
-         * geometries from database.
-         *
-         * @param flys The D4EArtifact that owns <i>wms</i>.
-         * @param wms The WMSLayerFacet that contains information for the layer.
-         */
-        public void createDatabaseLayer(
-            D4EArtifact    flys,
-            WMSDBLayerFacet wms,
-            String          style
-        )
-        throws FileNotFoundException, IOException
-        {
-            logger.debug("createDatabaseLayer");
-
-            LayerInfo layerinfo = new LayerInfo();
-            layerinfo.setName(wms.getName() + "-" + flys.identifier());
-            layerinfo.setType(wms.getGeometryType());
-            layerinfo.setFilter(wms.getFilter());
-            layerinfo.setData(wms.getData());
-            layerinfo.setTitle(wms.getDescription());
-            layerinfo.setStyle(style);
-            if(wms.getExtent() != null) {
-                layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent()));
-            }
-            layerinfo.setConnection(wms.getConnection());
-            layerinfo.setConnectionType(wms.getConnectionType());
-            layerinfo.setLabelItem(wms.getLabelItem());
-            layerinfo.setSrid(wms.getSrid());
-
-            String name = MS_LAYER_PREFIX + wms.getName();
-
-            Template template = getTemplateByName(DB_LAYER_TEMPLATE);
-            if (template == null) {
-                logger.warn("Template '" + DB_LAYER_TEMPLATE + "' found.");
-                return;
-            }
-
-            try {
-                File dir = new File(getShapefileBaseDir(), flys.identifier());
-                writeLayer(layerinfo, new File(dir, name), template);
-            }
-            catch (FileNotFoundException fnfe) {
-                logger.error(fnfe, fnfe);
-                logger.warn("Unable to write layer: " + name);
-            }
-        }
-
-        @Override
+    @Override
         protected String getMapfilePath() {
             return RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_MAPFILE_PATH);
         }
 
-        @Override
+    @Override
         protected String getMapfileTemplate() {
             return RiverUtils.getXPathString(RiverUtils.XPATH_FLOODMAP_MAPFILE_TEMPLATE);
         }


More information about the Dive4elements-commits mailing list