changeset 1816:5364b86a0880

Improved styles of WMS layers. flys-artifacts/trunk@3145 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 02 Nov 2011 15:02:23 +0000
parents a97764363ba2
children 595c404523a6
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/mapserver/db_layer.vm flys-artifacts/doc/conf/mapserver/fontset.txt flys-artifacts/doc/conf/mapserver/mapfile.vm flys-artifacts/doc/conf/mapserver/symbols.sym flys-artifacts/doc/conf/themes.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSKmArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DBLayerInfo.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/LayerInfo.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSDBLayerFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java
diffstat 15 files changed, 204 insertions(+), 96 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/ChangeLog	Wed Nov 02 15:02:23 2011 +0000
@@ -1,3 +1,51 @@
+2011-11-02  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/LayerInfo.java: Added
+	  setter methods for all parameters and removed the constructors. There is
+	  just an empty constructor - all parameters need to be set via setter
+	  methods.
+
+	* src/main/java/de/intevation/flys/utils/MapfileGenerator.java: Modified the
+	  creation of LayerInfo objects.
+
+	* src/main/java/de/intevation/flys/artifacts/model/DBLayerInfo.java:
+	  Removed, because the internal structure and constructors of LayerInfo have
+	  changed, so that we gonna use LayerInfo for all layers now.
+
+	* doc/conf/themes.xml: Modified the color definitions of
+	  'floodmap.riveraxis' and 'floodmap.kms' themes and added a 'symbol' field
+	  to 'floodmap.kms'.
+
+	* doc/conf/mapserver/symbols.sym,
+	  doc/conf/mapserver/fontset.txt: New. Required by Mapserver.
+
+	* doc/conf/mapserver/db_layer.vm: Added an 'EXTENT' field that is filled
+	  using LayerInfo.getExtent().
+
+	* doc/conf/mapserver/mapfile.vm: Modified FONTSET directory and added a
+	  SYMBOLSET.
+
+	* src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java: Added an
+	  abstract method getGeometryType().
+
+	* src/main/java/de/intevation/flys/artifacts/WMSKmArtifact.java: Override
+	  getGeometryType() of WMSDBArtifact. This Artifact provides "POINT"s.
+
+	* src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java:
+	  Create new WMSDBLayerFacets with geometry type "LINE".
+
+	* src/main/java/de/intevation/flys/artifacts/model/WMSDBLayerFacet.java:
+	  Added a 'geometryType' attribute and getter/setter methods. This attribute
+	  determines the type of geometry provided by this database wms layer. Types
+	  could be "POLYGON", "POINT", "LINE" and so on.
+
+	* src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java:
+	  Added a 'symbol' attribute to the inner class Clazz.
+
+	* src/main/java/de/intevation/flys/utils/ThemeUtil.java: Added a function to
+	  parse the symbol field of a theme. This symbol is used for
+	  MapserverStyle.Clazz.
+
 2011-11-02	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Apply point theme to heightmarks when imported in longitudinal
--- a/flys-artifacts/doc/conf/mapserver/db_layer.vm	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/doc/conf/mapserver/db_layer.vm	Wed Nov 02 15:02:23 2011 +0000
@@ -5,6 +5,7 @@
     INCLUDE "$CONFIGDIR/mapserver/dbconnection.include"
     DATA    "$LAYER.getData()"
     FILTER  '$LAYER.getFilter()'
+    EXTENT  $LAYER.getExtent()
 
     STATUS    ON
     TEMPLATE  map.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/doc/conf/mapserver/fontset.txt	Wed Nov 02 15:02:23 2011 +0000
@@ -0,0 +1,1 @@
+FreeSans /usr/share/fonts/truetype/freefont/FreeSans.ttf
--- a/flys-artifacts/doc/conf/mapserver/mapfile.vm	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/doc/conf/mapserver/mapfile.vm	Wed Nov 02 15:02:23 2011 +0000
@@ -6,7 +6,8 @@
     EXTENT -90 -180 90 180
     UNITS DD
     SHAPEPATH "$SHAPEFILEPATH"
-    FONTSET "$CONFIGDIR/fontset.txt"
+    FONTSET "$CONFIGDIR/mapserver/fontset.txt"
+    SYMBOLSET "$CONFIGDIR/mapserver/symbols.sym"
     IMAGECOLOR 255 255 255
     PROJECTION
         "init=epsg:31466"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/doc/conf/mapserver/symbols.sym	Wed Nov 02 15:02:23 2011 +0000
