Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/GFIServiceImpl.java @ 5829:18619c1e7c2a
Repaired internal references.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 11:54:36 +0200 |
parents | a4ff4167be1e |
children |
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; |
5818
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
4 import java.io.UnsupportedEncodingException; |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
5 import java.io.ByteArrayOutputStream; |
1400
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.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
|
7 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
|
8 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
|
9 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
|
10 import java.util.List; |
5818
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
11 import java.util.Scanner; |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
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
|
13 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
|
14 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
|
15 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
|
16 |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 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
|
18 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 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
|
20 |
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
|
21 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
|
22 |
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.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
|
24 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
|
25 import de.intevation.flys.client.shared.model.FeatureInfo; |
5818
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
26 import de.intevation.flys.client.shared.model.FeatureInfoResponse; |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 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
|
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 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
|
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 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 /** |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 * @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
|
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 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
|
36 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
|
37 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
|
38 { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 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
|
40 "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
|
41 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 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
|
43 "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
|
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 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
|
46 "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
|
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 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
|
50 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
|
51 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 /** |
5794
af2aa716152f
Fix issue1254, make GetFeatureInfo work reliably
Andre Heinecke <aheinecke@intevation.de>
parents:
2448
diff
changeset
|
54 * @param theme |
1400
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 format |
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 bbox |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 * @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
|
58 * @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
|
59 * @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
|
60 * @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
|
61 * |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 * @return |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 */ |
5818
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
64 public FeatureInfoResponse query( |
5794
af2aa716152f
Fix issue1254, make GetFeatureInfo work reliably
Andre Heinecke <aheinecke@intevation.de>
parents:
2448
diff
changeset
|
65 Theme theme, |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 ) 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
|
74 { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 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
|
76 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 String path = createGetFeautureInfoURL( |
5794
af2aa716152f
Fix issue1254, make GetFeatureInfo work reliably
Andre Heinecke <aheinecke@intevation.de>
parents:
2448
diff
changeset
|
78 theme, 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
|
79 |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 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
|
81 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 try { |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 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
|
84 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 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
|
86 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
|
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 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
|
89 |
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
|
90 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
|
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 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
|
94 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
|
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 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
|
98 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 /** |
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 map |
5794
af2aa716152f
Fix issue1254, make GetFeatureInfo work reliably
Andre Heinecke <aheinecke@intevation.de>
parents:
2448
diff
changeset
|
103 * @param theme |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 * @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
|
105 * @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
|
106 * @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
|
107 * |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 * @return |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 */ |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 protected String createGetFeautureInfoURL( |
5794
af2aa716152f
Fix issue1254, make GetFeatureInfo work reliably
Andre Heinecke <aheinecke@intevation.de>
parents:
2448
diff
changeset
|
111 Theme theme, |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 ) 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
|
120 { |
5794
af2aa716152f
Fix issue1254, make GetFeatureInfo work reliably
Andre Heinecke <aheinecke@intevation.de>
parents:
2448
diff
changeset
|
121 String url = getUrl(theme); |
1400
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 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
|
124 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
|
125 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 |
5794
af2aa716152f
Fix issue1254, make GetFeatureInfo work reliably
Andre Heinecke <aheinecke@intevation.de>
parents:
2448
diff
changeset
|
127 String layers = ((AttributedTheme)theme).getAttr("layers"); |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 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
|
130 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
|
131 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 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
|
133 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
|
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 else { |
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("&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
|
137 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 |
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("&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
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 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
|
150 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
|
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 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
|
153 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 |
5794
af2aa716152f
Fix issue1254, make GetFeatureInfo work reliably
Andre Heinecke <aheinecke@intevation.de>
parents:
2448
diff
changeset
|
156 protected String getUrl(Theme theme) { |
af2aa716152f
Fix issue1254, make GetFeatureInfo work reliably
Andre Heinecke <aheinecke@intevation.de>
parents:
2448
diff
changeset
|
157 AttributedTheme attr = (AttributedTheme) theme; |
5818
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
158 return attr.getAttr("url"); |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 } |
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
|
160 |
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
|
161 |
5818
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
162 protected FeatureInfoResponse parseResponse(InputStream is) { |
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
|
163 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
|
164 |
5818
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
165 ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
166 byte [] buf = new byte[1024]; |
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
|
167 |
5818
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
168 int r = -1; |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
169 try { |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
170 while ((r = is.read(buf)) >= 0) { |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
171 baos.write(buf, 0, r); |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
172 } |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
173 } catch (IOException ex) { |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
174 logger.warn("GetFeatureInfo response could not be read: ", ex); |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
175 return new FeatureInfoResponse(); |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
176 } |
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
|
177 |
5818
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
178 String content; |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
179 try { |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
180 content = baos.toString("UTF-8"); |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
181 } |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
182 catch (UnsupportedEncodingException uee) { |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
183 content = baos.toString(); |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
184 } |
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
|
185 |
5818
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
186 Document response = XMLUtils.parseDocument(content); |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
187 if (response != null) { |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
188 List<FeatureInfo> features = new ArrayList<FeatureInfo>(); |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
189 parseFeatureInfos(response, features); |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
190 return new FeatureInfoResponse(features, null); |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
191 } |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
192 // Unable to parse just return the response as is |
a4ff4167be1e
Request feature info on all layers and show it as html if
Andre Heinecke <aheinecke@intevation.de>
parents:
5794
diff
changeset
|
193 return new FeatureInfoResponse(new ArrayList<FeatureInfo>(), content); |
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
|
194 } |
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 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
|
198 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
|
199 |
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 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
|
201 |
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 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
|
203 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
|
204 |
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 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
|
206 } |
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 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
|
209 |
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 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
|
211 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
|
212 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
|
213 } |
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 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
|
219 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
|
220 |
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 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
|
222 |
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 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
|
224 |
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 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
|
226 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
|
227 |
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 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
|
229 |
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 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
|
231 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
|
232 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
|
233 |
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 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
|
235 |
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 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
|
237 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
|
238 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
|
239 } |
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 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
|
241 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
|
242 } |
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 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
|
246 } |
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 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
|
250 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
|
251 |
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 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
|
253 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
|
254 |
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 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
|
256 |
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 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
|
258 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
|
259 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
|
260 |
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 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
|
262 |
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 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
|
264 // 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
|
265 } |
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 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
|
267 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
|
268 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
|
269 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
|
270 } |
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 } |
1400
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
274 } |
96708d81eaf6
Added an initial GetFeatureInfo tool to get information about points in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
275 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |