[Dive4elements-commits] [PATCH] Fix typo in class names and correct file path in floodmap.xml

Wald Commits scm-commit at wald.intevation.org
Mon Dec 17 23:24:34 CET 2012


# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1355783067 -3600
# Node ID 13abfb1bcb75e78fef474ffde665f4c5242ebccd
# Parent  63d1e91db66692c20c64b00abec3ba73bf51a7c3
Fix typo in class names and correct file path in floodmap.xml.

diff -r 63d1e91db666 -r 13abfb1bcb75 flys-artifacts/doc/conf/mapserver/river-mapfile.vm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/doc/conf/mapserver/river-mapfile.vm	Mon Dec 17 23:24:27 2012 +0100
@@ -0,0 +1,60 @@
+MAP
+    NAME "Rivers"
+    STATUS ON
+    SIZE 600 400
+    MAXSIZE 4000
+    EXTENT 3233232.55407617 5303455.37850183 3421524.44644752 5585825.50888523
+    UNITS DD
+    SHAPEPATH "$SHAPEFILEPATH"
+    FONTSET "$CONFIGDIR/mapserver/fontset.txt"
+    SYMBOLSET "$CONFIGDIR/mapserver/symbols.sym"
+    IMAGECOLOR 255 255 255
+    PROJECTION
+        "init=epsg:31467"
+    END
+
+    DEBUG 5
+    CONFIG "MS_ERRORFILE" "log/river-$RIVERNAME.log"
+
+    WEB
+      METADATA
+        "wms_title"             "FLYS Rivers Web Map Service"
+        "wms_onlineresource"    "$MAPSERVERURL"
+        "wms_accessconstraints" "none"
+        "wms_fees"              "none"
+        "wms_addresstype"       "postal"
+        "wms_address"           "Any Street"
+        "wms_city"              "Any City"
+        "wms_stateorprovince"   "Any state"
+        "wms_postcode"          "My Postalcode"
+        "wms_country"           "Any Country"
+        "wms_contactperson"     "Any Person"
+        "wms_contactorganization" "Any Orga"
+        "wms_contactelectronicmailaddress" "any-email at example.com"
+        "wms_contactvoicetelephone" "Any's telephone number"
+        "wms_srs" "EPSG:4326 EPSG:31466 EPSG:31467"
+        "wms_feature_info_mime_type" "text/html"
+        "ows_enable_request"   "*"
+      END
+    END
+
+    LEGEND
+        KEYSIZE 20 20
+        STATUS ON
+        TRANSPARENT ON
+
+        LABEL
+            COLOR 150 150 150
+            OUTLINECOLOR 255 255 255
+            TYPE truetype
+            FONT "FreeSans"
+            SIZE 12
+            POSITION AUTO
+        END
+    END
+
+    ## Don't change the following lines.
+    #foreach ($LAYER in $LAYERS)
+        include "$LAYER"
+    #end
+END
\ No newline at end of file
diff -r 63d1e91db666 -r 13abfb1bcb75 flys-artifacts/doc/conf/mapserver/riveraxis-layer.vm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/doc/conf/mapserver/riveraxis-layer.vm	Mon Dec 17 23:24:27 2012 +0100
@@ -0,0 +1,58 @@
+LAYER
+    NAME "$LAYER.getName()"
+    TYPE $LAYER.getType()
+
+    CONNECTIONTYPE $LAYER.getConnectionType()
+    CONNECTION "$LAYER.getConnection()"
+
+    DATA    "$LAYER.getData()"
+    FILTER  "$LAYER.getFilter()"
+    EXTENT  $LAYER.getExtent()
+
+    STATUS    ON
+    TEMPLATE  map.html
+    TOLERANCE 10
+    DUMP      TRUE
+    #if( $LAYER.getGroup() )
+        GROUP "$LAYER.getGroup()"
+    #end
+
+    #if ( $LAYER.getLabelItem() )
+        LABELITEM $LAYER.getLabelItem()
+    #end
+
+    PROJECTION
+        "init=epsg:31467"
+    END
+
+    METADATA
+        "wms_title" "$LAYER.getTitle()"
+        "gml_include_items" "all"
+        #if ( $LAYER.getGroupTitle() )
+            "wms_group_title" "$LAYER.getGroupTitle()"
+        #end
+    END
+
+    #if ( $LAYER.getStyle() )
+        $LAYER.getStyle()
+    #else
+        CLASS
+            NAME ""
+            STYLE
+                SIZE 5
+                OUTLINECOLOR "#000000"
+            END
+            #if ( $LAYER.getLabelItem() )
+                LABEL
+                    ANGLE auto
+                    SIZE 10
+                    COLOR "#000000"
+                    TYPE truetype
+                    FONT LiberationSans-Italic
+                    POSITION ur
+                    OFFSET 2 2
+                END
+            #end
+        END
+    #end
+END
\ No newline at end of file
diff -r 63d1e91db666 -r 13abfb1bcb75 flys-artifacts/doc/conf/rivermap.xml
--- a/flys-artifacts/doc/conf/rivermap.xml	Mon Dec 17 18:03:53 2012 +0100
+++ b/flys-artifacts/doc/conf/rivermap.xml	Mon Dec 17 23:24:27 2012 +0100
@@ -5,7 +5,7 @@
         <server path="http://flys-devel.intevation.de/cgi-bin/"/>
         <mapfile path="${artifacts.config.dir}/../rivers.map"/>
         <templates path="${artifacts.config.dir}/mapserver/"/>
