# HG changeset patch # User Tom Gottfried # Date 1665489740 -7200 # Node ID 7227621f84967d6d395cb9af79b73ec67c007c0c # Parent a41f9c355204eef14fe5d413990c9668408805f0 Get rid of duplicate MapServer URL configurations diff -r a41f9c355204 -r 7227621f8496 artifacts/doc/conf/floodmap.xml --- a/artifacts/doc/conf/floodmap.xml Tue Oct 11 12:40:36 2022 +0200 +++ b/artifacts/doc/conf/floodmap.xml Tue Oct 11 14:02:20 2022 +0200 @@ -9,7 +9,6 @@ - diff -r a41f9c355204 -r 7227621f8496 artifacts/doc/conf/rivermap.xml --- a/artifacts/doc/conf/rivermap.xml Tue Oct 11 12:40:36 2022 +0200 +++ b/artifacts/doc/conf/rivermap.xml Tue Oct 11 14:02:20 2022 +0200 @@ -10,7 +10,6 @@ - diff -r a41f9c355204 -r 7227621f8496 artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java Tue Oct 11 12:40:36 2022 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/context/RiverContextFactory.java Tue Oct 11 14:02:20 2022 +0200 @@ -51,6 +51,7 @@ import org.dive4elements.river.themes.ThemeFactory; import org.dive4elements.river.themes.ThemeGroup; import org.dive4elements.river.themes.ThemeMapping; +import org.dive4elements.river.utils.RiverUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -595,7 +596,7 @@ Element e = (Element) rivers.item(i); String river = e.getAttribute("name"); - String url = XMLUtils.xpathString(e, "river-wms/@url", null); + String url = RiverUtils.getUserWMSUrl(); if (river != null && url != null) { riverWMS.put(river, url); diff -r a41f9c355204 -r 7227621f8496 artifacts/src/main/java/org/dive4elements/river/artifacts/services/MapInfoService.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/MapInfoService.java Tue Oct 11 12:40:36 2022 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/MapInfoService.java Tue Oct 11 14:02:20 2022 +0200 @@ -18,6 +18,7 @@ import org.dive4elements.artifacts.common.utils.XMLUtils; import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; import org.dive4elements.river.utils.GeometryUtils; +import org.dive4elements.river.utils.RiverUtils; import java.util.HashMap; import java.util.Map; @@ -38,6 +39,9 @@ */ public class MapInfoService extends XMLService { + private static final String MAPTYPE_FLOOD = "floodmap"; + private static final String MAPTYPE_RIVER = "rivermap"; + /** XPath that points to the river.*/ public static final String XPATH_RIVER = "/mapinfo/river/text()"; @@ -51,12 +55,6 @@ "/artifact-database/*[local-name()=$maptype]/" + "river[@name=$river]/background-wms"; - private static final String XPATH_RIVER_WMS = - "/artifact-database/*[local-name()=$maptype]/" - + "river[@name=$river]/river-wms"; - - - /** The log used in this service.*/ private static Logger log = LogManager.getLogger(MapInfoService.class); @@ -106,8 +104,8 @@ String mapType = extractMaptype(data); if (mapType == null - || !(mapType.equals("floodmap") || mapType.equals("rivermap"))) { - mapType = "floodmap"; + || !(mapType.equals(MAPTYPE_FLOOD) || mapType.equals(MAPTYPE_RIVER))) { + mapType = MAPTYPE_FLOOD; } Element root = cr.create("river"); @@ -142,13 +140,20 @@ log.debug("processXML: " + XMLUtils.toString(root)); } + Element bgWMS = (Element) getNodeXPath(XPATH_RIVER_BACKGROUND, vars); root.appendChild( createWMSElement("background-wms", - XPATH_RIVER_BACKGROUND, vars, cr)); + bgWMS.getAttribute("url"), + bgWMS.getAttribute("layers"), + cr)); root.appendChild( createWMSElement("river-wms", - XPATH_RIVER_WMS, vars, cr)); + mapType == MAPTYPE_FLOOD + ? RiverUtils.getUserWMSUrl() + : RiverUtils.getRiverWMSUrl(), + river, + cr)); return result; } @@ -156,24 +161,14 @@ protected Element createWMSElement( String elementName, - String xpath, - Map vars, + String url, + String layers, ElementCreator cr) { - log.debug("createWMSElement()"); - Element el = cr.create(elementName); - Element wms = (Element)getNodeXPath(xpath, vars); - if (wms != null) { - cr.addAttr(el, "url", wms.getAttribute("url")); - cr.addAttr(el, "layers", wms.getAttribute("layers")); - - log.debug("createWMSElement: " + XMLUtils.toString(el)); - } - else { - log.debug("createWMSElement: wms == null"); - } + cr.addAttr(el, "url", url); + cr.addAttr(el, "layers", layers); return el; } diff -r a41f9c355204 -r 7227621f8496 docker/README --- a/docker/README Tue Oct 11 12:40:36 2022 +0200 +++ b/docker/README Tue Oct 11 14:02:20 2022 +0200 @@ -1,6 +1,6 @@ Configure: _ Change 'localhost' to the hostname of your docker host in - artifacts/doc/conf/floodmap.xml and artifacts/doc/conf/rivermap.xml + artifacts/doc/conf/conf.xml _ Change 'example.com' to the hostname of your docker host plus ':8082' in artifacts/doc/conf/conf.xml _ Add to gwt-client/config/mapfish/config.yaml to enable map printing: