annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java @ 4805:722b4962e30e

Comment/doc.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 16 Jan 2013 11:38:06 +0100
parents 6aa1b8abe2d3
children 5ca2516ebef1
rev   line source
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.services;
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
1774
092e1e5020bc Added a new MapGenerator which only returns a map configuration document at the moment (work still in progress).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1061
diff changeset
3 import com.vividsolutions.jts.geom.Envelope;
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
4801
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
5 import de.intevation.artifactdatabase.XMLService;
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import de.intevation.artifacts.CallMeta;
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import de.intevation.artifacts.GlobalContext;
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import de.intevation.artifacts.common.ArtifactNamespaceContext;
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import de.intevation.artifacts.common.utils.Config;
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.common.utils.XMLUtils;
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
4801
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
12 import de.intevation.flys.utils.GeometryUtils;
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
4801
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
14 import java.util.HashMap;
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
15 import java.util.Map;
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
4801
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
17 import javax.xml.xpath.XPathConstants;
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
18
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
19 import org.apache.log4j.Logger;
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
20 import org.w3c.dom.Document;
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
21 import org.w3c.dom.Element;
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
22 import org.w3c.dom.Node;
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 /**
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 * This service provides information about the supported rivers by this
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 * application.
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 *
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 */
2607
247f3e98a14b Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2098
diff changeset
30 public class MapInfoService extends XMLService {
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 /** XPath that points to the river.*/
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 public static final String XPATH_RIVER = "/mapinfo/river/text()";
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 public static final String XPATH_RIVER_PROJECTION =
2098
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
36 "/artifact-database/floodmap/river[@name=$river]/srid/@value";
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 public static final String XPATH_RIVER_BACKGROUND =
3264
eb9f7fd77edf Fixed XPath typo
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3076
diff changeset
39 "/artifact-database/floodmap/river[@name=$river]/background-wms";
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 public static final String XPATH_RIVER_WMS =
4801
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
42 "/artifact-database/floodmap/river[@name=$river]/river-wms";
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 /** The logger used in this service.*/
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 private static Logger logger = Logger.getLogger(MapInfoService.class);
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 /**
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 * The default constructor.
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 */
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 public MapInfoService() {
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 }
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
2098
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
55 protected static String getStringXPath(
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2607
diff changeset
56 String query,
2098
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
57 Map<String, String> variables
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
58 ) {
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
59 return (String)XMLUtils.xpath(
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
60 Config.getConfig(), query, XPathConstants.STRING,
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
61 null, variables);
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
62 }
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
63
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
64 protected static Node getNodeXPath(
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2607
diff changeset
65 String query,
2098
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
66 Map<String, String> variables
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
67 ) {
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
68 return (Node)XMLUtils.xpath(
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
69 Config.getConfig(), query, XPathConstants.NODE,
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
70 null, variables);
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
71 }
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72
2607
247f3e98a14b Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2098
diff changeset
73 @Override
247f3e98a14b Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2098
diff changeset
74 public Document processXML(
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 Document data,
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 GlobalContext globalContext,
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 CallMeta callMeta
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78 ) {
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79 logger.debug("MapInfoService.process");
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 Document result = XMLUtils.newDocument();
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 ElementCreator cr = new ElementCreator(result, null, null);
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84 Element mapinfo = cr.create("mapinfo");
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 result.appendChild(mapinfo);
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87 String river = extractRiver(data);
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 if (river == null || river.length() == 0) {
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89 logger.warn("Cannot generate information: river is empty!");
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 return result;
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 }
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93 Element root = cr.create("river");
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 cr.addAttr(root, "name", river);
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 mapinfo.appendChild(root);
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96
2078
cbeeaaad1056 #440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1774
diff changeset
97 Envelope env = GeometryUtils.getRiverBoundary(river);
cbeeaaad1056 #440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1774
diff changeset
98 if (env != null) {
cbeeaaad1056 #440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1774
diff changeset
99 String bounds = GeometryUtils.jtsBoundsToOLBounds(env);
cbeeaaad1056 #440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1774
diff changeset
100 logger.debug("River '" + river + "' bounds: " + bounds);
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 Element bbox = cr.create("bbox");
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 cr.addAttr(bbox, "value", bounds);
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 root.appendChild(bbox);
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 }
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106
2098
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
107 Map<String, String> vars = new HashMap<String, String>();
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
108 vars.put("river", river);
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
109
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
110 String sridStr = getStringXPath(XPATH_RIVER_PROJECTION, vars);
8284c8fca840 Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2097
diff changeset
111
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 if (sridStr != null && sridStr.length() > 0) {
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 Element srid = cr.create("srid");
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 cr.addAttr(srid, "value", sridStr);
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 root.appendChild(srid);
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 }
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117
4801
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
118 logger.debug("processXML: " + XMLUtils.toString(root));
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
119 root.appendChild(
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
120 createWMSElement("background-wms", XPATH_RIVER_BACKGROUND, vars, cr));
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
121 root.appendChild(
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
122 createWMSElement("river-wms", XPATH_RIVER_WMS, vars, cr));
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
123
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
124 return result;
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
125 }
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
126
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
127
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
128 protected Element createWMSElement(
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
129 String elementName,
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
130 String xpath,
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
131 Map<String, String> vars,
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
132 ElementCreator cr)
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
133 {
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
134 logger.debug("createWMSElement()");
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
135
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
136 Element el = cr.create(elementName);
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
137 Element wms = (Element)getNodeXPath(xpath, vars);
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
138
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
139 if (wms != null) {
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
140 cr.addAttr(el, "url", wms.getAttribute("url"));
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
141 cr.addAttr(el, "layers", wms.getAttribute("layers"));
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
142
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
143 logger.debug("createWMSElement: " + XMLUtils.toString(el));
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
144 }
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
145 else {
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
146 logger.debug("createWMSElement: wms == null");
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 }
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148
4801
6aa1b8abe2d3 MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents: 4049
diff changeset
149 return el;
1058
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 }
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 protected String extractRiver(Document data) {
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 return XMLUtils.xpathString(
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 data, XPATH_RIVER, ArtifactNamespaceContext.INSTANCE);
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 }
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 }
c37084f31c84 Implemented a MapInfo service that returns some basic information to create maps for specific rivers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org