comparison 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
comparison
equal deleted inserted replaced
839:ac5988f27714 840:47578d91c4f0
71 */ 71 */
72 public static final String VELOCITY_LOGFILE = 72 public static final String VELOCITY_LOGFILE =
73 "/artifact-database/velocity/logfile/@path"; 73 "/artifact-database/velocity/logfile/@path";
74 74
75 /** 75 /**
76 * The URL for calling the mapserver
77 */
78 public static final String MAPSERVER_URL =
79 "/artifact-database/mapserver/server/@path";
80
81 /**
76 * The name of the file storing meta information coresponding to shapefiles. 82 * The name of the file storing meta information coresponding to shapefiles.
77 */ 83 */
78 public static final String META_FILE_NAME = "meta.xml"; 84 public static final String META_FILE_NAME = "meta.xml";
79 85
80 /** 86 /**
94 private static Logger logger = Logger.getLogger(MapfileGenerator.class); 100 private static Logger logger = Logger.getLogger(MapfileGenerator.class);
95 101
96 private static MapfileGenerator instance; 102 private static MapfileGenerator instance;
97 103
98 private File mapfile; 104 private File mapfile;
105 private String mapServerUrl;
99 private String shapefileDirectory; 106 private String shapefileDirectory;
100 private String templatePath; 107 private String templatePath;
101 private String velocityLogfile; 108 private String velocityLogfile;
102 109
103 private VelocityEngine velocityEngine; 110 private VelocityEngine velocityEngine;
277 return templatePath; 284 return templatePath;
278 } 285 }
279 286
280 287
281 /** 288 /**
289 * Returns the URL for calling the MapServer.
290 *
291 * @return the url for calling the MapServer.
292 */
293 protected String getMapServerUrl() {
294 if (mapServerUrl == null) {
295 mapServerUrl = Config.getStringXPath(MAPSERVER_URL);
296 mapServerUrl = Config.replaceConfigDir(mapServerUrl);
297 }
298
299 return mapServerUrl;
300 }
301
302
303 /**
282 * Returns a template specified by <i>model</i>. 304 * Returns a template specified by <i>model</i>.
283 * 305 *
284 * @param model The name of the template. 306 * @param model The name of the template.
285 * @return a template. 307 * @return a template.
286 */ 308 */
517 539
518 tmp.createNewFile(); 540 tmp.createNewFile();
519 writer = new FileWriter(tmp); 541 writer = new FileWriter(tmp);
520 542
521 VelocityContext context = new VelocityContext(); 543 VelocityContext context = new VelocityContext();
544 context.put("MAPSERVERURL", getMapServerUrl());
522 context.put("LAYERS", sb.toString()); 545 context.put("LAYERS", sb.toString());
523 546
524 Template mapTemplate = getMapfileTemplate(); 547 Template mapTemplate = getMapfileTemplate();
525 if (mapTemplate == null) { 548 if (mapTemplate == null) {
526 logger.warn("No mapfile template found."); 549 logger.warn("No mapfile template found.");

http://dive4elements.wald.intevation.org