-        <map-template path="mapfile.vm"/>
+        <map-template path="river-mapfile.vm"/>
     </mapserver>
 
     <velocity>
diff -r 63d1e91db666 -r 13abfb1bcb75 flys-artifacts/doc/mapserver/river-mapfile.vm
--- a/flys-artifacts/doc/mapserver/river-mapfile.vm	Mon Dec 17 18:03:53 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-MAP
-    NAME "River $RIVERNAME"
-    STATUS ON
-    SIZE 600 400
-    MAXSIZE 4000
-    EXTENT 3233232.55407617 5303455.37850183 3421524.44644752 5585825.50888523
-    UNITS DD
-    SHAPEPATH "$SHAPEFILEPATH"
-    FONTSET "$CONFIGDIR/mapserver/fontset.txt"
-    SYMBOLSET "$CONFIGDIR/mapserver/symbols.sym"
-    IMAGECOLOR 255 255 255
-    PROJECTION
-        "init=epsg:31467"
-    END
-
-    DEBUG 5
-    CONFIG "MS_ERRORFILE" "log/river-$RIVERNAME.log"
-
-    WEB
-      METADATA
-        "wms_title"             "FLYS $RIVERNAME Web Map Service"
-        "wms_onlineresource"    "$MAPSERVERURL"
-        "wms_accessconstraints" "none"
-        "wms_fees"              "none"
-        "wms_addresstype"       "postal"
-        "wms_address"           "Any Street"
-        "wms_city"              "Any City"
-        "wms_stateorprovince"   "Any state"
-        "wms_postcode"          "My Postalcode"
-        "wms_country"           "Any Country"
-        "wms_contactperson"     "Any Person"
-        "wms_contactorganization" "Any Orga"
-        "wms_contactelectronicmailaddress" "any-email at example.com"
-        "wms_contactvoicetelephone" "Any's telephone number"
-        "wms_srs" "EPSG:4326 EPSG:31466 EPSG:31467"
-        "wms_feature_info_mime_type" "text/html"
-        "ows_enable_request"   "*"
-      END
-    END
-
-    LEGEND
-        KEYSIZE 20 20
-        STATUS ON
-        TRANSPARENT ON
-
-        LABEL
-            COLOR 150 150 150
-            OUTLINECOLOR 255 255 255
-            TYPE truetype
-            FONT "FreeSans"
-            SIZE 12
-            POSITION AUTO
-        END
-    END
-
-    ## Don't change the following lines.
-    #foreach ($LAYER in $LAYERS)
-        include "$LAYER"
-    #end
-END
\ No newline at end of file
diff -r 63d1e91db666 -r 13abfb1bcb75 flys-artifacts/doc/mapserver/riveraxis-layer.vm
--- a/flys-artifacts/doc/mapserver/riveraxis-layer.vm	Mon Dec 17 18:03:53 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-LAYER
-    NAME "$LAYER.getName()"
-    TYPE $LAYER.getType()
-
-    CONNECTIONTYPE $LAYER.getConnectionType()
-    CONNECTION "$LAYER.getConnection()"
-
-    DATA    "$LAYER.getData()"
-    FILTER  "$LAYER.getFilter()"
-    EXTENT  $LAYER.getExtent()
-
-    STATUS    ON
-    TEMPLATE  map.html
-    TOLERANCE 10
-    DUMP      TRUE
-    #if( $LAYER.getGroup() )
-        GROUP "$LAYER.getGroup()"
-    #end
-
-    #if ( $LAYER.getLabelItem() )
-        LABELITEM $LAYER.getLabelItem()
-    #end
-
-    PROJECTION
-        "init=epsg:31467"
-    END
-
-    METADATA
-        "wms_title" "$LAYER.getTitle()"
-        "gml_include_items" "all"
-        #if ( $LAYER.getGroupTitle() )
-            "wms_group_title" "$LAYER.getGroupTitle()"
-        #end
-    END
-
-    #if ( $LAYER.getStyle() )
-        $LAYER.getStyle()
-    #else
-        CLASS
-            NAME ""
-            STYLE
-                SIZE 5
-                OUTLINECOLOR "#000000"
-            END
-            #if ( $LAYER.getLabelItem() )
-                LABEL
-                    ANGLE auto
-                    SIZE 10
-                    COLOR "#000000"
-                    TYPE truetype
-                    FONT LiberationSans-Italic
-                    POSITION ur
-                    OFFSET 2 2
-                END
-            #end
-        END
-    #end
-END
\ No newline at end of file
diff -r 63d1e91db666 -r 13abfb1bcb75 flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java	Mon Dec 17 18:03:53 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/MapGenerator.java	Mon Dec 17 23:24:27 2012 +0100
@@ -16,7 +16,7 @@
 import de.intevation.flys.artifacts.model.map.WMSLayerFacet;
 import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet;
 import de.intevation.flys.collections.FLYSArtifactCollection;
-import de.intevation.flys.utils.ArtefactMapfileGenerator;
+import de.intevation.flys.utils.ArtifactMapfileGenerator;
 import de.intevation.flys.utils.GeometryUtils;
 import de.intevation.flys.utils.ThemeUtil;
 
@@ -133,7 +133,7 @@
     ) {
         try {
             if(wms instanceof WSPLGENLayerFacet) {
-                ArtefactMapfileGenerator mfg = new ArtefactMapfileGenerator();
+                ArtifactMapfileGenerator mfg = new ArtifactMapfileGenerator();
                 mfg.createUeskLayer(
                     flys,
                     (WSPLGENLayerFacet) wms,
@@ -152,7 +152,7 @@
 
 
     protected void createBarriersLayer(FLYSArtifact flys, WMSLayerFacet wms) {
-        ArtefactMapfileGenerator mfg = new ArtefactMapfileGenerator();
+        ArtifactMapfileGenerator mfg = new ArtifactMapfileGenerator();
 
         try {
             mfg.createBarriersLayer(flys, wms);
@@ -167,7 +167,7 @@
 
 
     protected void createUserShapeLayer(FLYSArtifact flys, WMSLayerFacet wms) {
-        ArtefactMapfileGenerator mfg = new ArtefactMapfileGenerator();
+        ArtifactMapfileGenerator mfg = new ArtifactMapfileGenerator();
 
         try {
             mfg.createUserShapeLayer(flys, wms);
@@ -188,7 +188,7 @@
     ) {
         logger.debug("createDatabaseLayer for facet: " + wms.getName());
 
-        ArtefactMapfileGenerator mfg = new ArtefactMapfileGenerator();
+        ArtifactMapfileGenerator mfg = new ArtifactMapfileGenerator();
 
         try {
             File baseDir = mfg.getShapefileBaseDir();
@@ -224,7 +224,7 @@
     {
         logger.debug("MapGenerator.generate");
 
-        ArtefactMapfileGenerator mfg = new ArtefactMapfileGenerator();
+        ArtifactMapfileGenerator mfg = new ArtifactMapfileGenerator();
         mfg.generate();
 
         Document response = XMLUtils.newDocument();
diff -r 63d1e91db666 -r 13abfb1bcb75 flys-artifacts/src/main/java/de/intevation/flys/utils/ArtefactMapfileGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ArtefactMapfileGenerator.java	Mon Dec 17 18:03:53 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,337 +0,0 @@
-package de.intevation.flys.utils;
-
-import de.intevation.artifacts.CallContext;
-import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.model.LayerInfo;
-import de.intevation.flys.artifacts.model.map.WMSDBLayerFacet;
-import de.intevation.flys.artifacts.model.map.WMSLayerFacet;
-import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet;
-import de.intevation.flys.artifacts.resources.Resources;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.apache.velocity.Template;
-import org.geotools.data.shapefile.ShpFiles;
-import org.geotools.data.shapefile.shp.ShapefileHeader;
-import org.geotools.data.shapefile.shp.ShapefileReader;
-
-public class ArtefactMapfileGenerator extends MapfileGenerator {
-
-    private static Logger logger = Logger.getLogger(ArtefactMapfileGenerator.class);
-
-    @Override
-    protected String getVelocityLogfile() {
-        return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_VELOCITY_LOGFILE);
-    }
-
-    @Override
-    protected String getMapserverTemplatePath() {
-        return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPSERVER_TEMPLATE_PATH);
-    }
-
-    @Override
-    protected String getMapserverUrl() {
-        return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPSERVER_URL);
-    }
-
-    /**
-     * Method which starts searching for meta information file and mapfile
-     * generation.
-     */
-    @Override
-    public void generate() throws IOException
-    {
-        File[] userDirs = getUserDirs();
-        List<String> layers = parseLayers(userDirs);
-        logger.info("Found " + layers.size() + " layers for user mapfile.");
-
-        writeMapfile(layers);
-    }
-
-    /**
-     * Creates a layer file used for Mapserver's mapfile which represents the
-     * floodmap.
-     *
-     * @param flys The FLYSArtifact that owns <i>wms</i>.
-     * @param wms The WMSLayerFacet that contains information for the layer.
-     */
-    public void createUeskLayer(
-        FLYSArtifact  flys,
-        WSPLGENLayerFacet wms,
-        String        style,
-        CallContext context
-    ) throws FileNotFoundException, IOException
-    {
-        logger.debug("createUeskLayer");
-
-        LayerInfo layerinfo = new LayerInfo();
-        layerinfo.setName(MS_WSPLGEN_PREFIX + flys.identifier());
-        layerinfo.setType("POLYGON");
-        layerinfo.setDirectory(flys.identifier());
-        layerinfo.setData(WSPLGEN_RESULT_SHAPE);
-        layerinfo.setTitle(Resources.getMsg(Resources.getLocale(context.getMeta()),
-                                            "floodmap.uesk",
-                                            "Floodmap"));
-        layerinfo.setStyle(style);
-        layerinfo.setSrid(wms.getSrid());
-
-        String name = MS_LAYER_PREFIX + wms.getName();
-
-        Template template = getTemplateByName(WSPLGEN_LAYER_TEMPLATE);
-        if (template == null) {
-            logger.warn("Template '" + WSPLGEN_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);
-        }
-    }
-
-
-    /**
-     * Creates a layer file used for Mapserver's mapfile which represents the
-     * user defined barriers.
-     *
-     * @param flys The FLYSArtifact that owns <i>wms</i>.
-     * @param wms The WMSLayerFacet that contains information for the layer.
-     */
-    public void createBarriersLayer(FLYSArtifact flys, WMSLayerFacet wms)
-    throws FileNotFoundException, IOException
-    {
-        logger.debug("createBarriersLayer");
-
-        //String uuid = flys.identifier();
-        //File   dir  = new File(getShapefileBaseDir(), uuid);
-
-        createBarriersLineLayer(flys, wms);
-        createBarriersPolygonLayer(flys, wms);
-    }
-
-
-    protected void createBarriersLineLayer(
-        FLYSArtifact  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);
-
-        if (!test.exists() || !test.canRead()) {
-            logger.debug("No barrier line 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());
-
-        String nameLines = MS_LAYER_PREFIX + wms.getName() + "-lines";
-
-        Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE);
-        if (tpl == null) {
-            logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found.");
-            return;
-        }
-
-        try {
-            writeLayer(lineInfo, new File(dir, nameLines), tpl);
-        }
-        catch (FileNotFoundException fnfe) {
-            logger.error(fnfe, fnfe);
-            logger.warn("Unable to write layer: " + nameLines);
-        }
-    }
-
-    protected void createBarriersPolygonLayer(
-            FLYSArtifact  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 FLYSArtifact that owns <i>wms</i>.
-         * @param wms The WMSLayerFacet that contains information for the layer.
-         */
-        public void createUserShapeLayer(FLYSArtifact 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 FLYSArtifact that owns <i>wms</i>.
-         * @param wms The WMSLayerFacet that contains information for the layer.
-         */
-        public void createDatabaseLayer(
-            FLYSArtifact    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
-        protected String getMapfilePath() {
-            return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPFILE_PATH);
-        }
-
-        @Override
-        protected String getMapfileTemplate() {
-            return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPFILE_TEMPLATE);
-        }
-
-}
diff -r 63d1e91db666 -r 13abfb1bcb75 flys-artifacts/src/main/java/de/intevation/flys/utils/ArtifactMapfileGenerator.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ArtifactMapfileGenerator.java	Mon Dec 17 23:24:27 2012 +0100
@@ -0,0 +1,337 @@
+package de.intevation.flys.utils;
+
+import de.intevation.artifacts.CallContext;
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.model.LayerInfo;
+import de.intevation.flys.artifacts.model.map.WMSDBLayerFacet;
+import de.intevation.flys.artifacts.model.map.WMSLayerFacet;
+import de.intevation.flys.artifacts.model.map.WSPLGENLayerFacet;
+import de.intevation.flys.artifacts.resources.Resources;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.geotools.data.shapefile.ShpFiles;
+import org.geotools.data.shapefile.shp.ShapefileHeader;
+import org.geotools.data.shapefile.shp.ShapefileReader;
+
+public class ArtifactMapfileGenerator extends MapfileGenerator {
+
+    private static Logger logger = Logger.getLogger(ArtifactMapfileGenerator.class);
+
+    @Override
+    protected String getVelocityLogfile() {
+        return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_VELOCITY_LOGFILE);
+    }
+
+    @Override
+    protected String getMapserverTemplatePath() {
+        return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPSERVER_TEMPLATE_PATH);
+    }
+
+    @Override
+    protected String getMapserverUrl() {
+        return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPSERVER_URL);
+    }
+
+    /**
+     * Method which starts searching for meta information file and mapfile
+     * generation.
+     */
+    @Override
+    public void generate() throws IOException
+    {
+        File[] userDirs = getUserDirs();
+        List<String> layers = parseLayers(userDirs);
+        logger.info("Found " + layers.size() + " layers for user mapfile.");
+
+        writeMapfile(layers);
+    }
+
+    /**
+     * Creates a layer file used for Mapserver's mapfile which represents the
+     * floodmap.
+     *
+     * @param flys The FLYSArtifact that owns <i>wms</i>.
+     * @param wms The WMSLayerFacet that contains information for the layer.
+     */
+    public void createUeskLayer(
+        FLYSArtifact  flys,
+        WSPLGENLayerFacet wms,
+        String        style,
+        CallContext context
+    ) throws FileNotFoundException, IOException
+    {
+        logger.debug("createUeskLayer");
+
+        LayerInfo layerinfo = new LayerInfo();
+        layerinfo.setName(MS_WSPLGEN_PREFIX + flys.identifier());
+        layerinfo.setType("POLYGON");
+        layerinfo.setDirectory(flys.identifier());
+        layerinfo.setData(WSPLGEN_RESULT_SHAPE);
+        layerinfo.setTitle(Resources.getMsg(Resources.getLocale(context.getMeta()),
+                                            "floodmap.uesk",
+                                            "Floodmap"));
+        layerinfo.setStyle(style);
+        layerinfo.setSrid(wms.getSrid());
+
+        String name = MS_LAYER_PREFIX + wms.getName();
+
+        Template template = getTemplateByName(WSPLGEN_LAYER_TEMPLATE);
+        if (template == null) {
+            logger.warn("Template '" + WSPLGEN_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);
+        }
+    }
+
+
+    /**
+     * Creates a layer file used for Mapserver's mapfile which represents the
+     * user defined barriers.
+     *
+     * @param flys The FLYSArtifact that owns <i>wms</i>.
+     * @param wms The WMSLayerFacet that contains information for the layer.
+     */
+    public void createBarriersLayer(FLYSArtifact flys, WMSLayerFacet wms)
+    throws FileNotFoundException, IOException
+    {
+        logger.debug("createBarriersLayer");
+
+        //String uuid = flys.identifier();
+        //File   dir  = new File(getShapefileBaseDir(), uuid);
+
+        createBarriersLineLayer(flys, wms);
+        createBarriersPolygonLayer(flys, wms);
+    }
+
+
+    protected void createBarriersLineLayer(
+        FLYSArtifact  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);
+
+        if (!test.exists() || !test.canRead()) {
+            logger.debug("No barrier line 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());
+
+        String nameLines = MS_LAYER_PREFIX + wms.getName() + "-lines";
+
+        Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE);
+        if (tpl == null) {
+            logger.warn("Template '" + SHP_LAYER_TEMPLATE + "' found.");
+            return;
+        }
+
+        try {
+            writeLayer(lineInfo, new File(dir, nameLines), tpl);
+        }
+        catch (FileNotFoundException fnfe) {
+            logger.error(fnfe, fnfe);
+            logger.warn("Unable to write layer: " + nameLines);
+        }
+    }
+
+    protected void createBarriersPolygonLayer(
+            FLYSArtifact  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 FLYSArtifact that owns <i>wms</i>.
+         * @param wms The WMSLayerFacet that contains information for the layer.
+         */
+        public void createUserShapeLayer(FLYSArtifact 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 FLYSArtifact that owns <i>wms</i>.
+         * @param wms The WMSLayerFacet that contains information for the layer.
+         */
+        public void createDatabaseLayer(
+            FLYSArtifact    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
+        protected String getMapfilePath() {
+            return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPFILE_PATH);
+        }
+
+        @Override
+        protected String getMapfileTemplate() {
+            return FLYSUtils.getXPathString(FLYSUtils.XPATH_FLOODMAP_MAPFILE_TEMPLATE);
+        }
+
+}
diff -r 63d1e91db666 -r 13abfb1bcb75 flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java	Mon Dec 17 18:03:53 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java	Mon Dec 17 23:24:27 2012 +0100
@@ -6,6 +6,7 @@
 
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.log4j.Logger;
@@ -20,15 +21,20 @@
      */
     @Override
     public void generate() {
-        List<River> rivers = RiverFactory.getRivers();
+        logger.debug("generate()");
+
+        List<River>  rivers     = RiverFactory.getRivers();
+        List<String> riverNames = new ArrayList<String>();
 
         for (River river : rivers) {
-            createRiverAxisLayer(
+            /*createRiverAxisLayer(
                     river.getName(),
                     river.getId(),
                     "41677",
-                    "100,100,100,100");
+                    "100,100,100,100");*/
+            riverNames.add(river.getName());
         }
+        writeMapfile(riverNames);
     }
 
     protected void createRiverAxisLayer(String riverName, int riverID, String srid, String extend) {


More information about the Dive4elements-commits mailing list