[PATCH] Mapfile templates contain regex expressions to catch features more robust (#657)

Wald Commits scm-commit at wald.intevation.org
Wed Aug 14 14:21:05 CEST 2013


# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1376482859 -7200
# Node ID 74a437805e2a20b124ef5d8d4bd12a3520fb3cbd
# Parent  330ea29151682ba542fbc8d0f27fd3fb7ab9a4c5
Mapfile templates contain regex expressions to catch features more robust (#657).
Mapfile generation code is still confusing and should be refactored.

diff -r 330ea2915168 -r 74a437805e2a artifacts/doc/conf/mapserver/barrier_lines_class.vm
--- a/artifacts/doc/conf/mapserver/barrier_lines_class.vm	Wed Aug 14 11:28:30 2013 +0200
+++ b/artifacts/doc/conf/mapserver/barrier_lines_class.vm	Wed Aug 14 14:20:59 2013 +0200
@@ -1,6 +1,6 @@
 CLASS
     NAME "Damm"
-    EXPRESSION ("[TYP]"="Damm")
+    EXPRESSION /damm/i
     STYLE
         SIZE 5
         OUTLINECOLOR "#008000"
@@ -8,7 +8,7 @@
 END
 CLASS
     NAME "Rohr 1"
-    EXPRESSION ("[TYP]"="Rohr 1")
+    EXPRESSION /rohr.1/i
     STYLE
         SIZE 5
         OUTLINECOLOR "#800080"
@@ -16,7 +16,7 @@
 END
 CLASS
     NAME "Rohr 2"
-    EXPRESSION ("[TYP]"="Rohr 2")
+    EXPRESSION /rohr.2/i
     STYLE
         SIZE 5
         OUTLINECOLOR "#808080"
@@ -24,7 +24,7 @@
 END
 CLASS
     NAME "Graben"
-    EXPRESSION ("[TYP]"="Graben")
+    EXPRESSION /graben/i
     STYLE
         SIZE 5
         OUTLINECOLOR "#800000"
@@ -32,7 +32,7 @@
 END
 CLASS
     NAME "Ringdeich"
-    EXPRESSION ("[TYP]"="Ringdeich")
+    EXPRESSION /ringdeich/i
     STYLE
         SIZE 5
         OUTLINECOLOR "#800000"
diff -r 330ea2915168 -r 74a437805e2a artifacts/doc/conf/mapserver/barrier_polygons_class.vm
--- a/artifacts/doc/conf/mapserver/barrier_polygons_class.vm	Wed Aug 14 11:28:30 2013 +0200
+++ b/artifacts/doc/conf/mapserver/barrier_polygons_class.vm	Wed Aug 14 14:20:59 2013 +0200
@@ -1,6 +1,6 @@
 CLASS
     NAME "Ringdeich"
-    EXPRESSION ("[TYP]"="Ringdeich")
+    EXPRESSION /ringdeich/i
     STYLE
         SIZE 5
         OUTLINECOLOR "#FF8000"
diff -r 330ea2915168 -r 74a437805e2a artifacts/doc/conf/mapserver/mapfile.vm
--- a/artifacts/doc/conf/mapserver/mapfile.vm	Wed Aug 14 11:28:30 2013 +0200
+++ b/artifacts/doc/conf/mapserver/mapfile.vm	Wed Aug 14 14:20:59 2013 +0200
@@ -14,7 +14,8 @@
     END
 
     DEBUG 5
-    CONFIG "MS_ERRORFILE" "/tmp/flys-user-wms.log"
+    CONFIG "MS_ERRORFILE" "stderr"
+    # CONFIG "MS_ERRORFILE" "/tmp/flys-user-wms.log"
 
     WEB
       METADATA
diff -r 330ea2915168 -r 74a437805e2a artifacts/doc/conf/mapserver/river-mapfile.vm
--- a/artifacts/doc/conf/mapserver/river-mapfile.vm	Wed Aug 14 11:28:30 2013 +0200
+++ b/artifacts/doc/conf/mapserver/river-mapfile.vm	Wed Aug 14 14:20:59 2013 +0200
@@ -14,7 +14,8 @@
     END
 
     DEBUG 3
-    CONFIG "MS_ERRORFILE" "/tmp/flys-rivers-wms.log"
+    CONFIG "MS_ERRORFILE" "stderr"
+    # CONFIG "MS_ERRORFILE" "/tmp/flys-rivers-wms.log"
 
     WEB
       METADATA
diff -r 330ea2915168 -r 74a437805e2a artifacts/doc/conf/mapserver/shapefile_layer.vm
--- a/artifacts/doc/conf/mapserver/shapefile_layer.vm	Wed Aug 14 11:28:30 2013 +0200
+++ b/artifacts/doc/conf/mapserver/shapefile_layer.vm	Wed Aug 14 14:20:59 2013 +0200
@@ -21,6 +21,8 @@
             "wms_group_title" "$LAYER.getGroupTitle()"
         #end
     END
+    
+    CLASSITEM "TYP"
 
     #if ( !$LAYER.getStyle() )
         #if ( $LAYER.getGroupTitle() )
diff -r 330ea2915168 -r 74a437805e2a artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java	Wed Aug 14 11:28:30 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java	Wed Aug 14 14:20:59 2013 +0200
@@ -8,6 +8,16 @@
 
 package org.dive4elements.river.exports;
 
+import com.vividsolutions.jts.geom.Envelope;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
 import org.dive4elements.artifactdatabase.data.StateData;
 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
 import org.dive4elements.artifactdatabase.state.Facet;
@@ -27,20 +37,9 @@
 import org.dive4elements.river.utils.ArtifactMapfileGenerator;
 import org.dive4elements.river.utils.GeometryUtils;
 import org.dive4elements.river.utils.ThemeUtil;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import com.vividsolutions.jts.geom.Envelope;
-
 
 public class MapGenerator implements OutGenerator, FacetTypes {
 
@@ -120,9 +119,11 @@
                 setInitialExtent(extent);
                 createWSPLGENLayer(flys, wms, attr);
             }
-            else if (FLOODMAP_USERSHAPE.equals(name)) {
-                createUserShapeLayer(flys, wms);
-            }
+            // FIXME: Already generated by HWSBarrierState
+            // wms has a wrong SRID which would break that layer
+            //else if (FLOODMAP_USERSHAPE.equals(name)) {
+            //    createUserShapeLayer(flys, wms);
+            //}
             else {
                 logger.debug("doOut: createDatabaseLayer for facet name: " + name);
                 createDatabaseLayer(flys, wms, attr);
diff -r 330ea2915168 -r 74a437805e2a artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java
--- a/artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java	Wed Aug 14 11:28:30 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java	Wed Aug 14 14:20:59 2013 +0200
@@ -8,6 +8,13 @@
 
 package org.dive4elements.river.utils;
 
+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.dive4elements.artifacts.CallContext;
 import org.dive4elements.river.artifacts.D4EArtifact;
 import org.dive4elements.river.artifacts.access.RiverAccess;
@@ -16,14 +23,7 @@
 import org.dive4elements.river.artifacts.model.map.WMSLayerFacet;
 import org.dive4elements.river.artifacts.model.map.WSPLGENLayerFacet;
 import org.dive4elements.river.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.dive4elements.river.artifacts.states.FloodMapState;
 import org.geotools.data.shapefile.ShpFiles;
 import org.geotools.data.shapefile.shp.ShapefileHeader;
 import org.geotools.data.shapefile.shp.ShapefileReader;
@@ -135,11 +135,11 @@
         ShapefileReader sfr = new ShapefileReader(sf, true, false, null);
         ShapefileHeader sfh = sfr.getHeader();
 
-        String group      = uuid + MS_USERSHAPE_PREFIX;
+        String group      = MS_USERSHAPE_PREFIX + uuid;
         String groupTitle = "I18N_USER_SHAPE_TITLE";
 
         LayerInfo info = new LayerInfo();
-        info.setName(MS_USERSHAPE_PREFIX + uuid);
+        info.setName(MS_LAYER_PREFIX + FloodMapState.WSPLGEN_USER_RGD + uuid);
         if (sfh.getShapeType().isLineType()) {
             info.setType("LINE");
         }
@@ -156,7 +156,11 @@
         info.setGroupTitle(groupTitle);
         info.setSrid(wms.getSrid());
 
-        String nameUser = MS_LAYER_PREFIX + wms.getName();
+        //String nameUser = MS_LAYER_PREFIX + wms.getName();
+        // TODO: This rewrites the user-rgd mapfile fragment generated by
+        // HWSBarrierState. Otherwise we would have to fragments with same
+        // layer name. Should be refactored...
+        String nameUser = MS_LAYER_PREFIX + "user-rgd";
 
         Template tpl = getTemplateByName(SHP_LAYER_TEMPLATE);
         if (tpl == null) {
diff -r 330ea2915168 -r 74a437805e2a gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/WMSLayersTree.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/WMSLayersTree.java	Wed Aug 14 11:28:30 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/WMSLayersTree.java	Wed Aug 14 14:20:59 2013 +0200
@@ -8,16 +8,15 @@
 
 package org.dive4elements.river.client.client.ui.map;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import com.google.gwt.core.client.GWT;
-
 import com.smartgwt.client.types.TreeModelType;
 import com.smartgwt.client.widgets.tree.Tree;
 import com.smartgwt.client.widgets.tree.TreeGrid;
 import com.smartgwt.client.widgets.tree.TreeNode;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.dive4elements.river.client.shared.model.Capabilities;
 import org.dive4elements.river.client.shared.model.WMSLayer;
 
@@ -119,6 +118,13 @@
 
 
     protected WMSLayerNode buildTreeNode(WMSLayer wms) {
+        // FIXME: Is it correct to hide all layers with queryable=0 ?
+        // FIXME: Only for getFeatureInfo requests
+        //if (!wms.isQueryable()) {
+        //    GWT.log("WMSLayer " + wms.getName() + " is not queryable!");
+        //    return null;
+        //}
+
         if (srs != null && srs.length() > 0) {
             return wms.supportsSrs(srs) ? new WMSLayerNode(wms) : null;
         }
diff -r 330ea2915168 -r 74a437805e2a gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java	Wed Aug 14 11:28:30 2013 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java	Wed Aug 14 14:20:59 2013 +0200
@@ -8,12 +8,6 @@
 
 package org.dive4elements.river.client.server;
 
-import org.dive4elements.artifacts.common.utils.XMLUtils;
-import org.dive4elements.river.client.shared.exceptions.ServerException;
-import org.dive4elements.river.client.shared.model.Capabilities;
-import org.dive4elements.river.client.shared.model.ContactInformation;
-import org.dive4elements.river.client.shared.model.WMSLayer;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
@@ -27,6 +21,11 @@
 import javax.xml.xpath.XPathConstants;
 
 import org.apache.log4j.Logger;
+import org.dive4elements.artifacts.common.utils.XMLUtils;
+import org.dive4elements.river.client.shared.exceptions.ServerException;
+import org.dive4elements.river.client.shared.model.Capabilities;
+import org.dive4elements.river.client.shared.model.ContactInformation;
+import org.dive4elements.river.client.shared.model.WMSLayer;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;


More information about the Dive4elements-commits mailing list