changeset 1134:bcf70a452646

Read barrier layers from filesystem while mapfile creation and build a facet for this layer in the artifact. flys-artifacts/trunk@2654 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 06 Sep 2011 15:25:54 +0000
parents e011f8c6e5e8
children c8c753931514
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/mapserver/layer.vm flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/LayerInfo.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java
diffstat 6 files changed, 156 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Sep 06 11:10:13 2011 +0000
+++ b/flys-artifacts/ChangeLog	Tue Sep 06 15:25:54 2011 +0000
@@ -1,3 +1,21 @@
+2011-09-06  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/LayerInfo.java: Renamed
+	  some attributes to make their job in the mapfile more obvious.
+
+	* src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added
+	  new facet type for barriers.
+
+	* src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java: Add
+	  a facet for the barriers layer.
+
+	* src/main/java/de/intevation/flys/utils/MapfileGenerator.java: Parse
+	  barriers (lines and polygons) and create two new layers for each type -
+	  those layers are grouped.
+
+	* doc/conf/mapserver/layer.vm: Renamed attribute based on changes in
+	  LayerInfo and added support for Group-Layers.
+
 2011-09-06  Raimund Renkert <raimund.renkert@intevation.de>
 
 	* doc/conf/conf.xml:
--- a/flys-artifacts/doc/conf/mapserver/layer.vm	Tue Sep 06 11:10:13 2011 +0000
+++ b/flys-artifacts/doc/conf/mapserver/layer.vm	Tue Sep 06 15:25:54 2011 +0000
@@ -1,15 +1,21 @@
 LAYER
-    NAME      "$LAYER.getIdentifier()"
+    NAME      "$LAYER.getName()"
     TYPE      $LAYER.getType()
-    DATA      "$LAYER.getIdentifier()/$LAYER.getData()"
+    DATA      "$LAYER.getDirectory()/$LAYER.getData()"
     STATUS    ON
     TEMPLATE  map.html
     TOLERANCE 10
     DUMP      TRUE
+    #if( $LAYER.getGroup() )
+        GROUP "$LAYER.getGroup()"
+    #end
 
     METADATA
         "wms_title" "$LAYER.getTitle()"
         "gml_include_items" "all"
+        #if ( $LAYER.getGroupTitle() )
+            "wms_group_title" "$LAYER.getGroupTitle()"
+        #end
     END
 
     CLASS
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Tue Sep 06 11:10:13 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Tue Sep 06 15:25:54 2011 +0000
@@ -3,6 +3,7 @@
 public interface FacetTypes {
 
     String FLOODMAP_WSPLGEN       = "floodmap.wsplgen";
+    String FLOODMAP_BARRIERS      = "floodmap.barriers";
     String FLOODMAP_RIVERAXIS     = "floodmap.riveraxis";
     String FLOODMAP_WMSBACKGROUND = "floodmap.wmsbackground";
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/LayerInfo.java	Tue Sep 06 11:10:13 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/LayerInfo.java	Tue Sep 06 15:25:54 2011 +0000
@@ -1,37 +1,74 @@
 package de.intevation.flys.artifacts.model;
 
-import java.io.File;
-
 
 public class LayerInfo {
 
+    protected String name;
+    protected String type;
+    protected String directory;
     protected String data;
-
-    protected String type;
-    protected String identifier;
+    protected String group;
+    protected String groupTitle;
     protected String title;
 
 
-    public LayerInfo(File data, String type, String identifier, String title) {
-        this.data       = data.getName();
+    public LayerInfo(
+        String name,
+        String type,
+        String directory,
+        String data,
+        String title)
+    {
+        this(name, type, directory, data, title, null, null);
+    }
+
+
+    public LayerInfo(
+        String name,
+        String type,
+        String directory,
+        String data,
+        String title,
+        String group,
+        String groupTitle
+    ) {
+        this.name       = name;
         this.type       = type;
-        this.identifier = identifier;
+        this.directory  = directory;
+        this.data       = data;
+        this.group      = group;
+        this.groupTitle = groupTitle;
         this.title      = title;
     }
 
 
+    public String getName() {
+        return name;
+    }
+
+
+    public String getType() {
+        return type;
+    }
+
+
+    public String getDirectory() {
+        return directory;
+    }
+
+
     public String getData() {
         return data;
     }
 
 
-    public String getType() {
-        return type;
+    public String getGroup() {
+        return group;
     }
 
 
-    public String getIdentifier() {
-        return identifier;
+    public String getGroupTitle() {
+        return groupTitle;
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Tue Sep 06 11:10:13 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/FloodMapState.java	Tue Sep 06 15:25:54 2011 +0000
@@ -47,6 +47,7 @@
 import de.intevation.flys.exports.WstWriter;
 import de.intevation.flys.utils.FLYSUtils;
 import de.intevation.flys.utils.GeometryUtils;
+import de.intevation.flys.utils.MapfileGenerator;
 import de.intevation.flys.wsplgen.Scheduler;
 
 
@@ -114,7 +115,7 @@
         String url = FLYSUtils.getXPathString(FLYSUtils.XPATH_MAPSERVER_URL);
         url = url + "user-wms";
 
-        WMSLayerFacet facet = new WMSLayerFacet(
+        WMSLayerFacet wsplgen = new WMSLayerFacet(
             0,
             FLOODMAP_WSPLGEN,
             "Ergebnis der WSPLGEN Berechnung",
@@ -123,10 +124,27 @@
             hash,
             url);
 
-        facet.addLayer(artifact.identifier());
-        facet.setSrid(FLYSUtils.getRiverSrid(artifact));
+        String srid = FLYSUtils.getRiverSrid(artifact);
 
-        facets.add(facet);
+        wsplgen.addLayer(
+            artifact.identifier() + MapfileGenerator.MS_WSPLGEN_POSTFIX);
+        wsplgen.setSrid(srid);
+
+        WMSLayerFacet barriers = new WMSLayerFacet(
+            1,
+            FLOODMAP_WSPLGEN,
+            "Rohre/Graeben/Daemme",
+            ComputeType.ADVANCE,
+            getID(),
+            hash,
+            url);
+
+        barriers.addLayer(
+            artifact.identifier() + MapfileGenerator.MS_BARRIERS_POSTFIX);
+        barriers.setSrid(srid);
+
+        facets.add(wsplgen);
+        facets.add(barriers);
 
         context.afterCall(CallContext.BACKGROUND);
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java	Tue Sep 06 11:10:13 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java	Tue Sep 06 15:25:54 2011 +0000
@@ -29,7 +29,14 @@
 public class MapfileGenerator
 extends Thread
 {
-    public static final String WSPLGEN_RESULT_SHAPE = "wsplgen.shp";
+    public static final String WSPLGEN_RESULT_SHAPE   = "wsplgen.shp";
+    public static final String WSPLGEN_LINES_SHAPE    = "barrier_lines.shp";
+    public static final String WSPLGEN_POLYGONS_SHAPE = "barrier_polygons.shp";
+
+    public static final String MS_WSPLGEN_POSTFIX  = "-wsplgen";
+    public static final String MS_BARRIERS_POSTFIX = "-barriers";
+    public static final String MS_LINE_POSTFIX     = "-lines";
+    public static final String MS_POLYGONS_POSTFIX = "-polygons";
 
     protected static final long SLEEPTIME = 10 * 1000L; // 10 seconds
 
@@ -291,9 +298,18 @@
 
         for (File dir: dirs) {
             LayerInfo layer = parseUeskLayer(dir);
+            if (layer != null && layer.getData() != null) {
+                logger.debug("   Add WSPLGEN layer.");
+                layers.add(layer);
+            }
 
-            if (layer != null && layer.getData() != null) {
-                layers.add(layer);
+            List<LayerInfo> barriers = parseBarriersLayers(dir);
+            int num = barriers != null ? barriers.size() : 0;
+            if (num > 0) {
+                if (barriers.get(0).getData() != null) {
+                    logger.debug("   Add " + num + " BARRIERS layers.");
+                    layers.addAll(barriers);
+                }
             }
         }
 
@@ -308,14 +324,49 @@
             return null;
         }
 
-        return new LayerInfo(uesk, "POLYGON", dir.getName(), dir.getName());
+        return new LayerInfo(
+            dir.getName() + MS_WSPLGEN_POSTFIX,
+            "POLYGON",
+            dir.getName(),
+            WSPLGEN_RESULT_SHAPE,
+            "I18N_WSPLGEN_RESULT");
     }
 
 
-    protected LayerInfo parseBarriersLayers(File dir) {
-        // TODO IMPLEMENT ME
+    protected List<LayerInfo> parseBarriersLayers(File dir) {
+        List<LayerInfo> barriers = new ArrayList<LayerInfo>(2);
 
-        return null;
+        String group      = dir.getName() + MS_BARRIERS_POSTFIX;
+        String groupTitle = "I18N_BARRIERS_TITLE";
+
+        File lines    = new File(dir, WSPLGEN_LINES_SHAPE);
+        File polygons = new File(dir, WSPLGEN_POLYGONS_SHAPE);
+
+        if (lines.exists() || lines.isFile()) {
+            barriers.add(
+                new LayerInfo(
+                    dir.getName() + MS_LINE_POSTFIX,
+                    "LINE",
+                    dir.getName(),
+                    WSPLGEN_LINES_SHAPE,
+                    "I18N_LINE_SHAPE",
+                    group,
+                    groupTitle));
+        }
+
+        if (polygons.exists() || polygons.isFile()) {
+            barriers.add(
+                new LayerInfo(
+                    dir.getName() + MS_POLYGONS_POSTFIX,
+                    "POLYGON",
+                    dir.getName(),
+                    WSPLGEN_POLYGONS_SHAPE,
+                    "I18N_POLYGON_SHAPE",
+                    group,
+                    groupTitle));
+        }
+
+        return barriers;
     }
 
 

http://dive4elements.wald.intevation.org