Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MapInfoService.java @ 5639:db4e7ff0b987
Doc and whitespaces.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 10 Apr 2013 09:27:18 +0200 |
parents | a06e443f159a |
children |
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 |
4810
5ca2516ebef1
Add rivermap.xml with sample configuration and adapt MapInfoService to use rivermap data instead of floodmap for rivermap.
Christian Lins <christian.lins@intevation.de>
parents:
4801
diff
changeset
|
35 public static final String XPATH_MAPTYPE = "/mapinfo/maptype/text()"; |
5ca2516ebef1
Add rivermap.xml with sample configuration and adapt MapInfoService to use rivermap data instead of floodmap for rivermap.
Christian Lins <christian.lins@intevation.de>
parents:
4801
diff
changeset
|
36 |
5ca2516ebef1
Add rivermap.xml with sample configuration and adapt MapInfoService to use rivermap data instead of floodmap for rivermap.
Christian Lins <christian.lins@intevation.de>
parents:
4801
diff
changeset
|
37 private static final String XPATH_RIVER_PROJECTION = |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
38 "/artifact-database/*[local-name()=$maptype]/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
|
39 |
4810
5ca2516ebef1
Add rivermap.xml with sample configuration and adapt MapInfoService to use rivermap data instead of floodmap for rivermap.
Christian Lins <christian.lins@intevation.de>
parents:
4801
diff
changeset
|
40 private static final String XPATH_RIVER_BACKGROUND = |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
41 "/artifact-database/*[local-name()=$maptype]/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
|
42 |
4810
5ca2516ebef1
Add rivermap.xml with sample configuration and adapt MapInfoService to use rivermap data instead of floodmap for rivermap.
Christian Lins <christian.lins@intevation.de>
parents:
4801
diff
changeset
|
43 private static final String XPATH_RIVER_WMS = |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
44 "/artifact-database/*[local-name()=$maptype]/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
|
45 |
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 |
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 /** 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
|
48 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
|
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 |
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 * 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
|
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 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
|
55 } |
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
|
56 |
2098
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
57 protected static String getStringXPath( |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2607
diff
changeset
|
58 String query, |
2098
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
59 Map<String, String> variables |
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
60 ) { |
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
61 return (String)XMLUtils.xpath( |
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
62 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
|
63 null, variables); |
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
64 } |
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
65 |
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
66 protected static Node getNodeXPath( |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2607
diff
changeset
|
67 String query, |
2098
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
68 Map<String, String> variables |
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
69 ) { |
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
70 return (Node)XMLUtils.xpath( |
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
71 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
|
72 null, variables); |
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
73 } |
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
|
74 |
2607
247f3e98a14b
Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2098
diff
changeset
|
75 @Override |
247f3e98a14b
Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2098
diff
changeset
|
76 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
|
77 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
|
78 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
|
79 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
|
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 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
|
82 |
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 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
|
84 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
|
85 |
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 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
|
87 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
|
88 |
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 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
|
90 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
|
91 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
|
92 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
|
93 } |
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 |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
95 String mapType = extractMaptype(data); |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
96 if (mapType == null |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
97 || !(mapType.equals("floodmap") || mapType.equals("rivermap"))) { |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
98 mapType = "floodmap"; |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
99 } |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
100 |
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 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
|
102 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
|
103 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
|
104 |
2078
cbeeaaad1056
#440 Support river axes that consist of more than a single geometry.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1774
diff
changeset
|
105 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
|
106 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
|
107 String bounds = GeometryUtils.jtsBoundsToOLBounds(env); |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
108 if (logger.isDebugEnabled()) { |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
109 logger.debug("River '" + river + "' bounds: " + bounds); |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
110 } |
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
|
111 |
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 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
|
113 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
|
114 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
|
115 } |
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 |
2098
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
117 Map<String, String> vars = new HashMap<String, String>(); |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
118 vars.put("maptype", mapType); |
2098
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
119 vars.put("river", river); |
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
120 |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
121 String sridStr = getStringXPath(XPATH_RIVER_PROJECTION, vars); |
2098
8284c8fca840
Removed security problem when working with map infos.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2097
diff
changeset
|
122 |
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
|
123 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
|
124 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
|
125 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
|
126 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
|
127 } |
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
|
128 |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
129 if (logger.isDebugEnabled()) { |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
130 logger.debug("processXML: " + XMLUtils.toString(root)); |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
131 } |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
132 |
4801
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
133 root.appendChild( |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
134 createWMSElement("background-wms", |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
135 XPATH_RIVER_BACKGROUND, vars, cr)); |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
136 |
4801
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
137 root.appendChild( |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
138 createWMSElement("river-wms", |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
139 XPATH_RIVER_WMS, vars, cr)); |
4801
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
140 |
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
141 return result; |
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 |
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 protected Element createWMSElement( |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
146 String elementName, |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
147 String xpath, |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
148 Map<String, String> vars, |
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
149 ElementCreator cr) |
4801
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
150 { |
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
151 logger.debug("createWMSElement()"); |
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
152 |
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
153 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
|
154 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
|
155 |
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
156 if (wms != null) { |
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
157 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
|
158 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
|
159 |
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
160 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
|
161 } |
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
162 else { |
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
163 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
|
164 } |
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
|
165 |
4801
6aa1b8abe2d3
MapInfoService now submits layer names as well as WMS urls.
Christian Lins <christian.lins@intevation.de>
parents:
4049
diff
changeset
|
166 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
|
167 } |
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
|
168 |
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
|
169 |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
170 private static String extractRiver(Document data) { |
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
|
171 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
|
172 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
|
173 } |
4810
5ca2516ebef1
Add rivermap.xml with sample configuration and adapt MapInfoService to use rivermap data instead of floodmap for rivermap.
Christian Lins <christian.lins@intevation.de>
parents:
4801
diff
changeset
|
174 |
4811
a06e443f159a
Removed XPath injection!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4810
diff
changeset
|
175 private static String extractMaptype(Document data) { |
4810
5ca2516ebef1
Add rivermap.xml with sample configuration and adapt MapInfoService to use rivermap data instead of floodmap for rivermap.
Christian Lins <christian.lins@intevation.de>
parents:
4801
diff
changeset
|
176 return XMLUtils.xpathString( |
5ca2516ebef1
Add rivermap.xml with sample configuration and adapt MapInfoService to use rivermap data instead of floodmap for rivermap.
Christian Lins <christian.lins@intevation.de>
parents:
4801
diff
changeset
|
177 data, XPATH_MAPTYPE, ArtifactNamespaceContext.INSTANCE); |
5ca2516ebef1
Add rivermap.xml with sample configuration and adapt MapInfoService to use rivermap data instead of floodmap for rivermap.
Christian Lins <christian.lins@intevation.de>
parents:
4801
diff
changeset
|
178 } |
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
|
179 } |
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
|
180 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |