changeset 4810:5ca2516ebef1

Add rivermap.xml with sample configuration and adapt MapInfoService to use rivermap data instead of floodmap for rivermap.
author Christian Lins <christian.lins@intevation.de>
date Thu, 17 Jan 2013 21:06:41 +0100
parents 8062b571884d
children a06e443f159a
files flys-artifacts/doc/conf/rivermap.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java
diffstat 2 files changed, 40 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/rivermap.xml	Wed Jan 16 22:53:58 2013 +0100
+++ b/flys-artifacts/doc/conf/rivermap.xml	Thu Jan 17 21:06:41 2013 +0100
@@ -11,4 +11,20 @@
     <velocity>
         <logfile path="${artifacts.config.dir}/../rivermap_velocity.log"/>
     </velocity>
+    
+    <river name="Saar">
+        <srid value="31467"/>
+        <river-wms url="http://localhost:7777/cgi-bin/river-wms" layers="Saar"/>
+        <background-wms url="http://osm.intevation.de/mapcache/?" layers="flys-wms"/>
+    </river>
+    <river name="Mosel">
+        <srid value="31467"/>
+        <river-wms url="http://localhost:7777/cgi-bin/river-wms" layers="Mosel"/>
+        <background-wms url="http://osm.intevation.de/mapcache/?" layers="flys-wms"/>
+    </river>
+    <river name="Elbe">
+        <srid value="31467"/>
+        <river-wms url="http://localhost:7777/cgi-bin/river-wms" layers="Elbe"/>
+        <background-wms url="http://osm.intevation.de/mapcache/?" layers="flys-wms"/>
+    </river>
 </rivermap>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java	Wed Jan 16 22:53:58 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java	Thu Jan 17 21:06:41 2013 +0100
@@ -32,13 +32,15 @@
     /** XPath that points to the river.*/
     public static final String XPATH_RIVER = "/mapinfo/river/text()";
 
-    public static final String XPATH_RIVER_PROJECTION =
+    public static final String XPATH_MAPTYPE = "/mapinfo/maptype/text()";
+
+    private static final String XPATH_RIVER_PROJECTION =
         "/artifact-database/floodmap/river[@name=$river]/srid/@value";
 
-    public static final String XPATH_RIVER_BACKGROUND =
+    private static final String XPATH_RIVER_BACKGROUND =
         "/artifact-database/floodmap/river[@name=$river]/background-wms";
 
-    public static final String XPATH_RIVER_WMS =
+    private static final String XPATH_RIVER_WMS =
         "/artifact-database/floodmap/river[@name=$river]/river-wms";
 
 
@@ -70,6 +72,13 @@
             null, variables);
     }
 
+    protected String xpathMaptypeSwitch(String maptype, String xpath) {
+        if (maptype != null) {
+            return xpath.replace("floodmap", maptype);
+        }
+        return xpath;
+    }
+
     @Override
     public Document processXML(
         Document      data,
@@ -84,6 +93,7 @@
         Element mapinfo = cr.create("mapinfo");
         result.appendChild(mapinfo);
 
+        String mapType = extractMaptype(data);
         String river = extractRiver(data);
         if (river == null || river.length() == 0) {
             logger.warn("Cannot generate information: river is empty!");
@@ -107,7 +117,8 @@
         Map<String, String> vars = new HashMap<String, String>();
         vars.put("river", river);
 
-        String sridStr = getStringXPath(XPATH_RIVER_PROJECTION, vars);
+        String sridStr = getStringXPath(
+                xpathMaptypeSwitch(mapType, XPATH_RIVER_PROJECTION), vars);
 
         if (sridStr != null && sridStr.length() > 0) {
             Element srid = cr.create("srid");
@@ -117,9 +128,11 @@
 
         logger.debug("processXML: " + XMLUtils.toString(root));
         root.appendChild(
-                createWMSElement("background-wms", XPATH_RIVER_BACKGROUND, vars, cr));
+                createWMSElement("background-wms",
+                        xpathMaptypeSwitch(mapType, XPATH_RIVER_BACKGROUND), vars, cr));
         root.appendChild(
-                createWMSElement("river-wms", XPATH_RIVER_WMS, vars, cr));
+                createWMSElement("river-wms",
+                        xpathMaptypeSwitch(mapType, XPATH_RIVER_WMS), vars, cr));
 
         return result;
     }
@@ -154,5 +167,10 @@
         return XMLUtils.xpathString(
             data, XPATH_RIVER, ArtifactNamespaceContext.INSTANCE);
     }
+
+    protected String extractMaptype(Document data) {
+        return XMLUtils.xpathString(
+            data, XPATH_MAPTYPE, ArtifactNamespaceContext.INSTANCE);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org