Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java @ 4751:ee6c0f246b28
W80Parser: Added TODO/comment.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 03 Jan 2013 10:21:46 +0100 |
parents | d93748043cbc |
children | 8062b571884d |
line wrap: on
line source
package de.intevation.flys.utils; import de.intevation.flys.artifacts.model.LayerInfo; import de.intevation.flys.artifacts.model.RiverFactory; import de.intevation.flys.model.River; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import org.apache.velocity.Template; public class RiverMapfileGenerator extends MapfileGenerator { public static final String XPATH_RIVERMAP_RIVER_PROJECTION = "/artifact-database/rivermap/river[@name=$name]/srid/@value"; public static final String XPATH_RIVERMAP_SHAPEFILE_DIR = "/artifact-database/rivermap/shapefile-path/@value"; public static final String XPATH_RIVERMAP_VELOCITY_LOGFILE = "/artifact-database/rivermap/velocity/logfile/@path"; public static final String XPATH_RIVERMAP_MAPSERVER_URL = "/artifact-database/rivermap/mapserver/server/@path"; public static final String XPATH_RIVERMAP_MAPFILE_PATH = "/artifact-database/rivermap/mapserver/mapfile/@path"; public static final String XPATH_RIVERMAP_MAPFILE_TEMPLATE = "/artifact-database/rivermap/mapserver/map-template/@path"; public static final String XPATH_RIVERMAP_MAPSERVER_TEMPLATE_PATH = "/artifact-database/rivermap/mapserver/templates/@path"; private static Logger logger = Logger.getLogger(RiverMapfileGenerator.class); /** * Generate river axis mapfile. */ @Override public void generate() { logger.debug("generate()"); List<River> rivers = RiverFactory.getRivers(); List<String> riverFiles = new ArrayList<String>(); for (River river : rivers) { createRiverAxisLayer( river.getName(), river.getId(), "41677", "-10000 -10000 10000 10000"); riverFiles.add("river-" + river.getName() + ".map"); } writeMapfile(riverFiles); } protected void createRiverAxisLayer(String riverName, int riverID, String srid, String extend) { LayerInfo layerInfo = new LayerInfo(); layerInfo.setName(riverName); layerInfo.setSrid(srid); layerInfo.setExtent(extend); layerInfo.setType("line"); layerInfo.setData("geom FROM river_axis"); // FIXME: Use templates for that layerInfo.setFilter("river_id = " + riverID); layerInfo.setTitle(riverName + " RiverAxis"); File layerFile = new File("river-" + riverName + ".map"); Template template = getTemplateByName("riveraxis-layer.vm"); if (template == null) { logger.warn("Template riveraxis-layer.vm not found."); return; } try { writeLayer(layerInfo, layerFile, template); } catch (FileNotFoundException e) { logger.warn(e.getLocalizedMessage(), e); } } @Override protected String getVelocityLogfile() { return FLYSUtils.getXPathString(XPATH_RIVERMAP_VELOCITY_LOGFILE); } @Override protected String getMapserverTemplatePath() { return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPSERVER_TEMPLATE_PATH); } @Override protected String getMapserverUrl() { return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPSERVER_URL); } @Override protected String getMapfilePath() { return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPFILE_PATH); } @Override protected String getMapfileTemplate() { return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPFILE_TEMPLATE); } }