@@ -0,0 +1,22 @@
+SYMBOLSET
+SYMBOL
+  NAME 'point'
+  TYPE ELLIPSE
+  POINTS
+    1 1
+  END
+  FILLED TRUE
+END
+SYMBOL
+  NAME "square"
+  TYPE VECTOR
+  POINTS
+    0 0
+    0 1
+    1 1
+    1 0
+    0 0
+  END
+  FILLED TRUE
+END
+END
--- a/flys-artifacts/doc/conf/themes.xml	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/doc/conf/themes.xml	Wed Nov 02 15:02:23 2011 +0000
@@ -563,15 +563,16 @@
     <!-- MAP relevant themes -->
     <theme name="RiverAxis">
         <fields>
-            <field name="linecolor" type="Color" display="Linienfarbe" default="#800080"/>
+            <field name="linecolor" type="Color" display="Linienfarbe" default="0, 0, 205"/>
             <field name="linesize"  type="int"   display="Liniendicke" default="5" hints="h"/>
         </fields>
     </theme>
 
     <theme name="Kms">
         <fields>
-            <field name="linecolor" type="Color" display="Linienfarbe" default="#800080"/>
+            <field name="linecolor" type="Color" display="Linienfarbe" default="255, 0, 0"/>
             <field name="linesize"  type="int"   display="Liniendicke" default="5" hints="h"/>
+            <field name="symbol"    type="Symbol" display="Symbol"     default="square"/>
         </fields>
     </theme>
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java	Wed Nov 02 15:02:23 2011 +0000
@@ -125,6 +125,7 @@
             facet.setSrid(getSrid());
             facet.setData(getDataString());
             facet.setFilter(getFilter());
+            facet.setGeometryType(getGeometryType());
 
             facets.add(facet);
 
@@ -144,6 +145,8 @@
         protected abstract String getFilter();
 
         protected abstract String getDataString();
+
+        protected abstract String getGeometryType();
     } // end of WMSDBState
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSKmArtifact.java	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSKmArtifact.java	Wed Nov 02 15:02:23 2011 +0000
@@ -152,6 +152,10 @@
             return "geom FROM river_axes_km USING UNIQUE id USING SRID 31466";
         }
 
