diff flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java @ 4703:38ec171544de

Work on rivers.map Generator.
author Christian Lins <christian.lins@intevation.de>
date Tue, 18 Dec 2012 15:46:36 +0100
parents 13abfb1bcb75
children d93748043cbc
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java	Mon Dec 17 23:24:27 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/RiverMapfileGenerator.java	Tue Dec 18 15:46:36 2012 +0100
@@ -14,6 +14,27 @@
 
 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);
 
     /**
@@ -24,17 +45,17 @@
         logger.debug("generate()");
 
         List<River>  rivers     = RiverFactory.getRivers();
-        List<String> riverNames = new ArrayList<String>();
+        List<String> riverFiles = new ArrayList<String>();
 
         for (River river : rivers) {
-            /*createRiverAxisLayer(
+            createRiverAxisLayer(
                     river.getName(),
                     river.getId(),
                     "41677",
-                    "100,100,100,100");*/
-            riverNames.add(river.getName());
+                    "100,100,100,100");
+            riverFiles.add("river-" + river.getName() + ".map");
         }
-        writeMapfile(riverNames);
+        writeMapfile(riverFiles);
     }
 
     protected void createRiverAxisLayer(String riverName, int riverID, String srid, String extend) {
@@ -42,11 +63,12 @@
         layerInfo.setName(riverName);
         layerInfo.setSrid(srid);
         layerInfo.setExtent(extend);
+        layerInfo.setConnectionType(FLYSUtils.isUsingOracle() ? "oraclespatial" : "postgis");
 
-        File layerFile = new File(getMapfilePath());
+        File layerFile = new File("river-" + riverName + ".map");
         Template template = getTemplateByName(DB_LAYER_TEMPLATE);
         if (template == null) {
-            logger.warn("Template '" + DB_LAYER_TEMPLATE + "' found.");
+            logger.warn("Template '" + DB_LAYER_TEMPLATE + "' not found.");
             return;
         }
 
@@ -60,26 +82,26 @@
 
     @Override
     protected String getVelocityLogfile() {
-        return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_VELOCITY_LOGFILE);
+        return FLYSUtils.getXPathString(XPATH_RIVERMAP_VELOCITY_LOGFILE);
     }
 
     @Override
     protected String getMapserverTemplatePath() {
-        return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPSERVER_TEMPLATE_PATH);
+        return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPSERVER_TEMPLATE_PATH);
     }
 
     @Override
     protected String getMapserverUrl() {
-        return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPSERVER_URL);
+        return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPSERVER_URL);
     }
 
     @Override
     protected String getMapfilePath() {
-        return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPFILE_PATH);
+        return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPFILE_PATH);
     }
 
     @Override
     protected String getMapfileTemplate() {
-        return FLYSUtils.getXPathString(FLYSUtils.XPATH_RIVERMAP_MAPFILE_TEMPLATE);
+        return FLYSUtils.getXPathString(XPATH_RIVERMAP_MAPFILE_TEMPLATE);
     }
 }

http://dive4elements.wald.intevation.org