# HG changeset patch # User Christian Lins # Date 1358453201 -3600 # Node ID 5ca2516ebef198d6e48579105ade91767907743c # Parent 8062b571884d104050d42397e2bc9b0b31f9d086 Add rivermap.xml with sample configuration and adapt MapInfoService to use rivermap data instead of floodmap for rivermap. diff -r 8062b571884d -r 5ca2516ebef1 flys-artifacts/doc/conf/rivermap.xml --- 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 @@ + + + + + + + + + + + + + + + + diff -r 8062b571884d -r 5ca2516ebef1 flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java --- 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 vars = new HashMap(); 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 :