changeset 6826:74a437805e2a

Mapfile templates contain regex expressions to catch features more robust (#657). Mapfile generation code is still confusing and should be refactored.
author Christian Lins <christian.lins@intevation.de>
date Wed, 14 Aug 2013 14:20:59 +0200
parents 330ea2915168
children 2972a219743d
files artifacts/doc/conf/mapserver/barrier_lines_class.vm artifacts/doc/conf/mapserver/barrier_polygons_class.vm artifacts/doc/conf/mapserver/mapfile.vm artifacts/doc/conf/mapserver/river-mapfile.vm artifacts/doc/conf/mapserver/shapefile_layer.vm artifacts/src/main/java/org/dive4elements/river/exports/MapGenerator.java artifacts/src/main/java/org/dive4elements/river/utils/ArtifactMapfileGenerator.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/WMSLayersTree.java gwt-client/src/main/java/org/dive4elements/river/client/server/CapabilitiesParser.java
diffstat 9 files changed, 57 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- 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"
--- 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"
--- 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
--- 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
--- 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() )
--- 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);
--- 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) {
--- 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;
         }
--- 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;

http://dive4elements.wald.intevation.org