Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java @ 4801:6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Tue, 15 Jan 2013 13:32:14 +0100 |
parents | 8e66293c5369 |
children | 5ca2516ebef1 |
comparison
equal
deleted
inserted
replaced
4800:c6814695c82c | 4801:6aa1b8abe2d3 |
---|---|
1 package de.intevation.flys.artifacts.services; | 1 package de.intevation.flys.artifacts.services; |
2 | |
3 import org.apache.log4j.Logger; | |
4 | |
5 import java.util.Map; | |
6 import java.util.HashMap; | |
7 | |
8 import org.w3c.dom.Document; | |
9 import org.w3c.dom.Node; | |
10 import org.w3c.dom.Element; | |
11 | |
12 import javax.xml.xpath.XPathConstants; | |
13 | 2 |
14 import com.vividsolutions.jts.geom.Envelope; | 3 import com.vividsolutions.jts.geom.Envelope; |
15 | 4 |
5 import de.intevation.artifactdatabase.XMLService; | |
16 import de.intevation.artifacts.CallMeta; | 6 import de.intevation.artifacts.CallMeta; |
17 import de.intevation.artifacts.GlobalContext; | 7 import de.intevation.artifacts.GlobalContext; |
18 | |
19 import de.intevation.artifacts.common.ArtifactNamespaceContext; | 8 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
20 import de.intevation.artifacts.common.utils.Config; | 9 import de.intevation.artifacts.common.utils.Config; |
21 import de.intevation.artifacts.common.utils.XMLUtils; | 10 import de.intevation.artifacts.common.utils.XMLUtils; |
22 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; | 11 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; |
12 import de.intevation.flys.utils.GeometryUtils; | |
23 | 13 |
24 import de.intevation.artifactdatabase.XMLService; | 14 import java.util.HashMap; |
15 import java.util.Map; | |
25 | 16 |
26 import de.intevation.flys.utils.GeometryUtils; | 17 import javax.xml.xpath.XPathConstants; |
18 | |
19 import org.apache.log4j.Logger; | |
20 import org.w3c.dom.Document; | |
21 import org.w3c.dom.Element; | |
22 import org.w3c.dom.Node; | |
27 | 23 |
28 /** | 24 /** |
29 * This service provides information about the supported rivers by this | 25 * This service provides information about the supported rivers by this |
30 * application. | 26 * application. |
31 * | 27 * |
41 | 37 |
42 public static final String XPATH_RIVER_BACKGROUND = | 38 public static final String XPATH_RIVER_BACKGROUND = |
43 "/artifact-database/floodmap/river[@name=$river]/background-wms"; | 39 "/artifact-database/floodmap/river[@name=$river]/background-wms"; |
44 | 40 |
45 public static final String XPATH_RIVER_WMS = | 41 public static final String XPATH_RIVER_WMS = |
46 "/artifact-database/floodmap/river[@name=$river]/river-wms/@url"; | 42 "/artifact-database/floodmap/river[@name=$river]/river-wms"; |
47 | 43 |
48 | 44 |
49 /** The logger used in this service.*/ | 45 /** The logger used in this service.*/ |
50 private static Logger logger = Logger.getLogger(MapInfoService.class); | 46 private static Logger logger = Logger.getLogger(MapInfoService.class); |
51 | 47 |
117 Element srid = cr.create("srid"); | 113 Element srid = cr.create("srid"); |
118 cr.addAttr(srid, "value", sridStr); | 114 cr.addAttr(srid, "value", sridStr); |
119 root.appendChild(srid); | 115 root.appendChild(srid); |
120 } | 116 } |
121 | 117 |
122 Element back = (Element)getNodeXPath(XPATH_RIVER_BACKGROUND, vars); | 118 logger.debug("processXML: " + XMLUtils.toString(root)); |
123 if (back != null) { | 119 root.appendChild( |
124 Element background = cr.create("background-wms"); | 120 createWMSElement("background-wms", XPATH_RIVER_BACKGROUND, vars, cr)); |
125 cr.addAttr(background, "url", back.getAttribute("url")); | 121 root.appendChild( |
126 cr.addAttr(background, "layers", back.getAttribute("layers")); | 122 createWMSElement("river-wms", XPATH_RIVER_WMS, vars, cr)); |
127 root.appendChild(background); | 123 |
124 return result; | |
125 } | |
126 | |
127 | |
128 protected Element createWMSElement( | |
129 String elementName, | |
130 String xpath, | |
131 Map<String, String> vars, | |
132 ElementCreator cr) | |
133 { | |
134 logger.debug("createWMSElement()"); | |
135 | |
136 Element el = cr.create(elementName); | |
137 Element wms = (Element)getNodeXPath(xpath, vars); | |
138 | |
139 if (wms != null) { | |
140 cr.addAttr(el, "url", wms.getAttribute("url")); | |
141 cr.addAttr(el, "layers", wms.getAttribute("layers")); | |
142 | |
143 logger.debug("createWMSElement: " + XMLUtils.toString(el)); | |
144 } | |
145 else { | |
146 logger.debug("createWMSElement: wms == null"); | |
128 } | 147 } |
129 | 148 |
130 String wmsStr = getStringXPath(XPATH_RIVER_WMS, vars); | 149 return el; |
131 if (wmsStr != null && wmsStr.length() > 0) { | |
132 Element wms = cr.create("river-wms"); | |
133 cr.addAttr(wms, "url", wmsStr); | |
134 root.appendChild(wms); | |
135 } | |
136 | |
137 return result; | |
138 } | 150 } |
139 | 151 |
140 | 152 |
141 protected String extractRiver(Document data) { | 153 protected String extractRiver(Document data) { |
142 return XMLUtils.xpathString( | 154 return XMLUtils.xpathString( |