changeset 840:47578d91c4f0

Added a metadata section into the mapfile and feed it with the MapServer URL (issue235). gnv-artifacts/trunk@952 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 20 Apr 2010 07:19:05 +0000
parents ac5988f27714
children 9cbc8343a04d
files gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/maptemplates/mapfile.vm gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java
diffstat 3 files changed, 56 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Mon Apr 19 14:19:19 2010 +0000
+++ b/gnv-artifacts/ChangeLog	Tue Apr 20 07:19:05 2010 +0000
@@ -1,3 +1,15 @@
+2010-04-20  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	  Issue235
+
+	* doc/conf/maptemplates/mapfile.vm: Added a metadata section into the 
+	  mapfile template.
+
+	* src/main/java/de/intevation/gnv/utils/MapfileGenerator.java: Read the URL
+	  of the MapServer from configuration and feed the template with this
+	  information. The URL is used in the metadata section for filling the 'wms
+	  onlineresource' field.
+
 2010-04-19	Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	  Issue152
--- a/gnv-artifacts/doc/conf/maptemplates/mapfile.vm	Mon Apr 19 14:19:19 2010 +0000
+++ b/gnv-artifacts/doc/conf/maptemplates/mapfile.vm	Tue Apr 20 07:19:05 2010 +0000
@@ -11,6 +11,27 @@
         "init=epsg:4326"
     END
 
+    WEB
+      METADATA
+        "wms_title"             "GNV 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@example.com"
+        "wms_contactvoicetelephone" "Any's telephone number"
+        "wms_srs" "EPSG:4326 EPSG:32631 EPSG:32632 EPSG:32633"
+        "wms_feature_info_mime_type" "text/html"
+      END
+    END
+
     ## Don't change the following lines.
     $LAYERS
 
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java	Mon Apr 19 14:19:19 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java	Tue Apr 20 07:19:05 2010 +0000
@@ -73,6 +73,12 @@
         "/artifact-database/velocity/logfile/@path";
 
     /**
+     * The URL for calling the mapserver
+     */
+    public static final String MAPSERVER_URL =
+        "/artifact-database/mapserver/server/@path";
+
+    /**
      * The name of the file storing meta information coresponding to shapefiles.
      */
     public static final String META_FILE_NAME = "meta.xml";
@@ -96,6 +102,7 @@
     private static MapfileGenerator instance;
 
     private File   mapfile;
+    private String mapServerUrl;
     private String shapefileDirectory;
     private String templatePath;
     private String velocityLogfile;
@@ -279,6 +286,21 @@
 
 
     /**
+     * Returns the URL for calling the MapServer.
+     *
+     * @return the url for calling the MapServer.
+     */
+    protected String getMapServerUrl() {
+        if (mapServerUrl == null) {
+            mapServerUrl = Config.getStringXPath(MAPSERVER_URL);
+            mapServerUrl = Config.replaceConfigDir(mapServerUrl);
+        }
+
+        return mapServerUrl;
+    }
+
+
+    /**
      * Returns a template specified by <i>model</i>.
      *
      * @param model The name of the template.
@@ -519,6 +541,7 @@
             writer   = new FileWriter(tmp);
 
             VelocityContext context = new VelocityContext();
+            context.put("MAPSERVERURL", getMapServerUrl());
             context.put("LAYERS", sb.toString());
 
             Template mapTemplate = getMapfileTemplate();

http://dive4elements.wald.intevation.org