+        @Override
+        protected String getGeometryType() {
+            return "POINT";
+        }
     } // end of WMSKmState
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DBLayerInfo.java	Wed Nov 02 13:41:39 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-package de.intevation.flys.artifacts.model;
-
-
-public class DBLayerInfo extends LayerInfo {
-
-    protected String filter;
-
-
-    public DBLayerInfo(
-        String name,
-        String type,
-        String filter,
-        String data,
-        String title)
-    {
-        this(name, type, filter, data, title, null, null);
-    }
-
-
-    public DBLayerInfo(
-        String name,
-        String type,
-        String filter,
-        String data,
-        String title,
-        String group,
-        String groupTitle
-    ) {
-        super(name, type, null, data, group, groupTitle, title);
-        this.filter = filter;
-    }
-
-
-    public String getFilter() {
-        return filter;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/LayerInfo.java	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/LayerInfo.java	Wed Nov 02 15:02:23 2011 +0000
@@ -7,39 +7,20 @@
     protected String type;
     protected String directory;
     protected String data;
+    protected String extent;
     protected String group;
     protected String groupTitle;
     protected String title;
     protected String style;
+    protected String filter;
 
 
-    public LayerInfo(
-        String name,
-        String type,
-        String directory,
-        String data,
-        String title)
-    {
-        this(name, type, directory, data, title, null, null);
+    public LayerInfo() {
     }
 
 
-    public LayerInfo(
-        String name,
-        String type,
-        String directory,
-        String data,
-        String title,
-        String group,
-        String groupTitle
-    ) {
-        this.name       = name;
-        this.type       = type;
-        this.directory  = directory;
-        this.data       = data;
-        this.group      = group;
-        this.groupTitle = groupTitle;
-        this.title      = title;
+    public void setName(String name) {
+        this.name = name;
     }
 
 
@@ -48,36 +29,76 @@
     }
 
 
+    public void setType(String type) {
+        this.type = type;
+    }
+
+
     public String getType() {
         return type;
     }
 
 
+    public void setDirectory(String directory) {
+        this.directory = directory;
+    }
+
+
     public String getDirectory() {
         return directory;
     }
 
 
+    public void setData(String data) {
+        this.data = data;
+    }
+
+
     public String getData() {
         return data;
     }
 
 
+    public void setGroup(String group) {
+        this.group = group;
+    }
+
+
     public String getGroup() {
         return group;
     }
 
 
+    public void setGroupTitle(String groupTitle) {
+        this.groupTitle = groupTitle;
+    }
+
+
     public String getGroupTitle() {
         return groupTitle;
     }
 
 
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+
     public String getTitle() {
         return title;
     }
 
 
+    public void setExtent(String extent) {
+        this.extent = extent;
+    }
+
+
+    public String getExtent() {
+        return extent;
+    }
+
+
     public void setStyle(String style) {
         this.style = style;
     }
@@ -86,5 +107,15 @@
     public String getStyle() {
         return style;
     }
+
+
+    public void setFilter(String filter) {
+        this.filter = filter;
+    }
+
+
+    public String getFilter() {
+        return filter;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/MapserverStyle.java	Wed Nov 02 15:02:23 2011 +0000
@@ -9,6 +9,7 @@
     public static class Clazz {
         protected String name;
         protected String outlinecolor;
+        protected String symbol;
         protected int    size;
 
         public Clazz(String name) {
@@ -23,13 +24,24 @@
             this.size = size;
         }
 
+        public void setSymbol(String symbol) {
+            if (symbol != null && symbol.length() > 0) {
+                this.symbol = symbol;
+            }
+        }
+
         public String toString() {
             StringBuilder sb = new StringBuilder();
             sb.append("CLASS\n");
             sb.append("NAME \"" + name + "\"\n");
             sb.append("STYLE\n");
             sb.append("SIZE " + String.valueOf(size) + "\n");
-            sb.append("OUTLINECOLOR \"" + outlinecolor + "\"\n");
+            sb.append("OUTLINECOLOR " + outlinecolor + "\n");
+
+            if (symbol != null) {
+                sb.append("SYMBOL '" + symbol + "'\n");
+            }
+
             sb.append("END\n");
             sb.append("END\n");
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSDBLayerFacet.java	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSDBLayerFacet.java	Wed Nov 02 15:02:23 2011 +0000
@@ -7,6 +7,7 @@
 
     protected String data;
     protected String filter;
+    protected String geometryType;
 
 
     public WMSDBLayerFacet() {
@@ -60,5 +61,13 @@
     public String getData() {
         return data;
     }
+
+    public void setGeometryType(String geometryType) {
+        this.geometryType = geometryType;
+    }
+
+    public String getGeometryType() {
+        return geometryType;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java	Wed Nov 02 15:02:23 2011 +0000
@@ -69,6 +69,7 @@
         facet.setSrid(FLYSUtils.getRiverSrid(artifact));
         facet.setData("geom FROM river_axes USING UNIQUE id USING SRID 31466");
         facet.setFilter("river_id=1");
+        facet.setGeometryType("LINE");
 
         facets.add(facet);
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/MapfileGenerator.java	Wed Nov 02 15:02:23 2011 +0000
@@ -20,7 +20,6 @@
 import de.intevation.artifacts.common.utils.Config;
 
 import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.artifacts.model.DBLayerInfo;
 import de.intevation.flys.artifacts.model.LayerInfo;
 import de.intevation.flys.artifacts.model.WMSLayerFacet;
 import de.intevation.flys.artifacts.model.WMSDBLayerFacet;
@@ -370,12 +369,12 @@
     {
         logger.debug("createUeskLayer");
 
-        LayerInfo layerinfo = new LayerInfo(
-            flys.identifier() + MS_WSPLGEN_POSTFIX,
-            "POLYGON",
-            flys.identifier(),
-            WSPLGEN_RESULT_SHAPE,
-            "I18N_WSPLGEN_RESULT");
+        LayerInfo layerinfo = new LayerInfo();
+        layerinfo.setName(flys.identifier() + MS_WSPLGEN_POSTFIX);
+        layerinfo.setType("POLYGON");
+        layerinfo.setDirectory(flys.identifier());
+        layerinfo.setData(WSPLGEN_RESULT_SHAPE);
+        layerinfo.setTitle("I18N_WSPLGEN_RESULT");
 
         String name = MS_LAYER_PREFIX + wms.getName();
 
@@ -414,23 +413,23 @@
         String group      = uuid + MS_BARRIERS_POSTFIX;
         String groupTitle = "I18N_BARRIERS_TITLE";
 
-        LayerInfo lineInfo = new LayerInfo(
-            uuid + MS_LINE_POSTFIX,
-            "LINE",
-            uuid,
-            WSPLGEN_LINES_SHAPE,
-            "I18N_LINE_SHAPE",
-            group,
-            groupTitle);
+        LayerInfo lineInfo = new LayerInfo();
+        lineInfo.setName(uuid + MS_LINE_POSTFIX);
+        lineInfo.setType("LINE");
+        lineInfo.setDirectory(uuid);
+        lineInfo.setData(WSPLGEN_LINES_SHAPE);
+        lineInfo.setTitle("I18N_LINE_SHAPE");
+        lineInfo.setGroup(group);
+        lineInfo.setGroupTitle(groupTitle);
 
-        LayerInfo polygonInfo = new LayerInfo(
-            uuid + MS_POLYGONS_POSTFIX,
-            "POLYGON",
-            uuid,
-            WSPLGEN_POLYGONS_SHAPE,
-            "I18N_POLYGON_SHAPE",
-            group,
-            groupTitle);
+        LayerInfo polygonInfo = new LayerInfo();
+        polygonInfo.setName(uuid + MS_POLYGONS_POSTFIX);
+        polygonInfo.setType("POLYGON");
+        polygonInfo.setDirectory(uuid);
+        polygonInfo.setData(WSPLGEN_POLYGONS_SHAPE);
+        polygonInfo.setTitle("I18N_POLYGON_SHAPE");
+        polygonInfo.setGroup(group);
+        polygonInfo.setGroupTitle(groupTitle);
 
         String nameLines    = MS_LAYER_PREFIX + wms.getName() + "-lines";
         String namePolygons = MS_LAYER_PREFIX + wms.getName() + "-polygons";
@@ -475,13 +474,14 @@
     {
         logger.debug("createDatabaseLayer");
 
-        LayerInfo layerinfo = new DBLayerInfo(
-            flys.identifier() + "-" + wms.getName(),
-            "LINE",
-            wms.getFilter(),
-            wms.getData(),
-            wms.getDescription());
+        LayerInfo layerinfo = new LayerInfo();
+        layerinfo.setName(flys.identifier() + "-" + wms.getName());
+        layerinfo.setType(wms.getGeometryType());
+        layerinfo.setFilter(wms.getFilter());
+        layerinfo.setData(wms.getData());
+        layerinfo.setTitle(wms.getDescription());
         layerinfo.setStyle(style);
+        layerinfo.setExtent(GeometryUtils.jtsBoundsToOLBounds(wms.getExtent()));
 
         String name = MS_LAYER_PREFIX + wms.getName();
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Wed Nov 02 13:41:39 2011 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/ThemeUtil.java	Wed Nov 02 15:02:23 2011 +0000
@@ -57,6 +57,9 @@
     public final static String XPATH_SHOW_BACKGROUND =
         "/theme/field[@name='showbackground']/@default";
 
+    public final static String XPATH_SYMBOL =
+        "/theme/field[@name='symbol']/@default";
+
     /**
      * Parses line width, defaulting to 0.
      * @param theme the theme
@@ -292,6 +295,11 @@
     }
 
 
+    public static String getSymbol(Document theme) {
+        return XMLUtils.xpathString(theme, XPATH_SYMBOL, null);
+    }
+
+
     /**
      * Gets color from color field.
      * @param theme    the theme document.
@@ -303,14 +311,18 @@
 
 
     public static String createMapserverStyle(Document theme) {
+        String symbol    = getSymbol(theme);
         String linecolor = getLineColorString(theme);
-        int    linewidth = parseLineWidth(theme);
+        linecolor        = linecolor.replace(",", "");
+
+        int linewidth = parseLineWidth(theme);
 
         MapserverStyle ms = new MapserverStyle();
 
         Clazz c = new Clazz(" ");
         c.setOutlineColor(linecolor);
         c.setSize(linewidth);
+        c.setSymbol(symbol);
 
         ms.addClazz(c);
 

http://dive4elements.wald.intevation.org