diff gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java @ 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 a645bd23c1c8
children f953c9a559d8
line wrap: on
line diff
--- 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