comparison flys-client/src/main/java/de/intevation/flys/client/server/GFIServiceImpl.java @ 5794:af2aa716152f

Fix issue1254, make GetFeatureInfo work reliably This reduced GetFeatureInfo to one request per layer and chooses the layer based on the selected theme
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 23 Apr 2013 17:14:07 +0200
parents 30c7f8f9f1b7
children a4ff4167be1e
comparison
equal deleted inserted replaced
5793:4cc59122b682 5794:af2aa716152f
45 private static final Logger logger = 45 private static final Logger logger =
46 Logger.getLogger(GFIServiceImpl.class); 46 Logger.getLogger(GFIServiceImpl.class);
47 47
48 48
49 /** 49 /**
50 * @param themes 50 * @param theme
51 * @param format 51 * @param format
52 * @param bbox 52 * @param bbox
53 * @param height 53 * @param height
54 * @param width 54 * @param width
55 * @param x 55 * @param x
56 * @param y 56 * @param y
57 * 57 *
58 * @return 58 * @return
59 */ 59 */
60 public List<FeatureInfo> query( 60 public List<FeatureInfo> query(
61 List<Theme> themes, 61 Theme theme,
62 String format, 62 String format,
63 String bbox, 63 String bbox,
64 String projection, 64 String projection,
65 int height, 65 int height,
66 int width, 66 int width,
69 ) throws ServerException 69 ) throws ServerException
70 { 70 {
71 logger.info("GFIServiceImpl.query"); 71 logger.info("GFIServiceImpl.query");
72 72
73 String path = createGetFeautureInfoURL( 73 String path = createGetFeautureInfoURL(
74 themes, format, bbox, projection, height, width, x, y); 74 theme, format, bbox, projection, height, width, x, y);
75 75
76 logger.debug("URL=" + path); 76 logger.debug("URL=" + path);
77 77
78 try { 78 try {
79 URL url = new URL(path); 79 URL url = new URL(path);
94 } 94 }
95 95
96 96
97 /** 97 /**
98 * @param map 98 * @param map
99 * @param themes 99 * @param theme
100 * @param format 100 * @param format
101 * @param x 101 * @param x
102 * @param y 102 * @param y
103 * 103 *
104 * @return 104 * @return
105 */ 105 */
106 protected String createGetFeautureInfoURL( 106 protected String createGetFeautureInfoURL(
107 List<Theme> themes, 107 Theme theme,
108 String infoFormat, 108 String infoFormat,
109 String bbox, 109 String bbox,
110 String projection, 110 String projection,
111 int height, 111 int height,
112 int width, 112 int width,
113 int x, 113 int x,
114 int y 114 int y
115 ) throws ServerException 115 ) throws ServerException
116 { 116 {
117 String url = getUrl(themes); 117 String url = getUrl(theme);
118 118
119 if (url == null || url.length() == 0) { 119 if (url == null || url.length() == 0) {
120 throw new ServerException(ERR_NO_VALID_GFI_URL); 120 throw new ServerException(ERR_NO_VALID_GFI_URL);
121 } 121 }
122 122
123 String layers = createLayersString(themes); 123 String layers = ((AttributedTheme)theme).getAttr("layers");
124 124
125 StringBuilder sb = new StringBuilder(); 125 StringBuilder sb = new StringBuilder();
126 sb.append(url); 126 sb.append(url);
127 127
128 if (url.indexOf("?") < 0) { 128 if (url.indexOf("?") < 0) {
147 147
148 return sb.toString(); 148 return sb.toString();
149 } 149 }
150 150
151 151
152 protected String getUrl(List<Theme> themes) { 152 protected String getUrl(Theme theme) {
153 for (Theme t: themes) { 153 AttributedTheme attr = (AttributedTheme) theme;
154 AttributedTheme attr = (AttributedTheme) t; 154
155 155 if (attr.getAttrAsBoolean("queryable")) {
156 if (attr.getAttrAsBoolean("queryable")) { 156 return attr.getAttr("url");
157 return attr.getAttr("url"); 157 }
158 }
159 }
160
161 return null; 158 return null;
162 }
163
164
165 protected String createLayersString(List<Theme> themes) {
166 StringBuilder sb = new StringBuilder();
167 boolean first = true;
168
169 for (Theme theme: themes) {
170 AttributedTheme layer = (AttributedTheme) theme;
171 if (layer.getAttrAsBoolean("queryable")) {
172 if (!first) {
173 sb.append(",");
174 }
175
176 sb.append(layer.getAttr("layers"));
177 first = false;
178 }
179 }
180
181 return sb.toString();
182 } 159 }
183 160
184 161
185 protected List<FeatureInfo> parseResponse(InputStream is) { 162 protected List<FeatureInfo> parseResponse(InputStream is) {
186 logger.debug("GFIServiceImpl.parseResponse"); 163 logger.debug("GFIServiceImpl.parseResponse");

http://dive4elements.wald.intevation.org