christian@4654: package de.intevation.flys.utils; christian@4654: christian@4654: import de.intevation.flys.artifacts.model.LayerInfo; christian@4654: import de.intevation.flys.artifacts.model.RiverFactory; christian@4654: import de.intevation.flys.model.River; christian@4654: christian@4656: import java.io.File; christian@4656: import java.io.FileNotFoundException; christian@4654: import java.util.List; christian@4654: christian@4656: import org.apache.log4j.Logger; christian@4656: import org.apache.velocity.Template; christian@4656: christian@4654: public class RiverMapfileGenerator extends MapfileGenerator { christian@4654: christian@4656: private static Logger logger = Logger.getLogger(RiverMapfileGenerator.class); christian@4656: christian@4654: /** christian@4654: * Generate river axis mapfile. christian@4654: */ christian@4654: @Override christian@4656: public void generate() { christian@4654: List rivers = RiverFactory.getRivers(); christian@4654: christian@4654: for (River river : rivers) { christian@4654: createRiverAxisLayer( christian@4654: river.getName(), christian@4654: river.getId(), christian@4654: "41677", christian@4654: "100,100,100,100"); christian@4654: } christian@4654: } christian@4654: christian@4654: protected void createRiverAxisLayer(String riverName, int riverID, String srid, String extend) { christian@4654: LayerInfo layerInfo = new LayerInfo(); christian@4654: layerInfo.setName(riverName); christian@4654: layerInfo.setSrid(srid); christian@4654: layerInfo.setExtent(extend); christian@4656: christian@4656: File layerFile = new File(getMapfilePath()); christian@4656: Template template = getTemplateByName(DB_LAYER_TEMPLATE); christian@4656: if (template == null) { christian@4656: logger.warn("Template '" + DB_LAYER_TEMPLATE + "' found."); christian@4656: return; christian@4656: } christian@4656: christian@4656: try { christian@4656: writeLayer(layerInfo, layerFile, template); christian@4656: } christian@4656: catch (FileNotFoundException e) { christian@4656: logger.warn(e.getLocalizedMessage(), e); christian@4656: } christian@4654: } christian@4654: christian@4656: @Override christian@4656: protected String getVelocityLogfile() { christian@4656: return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_VELOCITY_LOGFILE); christian@4656: } christian@4656: christian@4656: @Override christian@4656: protected String getMapserverTemplatePath() { christian@4656: return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPSERVER_TEMPLATE_PATH); christian@4656: } christian@4656: christian@4656: @Override christian@4656: protected String getMapserverUrl() { christian@4656: return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPSERVER_URL); christian@4656: } christian@4656: christian@4656: @Override christian@4656: protected String getMapfilePath() { christian@4656: return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPFILE_PATH); christian@4656: } christian@4656: christian@4656: @Override christian@4656: protected String getMapfileTemplate() { christian@4656: return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPFILE_TEMPLATE); christian@4656: } christian@4654: }