Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/GFIServiceImpl.java @ 2917:be99bf1aa59b
Create simplified column filter.
flys-client/trunk@4739 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 21 Jun 2012 11:55:37 +0000 |
parents | 30c7f8f9f1b7 |
children | af2aa716152f |
rev | line source |
---|---|
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.io.InputStream; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.io.IOException; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import java.net.URL; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import java.net.URLConnection; |
1402
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
7 import java.util.ArrayList; |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import java.util.List; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
1402
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
10 import org.w3c.dom.Document; |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
11 import org.w3c.dom.Node; |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
12 import org.w3c.dom.NodeList; |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
13 |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import org.apache.log4j.Logger; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
1402
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
18 import de.intevation.artifacts.common.utils.XMLUtils; |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.client.shared.exceptions.ServerException; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.client.shared.model.AttributedTheme; |
1402
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
22 import de.intevation.flys.client.shared.model.FeatureInfo; |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.client.shared.model.Theme; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.client.client.services.GFIService; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 /** |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 */ |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 public class GFIServiceImpl |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 extends RemoteServiceServlet |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 implements GFIService |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 public static final String ERR_NO_VALID_GFI_URL = |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 "error_no_valid_gfi_url"; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 public static final String ERR_GFI_REQUEST_FAILED = |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 "error_gfi_req_failed"; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 public static final String ERR_PARSING_RESPONSE_FAILED = |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 "error_gfi_parsing_failed"; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 private static final Logger logger = |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 Logger.getLogger(GFIServiceImpl.class); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 /** |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 * @param themes |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 * @param format |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 * @param bbox |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 * @param height |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 * @param width |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 * @param x |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 * @param y |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 * |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 * @return |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 */ |
1402
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
60 public List<FeatureInfo> query( |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 List<Theme> themes, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 String format, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 String bbox, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 String projection, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 int height, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 int width, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 int x, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 int y |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 ) throws ServerException |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 logger.info("GFIServiceImpl.query"); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 String path = createGetFeautureInfoURL( |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 themes, format, bbox, projection, height, width, x, y); |
1402
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
75 |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 logger.debug("URL=" + path); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 try { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 URL url = new URL(path); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 URLConnection conn = url.openConnection(); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 conn.connect(); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 InputStream is = conn.getInputStream(); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 |
1402
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
86 return parseResponse(is); |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 catch (IOException ioe) { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 logger.warn(ioe, ioe); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 throw new ServerException(ERR_GFI_REQUEST_FAILED); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 /** |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 * @param map |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 * @param themes |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 * @param format |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 * @param x |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 * @param y |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 * |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 * @return |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 */ |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 protected String createGetFeautureInfoURL( |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 List<Theme> themes, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 String infoFormat, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 String bbox, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 String projection, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 int height, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 int width, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 int x, |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 int y |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 ) throws ServerException |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 String url = getUrl(themes); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 if (url == null || url.length() == 0) { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 throw new ServerException(ERR_NO_VALID_GFI_URL); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 String layers = createLayersString(themes); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 StringBuilder sb = new StringBuilder(); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 sb.append(url); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 if (url.indexOf("?") < 0) { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 sb.append("?SERVICE=WMS"); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 else { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 sb.append("&SERVICE=WMS"); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 sb.append("&VERSION=1.1.1"); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 sb.append("&REQUEST=GetFeatureInfo"); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 sb.append("&LAYERS=" + layers); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 sb.append("&QUERY_LAYERS=" + layers); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 sb.append("&BBOX=" + bbox); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 sb.append("&HEIGHT=" + height); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 sb.append("&WIDTH=" + width); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 sb.append("&FORMAT=image/png"); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 sb.append("&INFO_FORMAT=" + infoFormat); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 sb.append("&SRS=" + projection); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 sb.append("&X=" + String.valueOf(x)); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 sb.append("&Y=" + String.valueOf(y)); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 return sb.toString(); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 protected String getUrl(List<Theme> themes) { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 for (Theme t: themes) { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 AttributedTheme attr = (AttributedTheme) t; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 if (attr.getAttrAsBoolean("queryable")) { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 return attr.getAttr("url"); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 return null; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 protected String createLayersString(List<Theme> themes) { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 StringBuilder sb = new StringBuilder(); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 boolean first = true; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 for (Theme theme: themes) { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 AttributedTheme layer = (AttributedTheme) theme; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 if (layer.getAttrAsBoolean("queryable")) { |
2448
30c7f8f9f1b7
Made GetFeatureInfo request available for maps with one layer only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1405
diff
changeset
|
172 if (!first) { |
30c7f8f9f1b7
Made GetFeatureInfo request available for maps with one layer only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1405
diff
changeset
|
173 sb.append(","); |
30c7f8f9f1b7
Made GetFeatureInfo request available for maps with one layer only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1405
diff
changeset
|
174 } |
30c7f8f9f1b7
Made GetFeatureInfo request available for maps with one layer only.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1405
diff
changeset
|
175 |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 sb.append(layer.getAttr("layers")); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 first = false; |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 return sb.toString(); |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 } |
1402
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
183 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
184 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
185 protected List<FeatureInfo> parseResponse(InputStream is) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
186 logger.debug("GFIServiceImpl.parseResponse"); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
187 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
188 Document response = XMLUtils.parseDocument(is); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
189 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
190 List<FeatureInfo> features = new ArrayList<FeatureInfo>(); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
191 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
192 parseFeatureInfos(response, features); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
193 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
194 return features; |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
195 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
196 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
197 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
198 protected void parseFeatureInfos(Node node, List<FeatureInfo> features) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
199 logger.debug("GFIServiceImpl.parseFeatureInfos"); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
200 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
201 String name = node.getNodeName(); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
202 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
203 if (name.endsWith("_layer")) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
204 features.add(parseFeature(node)); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
205 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
206 return; |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
207 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
208 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
209 NodeList children = node.getChildNodes(); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
210 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
211 if (children != null && children.getLength() > 0) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
212 for (int i = 0, n = children.getLength(); i < n; i++) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
213 parseFeatureInfos(children.item(i), features); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
214 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
215 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
216 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
217 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
218 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
219 protected FeatureInfo parseFeature(Node node) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
220 logger.debug("GFIServiceImpl.parseFeature"); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
221 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
222 String layername = node.getNodeName(); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
223 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
224 FeatureInfo f = new FeatureInfo(layername); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
225 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
226 NodeList children = node.getChildNodes(); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
227 int numChildren = children != null ? children.getLength() : 0; |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
228 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
229 logger.debug("Feature '" + layername + "' has " + numChildren + " nodes."); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
230 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
231 for (int i = 0; i < numChildren; i++) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
232 Node tmp = children.item(i); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
233 String nodeName = tmp.getNodeName(); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
234 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
235 logger.debug(" node name: '" + nodeName + "'"); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
236 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
237 if (nodeName.equals("gml:name")) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
238 logger.debug("NAME node has child: " + tmp.getFirstChild().getNodeValue()); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
239 f.setLayername(tmp.getFirstChild().getNodeValue()); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
240 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
241 else if (nodeName.endsWith("_feature")) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
242 parseFeatureAttributes(tmp, f); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
243 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
244 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
245 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
246 return f; |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
247 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
248 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
249 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
250 protected void parseFeatureAttributes(Node node, FeatureInfo f) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
251 logger.debug("GFIServiceImpl.parseFeatureAttributes"); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
252 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
253 NodeList children = node.getChildNodes(); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
254 int numChildren = children != null ? children.getLength() : 0; |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
255 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
256 logger.debug("Has " + numChildren + " attributes."); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
257 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
258 for (int i = 0; i < numChildren; i++) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
259 Node tmp = children.item(i); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
260 String name = tmp.getNodeName(); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
261 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
262 logger.debug(" tmp attribute name: '" + name + "'"); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
263 |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
264 if (name.equals("gml:boundedBy")) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
265 // TODO |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
266 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
267 else { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
268 Node child = tmp.getFirstChild(); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
269 if (child != null) { |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
270 f.addAttr(name, child.getNodeValue()); |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
271 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
272 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
273 } |
15ef3d3081b7
Parse GetFeatureInfo response on our own and display resulting FeatureInfo objects in the GetFeatureInfoWindow.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1400
diff
changeset
|
274 } |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
275 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
276 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |