svn-gvsig-desktop / tags / v2_0_0_Build_2050 / libraries / libRemoteServices / src / org / gvsig / remoteclient / wms / WMSProtocolHandler.java @ 38682
History | View | Annotate | Download (20.7 KB)
1 |
package org.gvsig.remoteclient.wms; |
---|---|
2 |
|
3 |
import java.io.ByteArrayInputStream; |
4 |
import java.io.File; |
5 |
import java.io.FileReader; |
6 |
import java.io.IOException; |
7 |
import java.io.InputStream; |
8 |
import java.net.URL; |
9 |
import java.net.URLConnection; |
10 |
import java.util.ArrayList; |
11 |
import java.util.StringTokenizer; |
12 |
import java.util.TreeMap; |
13 |
|
14 |
import org.gvsig.compat.net.ICancellable; |
15 |
import org.gvsig.remoteclient.exceptions.ServerErrorException; |
16 |
import org.gvsig.remoteclient.exceptions.WMSException; |
17 |
import org.gvsig.remoteclient.ogc.OGCProtocolHandler; |
18 |
import org.gvsig.remoteclient.ogc.OGCServiceInformation; |
19 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
20 |
import org.gvsig.remoteclient.utils.ExceptionTags; |
21 |
import org.gvsig.remoteclient.utils.Utilities; |
22 |
import org.gvsig.remoteclient.wms.request.WMSGetCapabilitiesRequest; |
23 |
import org.gvsig.remoteclient.wms.request.WMSGetFeatureInfoRequest; |
24 |
import org.gvsig.remoteclient.wms.request.WMSGetLegendGraphicRequest; |
25 |
import org.gvsig.remoteclient.wms.request.WMSGetMapRequest; |
26 |
import org.kxml2.io.KXmlParser; |
27 |
import org.xmlpull.v1.XmlPullParserException; |
28 |
|
29 |
/**
|
30 |
* <p> Abstract class that represents handlers to comunicate via WMS protocol.
|
31 |
* </p>
|
32 |
*
|
33 |
*/
|
34 |
public abstract class WMSProtocolHandler extends OGCProtocolHandler { |
35 |
/**
|
36 |
* Encoding used to parse different xml documents.
|
37 |
*/
|
38 |
protected String encoding = "UTF-8"; |
39 |
/**
|
40 |
* WMS metadata
|
41 |
*/
|
42 |
protected WMSServiceInformation serviceInfo;
|
43 |
public TreeMap layers; |
44 |
public WMSLayer rootLayer;
|
45 |
|
46 |
/**
|
47 |
* returns the alfanumeric information of the layers at the specified point.
|
48 |
* the diference between the other getfeatureInfo method is that this will
|
49 |
* be implemented by each specific version because the XML from the server will be
|
50 |
* parsed and presented by a well known structure.
|
51 |
*/
|
52 |
|
53 |
public String getName() { |
54 |
return name;
|
55 |
} |
56 |
|
57 |
/*
|
58 |
* (non-Javadoc)
|
59 |
* @see org.gvsig.remoteClient.ogc.OGCProtocolHandler#getServiceInformation()
|
60 |
*/
|
61 |
public OGCServiceInformation getServiceInformation() {
|
62 |
return serviceInfo;
|
63 |
} |
64 |
|
65 |
/**
|
66 |
* <p>Builds a GetCapabilities request that is sent to the WMS
|
67 |
* the response will be parse to extract the data needed by the
|
68 |
* WMS client</p>
|
69 |
* @param override, if true the previous downloaded data will be overridden
|
70 |
*/
|
71 |
public void getCapabilities(WMSStatus status, boolean override, ICancellable cancel) { |
72 |
URL request = null; |
73 |
try {
|
74 |
request = new URL(buildCapabilitiesRequest(status)); |
75 |
} catch(Exception e) { |
76 |
e.printStackTrace(); |
77 |
} |
78 |
try {
|
79 |
if (override)
|
80 |
Utilities.removeURL(request);
|
81 |
File f = Utilities.downloadFile(request,"wms_capabilities.xml", cancel); |
82 |
//WMSGetCapabilitiesRequest request = createGetCapabilitiesRequest(status);
|
83 |
//File f = request.sendRequest();
|
84 |
if (f == null) |
85 |
return;
|
86 |
clear(); |
87 |
parseCapabilities(f); |
88 |
} catch(Exception e) { |
89 |
e.printStackTrace(); |
90 |
} |
91 |
} |
92 |
|
93 |
private void clear() { |
94 |
layers.clear(); |
95 |
serviceInfo.clear(); |
96 |
} |
97 |
|
98 |
/**
|
99 |
* <p>It will send a GetFeatureInfo request to the WMS
|
100 |
* Parsing the response and redirecting the info to the WMS client</p>
|
101 |
* TODO: return a stored file instead a String.
|
102 |
*/
|
103 |
public String getFeatureInfo(WMSStatus status, int x, int y, int featureCount, ICancellable cancel) |
104 |
{ |
105 |
StringBuffer output = new StringBuffer(); |
106 |
String outputFormat = new String(); |
107 |
String ServiceException = "ServiceExceptionReport"; |
108 |
StringBuffer sb = new StringBuffer(); |
109 |
sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
|
110 |
try
|
111 |
{ |
112 |
WMSGetFeatureInfoRequest request = createGetFeatureInfoRequest(status, x, y); |
113 |
URL url = request.getURL();
|
114 |
outputFormat = url.openConnection().getContentType(); |
115 |
File f = request.sendRequest(cancel);
|
116 |
if (f == null){ |
117 |
return ""; |
118 |
} |
119 |
|
120 |
FileReader fReader = new FileReader(f); |
121 |
char[] buffer = new char[1024*256]; |
122 |
for (int i = fReader.read(buffer); i>0; i = fReader.read(buffer)) |
123 |
{ |
124 |
String str = new String(buffer,0,i); |
125 |
output.append(str); |
126 |
} |
127 |
if ( (outputFormat == null) || (outputFormat.indexOf("xml") != -1) |
128 |
||output.toString().toLowerCase().startsWith("<?xml")
|
129 |
||(outputFormat.indexOf("gml") != -1)) |
130 |
{ |
131 |
int tag;
|
132 |
KXmlParser kxmlParser = null;
|
133 |
kxmlParser = new KXmlParser();
|
134 |
//kxmlParser.setInput(new StringReader(output.toString()));
|
135 |
kxmlParser.setInput(new FileReader(f)); |
136 |
|
137 |
tag = kxmlParser.nextTag(); |
138 |
if (kxmlParser.getName().compareTo(ServiceException)==0) |
139 |
{ |
140 |
sb.append("<INFO>").append(parseException( output.toString().getBytes())).append("</INFO>"); |
141 |
return sb.toString();
|
142 |
} |
143 |
else if (kxmlParser.getName().compareToIgnoreCase("ERROR")==0) |
144 |
{ |
145 |
return output.toString();
|
146 |
} |
147 |
else
|
148 |
{ |
149 |
return output.toString();
|
150 |
} |
151 |
} |
152 |
else
|
153 |
{ |
154 |
//Para que funcione con el GetFeatureInfo Viewer generico hay que devolver:
|
155 |
return output.toString();
|
156 |
} |
157 |
} |
158 |
catch(XmlPullParserException parserEx)
|
159 |
{ |
160 |
if (output.toString().toLowerCase().indexOf("xml") != -1) |
161 |
{ |
162 |
return output.toString().trim();
|
163 |
} |
164 |
else
|
165 |
{ |
166 |
sb.append("<INFO>").append("Info format not supported").append("</INFO>"); |
167 |
return sb.toString();
|
168 |
} |
169 |
} |
170 |
catch(Exception e) |
171 |
{ |
172 |
e.printStackTrace(); |
173 |
sb.append("<INFO>").append("Info format not supported").append("</INFO>"); |
174 |
return sb.toString();
|
175 |
|
176 |
} |
177 |
} |
178 |
/**
|
179 |
* <p>Builds a GetMap request that is sent to the WMS
|
180 |
* the response (image) will be redirect to the
|
181 |
* WMS client</p>
|
182 |
*/
|
183 |
public byte[] _getMap(WMSStatus status) throws ServerErrorException, WMSException |
184 |
{ |
185 |
try
|
186 |
{ |
187 |
//TODO:
|
188 |
//pass this buildXXXRequest to the WMSProtocolHandlerXXX: The request can depend on the WMS version.
|
189 |
WMSGetMapRequest request = createGetMapRequest(status); |
190 |
URL url = request.getURL();
|
191 |
|
192 |
URLConnection conn = url.openConnection();
|
193 |
System.out.println(request.toString());
|
194 |
String type = conn.getContentType();
|
195 |
|
196 |
|
197 |
byte[] imageBytes = null; |
198 |
byte[] buffer = new byte[1024*256]; |
199 |
InputStream is = conn.getInputStream();
|
200 |
int readed = 0; |
201 |
|
202 |
for (int i = is.read(buffer); i>0; i = is.read(buffer)){ |
203 |
// Creates a new buffer to contain the previous readed bytes and the next bunch of bytes
|
204 |
byte[] buffered = new byte[readed+i]; |
205 |
for (int j = 0; j < buffered.length; j++) { |
206 |
if (j<readed){
|
207 |
// puts the previously downloaded bytes into the image buffer
|
208 |
buffered[j] = imageBytes[j]; |
209 |
} |
210 |
else {
|
211 |
// appends the recently downloaded bytes to the image buffer.
|
212 |
buffered[j] = buffer[j-readed]; |
213 |
} |
214 |
} |
215 |
imageBytes = (byte[]) buffered.clone(); |
216 |
readed += i; |
217 |
} |
218 |
|
219 |
if ((type !=null && !type.subSequence(0,5).equals("image")) |
220 |
||(Utilities.isTextData(imageBytes)))
|
221 |
{ |
222 |
WMSException wmsEx = null;
|
223 |
|
224 |
String exceptionMessage = parseException(imageBytes);
|
225 |
if (exceptionMessage==null) |
226 |
{ |
227 |
String error = new String(imageBytes); |
228 |
int pos = error.indexOf("<?xml"); |
229 |
if (pos!= -1) |
230 |
{ |
231 |
String xml = error.substring(pos,error.length());
|
232 |
exceptionMessage = parseException(xml.getBytes()); |
233 |
if (exceptionMessage == null) |
234 |
exceptionMessage = new String(imageBytes); |
235 |
} |
236 |
} |
237 |
wmsEx = new WMSException(exceptionMessage);
|
238 |
wmsEx.setWMSMessage(new String(imageBytes)); |
239 |
throw wmsEx;
|
240 |
} |
241 |
return imageBytes;
|
242 |
} |
243 |
catch(IOException e) |
244 |
{ |
245 |
e.printStackTrace(); |
246 |
throw new ServerErrorException(); |
247 |
} |
248 |
} |
249 |
|
250 |
public File getLegendGraphic(WMSStatus status, String layerName, ICancellable cancel) throws ServerErrorException, WMSException |
251 |
{ |
252 |
try
|
253 |
{ |
254 |
WMSGetLegendGraphicRequest request = createGetLegendGraphicRequest(status, layerName); |
255 |
File f = request.sendRequest(cancel);
|
256 |
if (f== null) |
257 |
return null; |
258 |
if (Utilities.isTextFile(f)) { |
259 |
|
260 |
byte[] data = fileToBytes(f); |
261 |
|
262 |
WMSException wmsEx = null;
|
263 |
|
264 |
String exceptionMessage = parseException(data);
|
265 |
if (exceptionMessage==null) |
266 |
{ |
267 |
String error = new String(data); |
268 |
int pos = error.indexOf("<?xml"); |
269 |
if (pos!= -1) |
270 |
{ |
271 |
String xml = error.substring(pos,error.length());
|
272 |
exceptionMessage = parseException(xml.getBytes()); |
273 |
} |
274 |
if (exceptionMessage == null) |
275 |
exceptionMessage = new String(data); |
276 |
|
277 |
} |
278 |
wmsEx = new WMSException(exceptionMessage);
|
279 |
wmsEx.setWMSMessage(new String(data)); |
280 |
downloader.removeURL(request); |
281 |
throw wmsEx;
|
282 |
} |
283 |
return f;
|
284 |
} |
285 |
catch(IOException e) |
286 |
{ |
287 |
e.printStackTrace(); |
288 |
throw new ServerErrorException(); |
289 |
} |
290 |
} |
291 |
|
292 |
public URL getMapURL(WMSStatus status, ICancellable cancel) throws ServerErrorException, WMSException { |
293 |
try {
|
294 |
WMSGetMapRequest request = createGetMapRequest(status); |
295 |
return request.getURL();
|
296 |
} catch(IOException e) { |
297 |
e.printStackTrace(); |
298 |
throw new ServerErrorException(); |
299 |
} |
300 |
} |
301 |
|
302 |
/**
|
303 |
* Returns the exception message if the file is a XML instead of a image.
|
304 |
* @param file3
|
305 |
* @return
|
306 |
* @throws IOException
|
307 |
*/
|
308 |
public String getExceptionMessage(File f) throws IOException { |
309 |
if (f == null) |
310 |
return null; |
311 |
|
312 |
if (Utilities.isTextFile(f)) { |
313 |
byte[] data = fileToBytes(f); |
314 |
|
315 |
String exceptionMessage = parseException(data);
|
316 |
if (exceptionMessage == null) { |
317 |
String error = new String(data); |
318 |
int pos = error.indexOf("<?xml"); |
319 |
if (pos!= -1) { |
320 |
String xml = error.substring(pos,error.length());
|
321 |
exceptionMessage = parseException(xml.getBytes()); |
322 |
} |
323 |
if (exceptionMessage == null) |
324 |
exceptionMessage = new String(data); |
325 |
} |
326 |
return exceptionMessage;
|
327 |
} |
328 |
return null; |
329 |
} |
330 |
|
331 |
public File getMap(WMSStatus status, ICancellable cancel) throws ServerErrorException, WMSException { |
332 |
try {
|
333 |
WMSGetMapRequest request = createGetMapRequest(status); |
334 |
File f = request.sendRequest(cancel);
|
335 |
|
336 |
if (f== null) |
337 |
return null; |
338 |
if (Utilities.isTextFile(f)) { |
339 |
byte[] data = fileToBytes(f); |
340 |
|
341 |
WMSException wmsEx = null;
|
342 |
|
343 |
String exceptionMessage = parseException(data);
|
344 |
if (exceptionMessage==null) { |
345 |
String error = new String(data); |
346 |
int pos = error.indexOf("<?xml"); |
347 |
if (pos!= -1) { |
348 |
String xml = error.substring(pos,error.length());
|
349 |
exceptionMessage = parseException(xml.getBytes()); |
350 |
// if (exceptionMessage == null)
|
351 |
// exceptionMessage = new String(data);
|
352 |
} |
353 |
if (exceptionMessage == null) |
354 |
exceptionMessage = new String(data); |
355 |
|
356 |
} |
357 |
wmsEx = new WMSException(exceptionMessage);
|
358 |
wmsEx.setWMSMessage(new String(data)); |
359 |
|
360 |
// Since it is an error file, It must be deleted from the cache
|
361 |
downloader.removeURL(request); |
362 |
throw wmsEx;
|
363 |
} |
364 |
return f;
|
365 |
} catch(IOException e) { |
366 |
e.printStackTrace(); |
367 |
throw new ServerErrorException(); |
368 |
} |
369 |
} |
370 |
|
371 |
|
372 |
/* (non-Javadoc)
|
373 |
* @see org.gvsig.remoteClient.wms.WMSProtocolHandler#parseException(byte[])
|
374 |
*/
|
375 |
protected String parseException(byte[] data) { |
376 |
ArrayList errors = new ArrayList(); |
377 |
KXmlParser kxmlParser = new KXmlParser();
|
378 |
try
|
379 |
{ |
380 |
kxmlParser.setInput(new ByteArrayInputStream(data), encoding); |
381 |
kxmlParser.nextTag(); |
382 |
int tag;
|
383 |
if ( kxmlParser.getEventType() != KXmlParser.END_DOCUMENT )
|
384 |
{ |
385 |
kxmlParser.require(KXmlParser.START_TAG, null, ExceptionTags.EXCEPTION_ROOT);
|
386 |
tag = kxmlParser.nextTag(); |
387 |
while(tag != KXmlParser.END_DOCUMENT)
|
388 |
{ |
389 |
switch(tag)
|
390 |
{ |
391 |
case KXmlParser.START_TAG:
|
392 |
if (kxmlParser.getName().compareTo(ExceptionTags.SERVICE_EXCEPTION)==0){ |
393 |
String errorCode = kxmlParser.getAttributeValue("", ExceptionTags.CODE); |
394 |
errorCode = (errorCode != null) ? "["+errorCode+"] " : ""; |
395 |
String errorMessage = kxmlParser.nextText();
|
396 |
errors.add(errorCode+errorMessage); |
397 |
} |
398 |
break;
|
399 |
case KXmlParser.END_TAG:
|
400 |
break;
|
401 |
|
402 |
} |
403 |
tag = kxmlParser.nextTag(); |
404 |
} |
405 |
//kxmlParser.require(KXmlParser.END_DOCUMENT, null, null);
|
406 |
} |
407 |
} |
408 |
catch(XmlPullParserException parser_ex){
|
409 |
parser_ex.printStackTrace(); |
410 |
} |
411 |
catch (IOException ioe) { |
412 |
ioe.printStackTrace(); |
413 |
} |
414 |
String message = errors.size()>0? "" : null; |
415 |
for (int i = 0; i < errors.size(); i++) { |
416 |
message += (String) errors.get(i)+"\n"; |
417 |
} |
418 |
return message;
|
419 |
} |
420 |
/**
|
421 |
* Builds the GetCapabilitiesRequest according to the OGC WMS Specifications
|
422 |
* without a VERSION, to get the highest version than a WMS supports.
|
423 |
*/
|
424 |
public static String buildCapabilitiesSuitableVersionRequest(String _host, String _version) |
425 |
{ |
426 |
int index = _host.indexOf('?'); |
427 |
|
428 |
if (index > -1) { |
429 |
String host = _host.substring(0, index + 1); |
430 |
String query = _host.substring(index + 1, _host.length()); |
431 |
|
432 |
StringTokenizer tokens = new StringTokenizer(query, "&"); |
433 |
String newQuery = "", token; |
434 |
|
435 |
// If there is a field or a value with spaces, (and then it's on different tokens) -> unify them
|
436 |
while (tokens.hasMoreTokens()) {
|
437 |
token = tokens.nextToken().trim(); |
438 |
|
439 |
if (token.toUpperCase().compareTo("REQUEST=GETCAPABILITIES") == 0) |
440 |
continue;
|
441 |
|
442 |
if (token.toUpperCase().compareTo("SERVICE=WMS") == 0) |
443 |
continue;
|
444 |
|
445 |
if ((_version != null) && (_version.length() > 0)) { |
446 |
if (token.toUpperCase().compareTo("VERSION=" + _version) == 0) |
447 |
continue;
|
448 |
} |
449 |
|
450 |
if (token.toUpperCase().compareTo("EXCEPTIONS=XML") == 0) |
451 |
continue;
|
452 |
|
453 |
newQuery += token + "&";
|
454 |
} |
455 |
|
456 |
_host = host + newQuery; |
457 |
} |
458 |
else {
|
459 |
_host += "?";
|
460 |
} |
461 |
|
462 |
if ((_version != null) && (_version.compareTo("") != 0)) |
463 |
_host += "REQUEST=GetCapabilities&SERVICE=WMS&VERSION=" + _version;
|
464 |
else
|
465 |
_host += "REQUEST=GetCapabilities&SERVICE=WMS";
|
466 |
|
467 |
return _host;
|
468 |
} |
469 |
|
470 |
/**
|
471 |
* Builds the GetCapabilitiesRequest according to the OGC WMS Specifications
|
472 |
* @param WMSStatus
|
473 |
*/
|
474 |
private String buildCapabilitiesRequest(WMSStatus status) |
475 |
{ |
476 |
StringBuffer req = new StringBuffer(); |
477 |
String symbol = null; |
478 |
|
479 |
String onlineResource;
|
480 |
if (status == null || status.getOnlineResource() == null) |
481 |
onlineResource = getHost(); |
482 |
else
|
483 |
onlineResource = status.getOnlineResource(); |
484 |
symbol = getSymbol(onlineResource); |
485 |
|
486 |
req.append(onlineResource).append(symbol).append("REQUEST=GetCapabilities&SERVICE=WMS&");
|
487 |
req.append("VERSION=").append(getVersion());
|
488 |
return req.toString();
|
489 |
} |
490 |
|
491 |
public void close() { |
492 |
// your code here
|
493 |
} |
494 |
|
495 |
/**
|
496 |
* @param status
|
497 |
* The WMS status
|
498 |
* @param protocolHandler
|
499 |
* The handler to parse the requests
|
500 |
* @return an object to send the GetMap requests
|
501 |
*/
|
502 |
protected abstract WMSGetMapRequest createGetMapRequest(WMSStatus status); |
503 |
|
504 |
protected abstract WMSGetFeatureInfoRequest createGetFeatureInfoRequest(WMSStatus status, int x, int y); |
505 |
|
506 |
protected abstract WMSGetLegendGraphicRequest createGetLegendGraphicRequest(WMSStatus status, String layerName); |
507 |
|
508 |
protected abstract WMSGetCapabilitiesRequest createGetCapabilitiesRequest(WMSStatus status); |
509 |
|
510 |
/**
|
511 |
* <p>Parses the Request tag </p>
|
512 |
*/
|
513 |
protected void parseRequestTag(KXmlParser parser) throws IOException, XmlPullParserException |
514 |
{ |
515 |
int currentTag;
|
516 |
boolean end = false; |
517 |
|
518 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.REQUEST);
|
519 |
currentTag = parser.next(); |
520 |
|
521 |
while (!end)
|
522 |
{ |
523 |
switch(currentTag)
|
524 |
{ |
525 |
case KXmlParser.START_TAG:
|
526 |
if (parser.getName().compareTo(CapabilitiesTags.GETCAPABILITIES)==0) |
527 |
{ |
528 |
parserDcpType(parser, CapabilitiesTags.GETCAPABILITIES); |
529 |
} |
530 |
else if (parser.getName().compareTo(CapabilitiesTags.GETMAP)==0) |
531 |
{ |
532 |
parseGetMapTag(parser); |
533 |
} |
534 |
else if (parser.getName().compareTo(CapabilitiesTags.GETFEATUREINFO)==0) |
535 |
{ |
536 |
parseGetFeatureInfoTag(parser); |
537 |
} |
538 |
else if (parser.getName().compareTo(CapabilitiesTags.DESCRIBELAYER)==0) |
539 |
{ |
540 |
parserDcpType(parser, CapabilitiesTags.DESCRIBELAYER); |
541 |
} |
542 |
else if (parser.getName().compareTo(CapabilitiesTags.GETLEGENDGRAPHIC)==0) |
543 |
{ |
544 |
parseGetLegendGraphicTag(parser); |
545 |
} |
546 |
break;
|
547 |
case KXmlParser.END_TAG:
|
548 |
if (parser.getName().compareTo(CapabilitiesTags.REQUEST) == 0) |
549 |
end = true;
|
550 |
break;
|
551 |
case KXmlParser.TEXT:
|
552 |
break;
|
553 |
} |
554 |
if(!end)
|
555 |
currentTag = parser.next(); |
556 |
} |
557 |
// TODO: does not get such a tag when arrives here!!!!!!
|
558 |
//parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.REQUEST);
|
559 |
} |
560 |
/**
|
561 |
* <p>Parses the GetMap tag </p>
|
562 |
*/
|
563 |
protected void parseGetMapTag(KXmlParser parser) throws IOException, XmlPullParserException |
564 |
{ |
565 |
int currentTag;
|
566 |
boolean end = false; |
567 |
|
568 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.GETMAP);
|
569 |
currentTag = parser.next(); |
570 |
|
571 |
while (!end)
|
572 |
{ |
573 |
switch(currentTag)
|
574 |
{ |
575 |
case KXmlParser.START_TAG:
|
576 |
if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0) |
577 |
{ |
578 |
serviceInfo.formats.add(parser.nextText()); |
579 |
} |
580 |
else if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0) |
581 |
{ |
582 |
parserDcpType(parser, CapabilitiesTags.GETMAP); |
583 |
} |
584 |
break;
|
585 |
case KXmlParser.END_TAG:
|
586 |
if (parser.getName().compareTo(CapabilitiesTags.GETMAP) == 0) |
587 |
end = true;
|
588 |
break;
|
589 |
case KXmlParser.TEXT:
|
590 |
break;
|
591 |
} |
592 |
if(!end)
|
593 |
currentTag = parser.next(); |
594 |
} |
595 |
} |
596 |
|
597 |
/**
|
598 |
* <p>Parses the GetFeatureInfo tag </p>
|
599 |
*/
|
600 |
protected void parseGetFeatureInfoTag(KXmlParser parser) throws IOException, XmlPullParserException |
601 |
{ |
602 |
int currentTag;
|
603 |
boolean end = false; |
604 |
|
605 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.GETFEATUREINFO);
|
606 |
currentTag = parser.next(); |
607 |
|
608 |
while (!end)
|
609 |
{ |
610 |
switch(currentTag)
|
611 |
{ |
612 |
case KXmlParser.START_TAG:
|
613 |
if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0) |
614 |
{ |
615 |
serviceInfo.infoformats.add(parser.nextText()); |
616 |
} |
617 |
else if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0) |
618 |
{ |
619 |
parserDcpType(parser, CapabilitiesTags.GETFEATUREINFO); |
620 |
} |
621 |
break;
|
622 |
case KXmlParser.END_TAG:
|
623 |
if (parser.getName().compareTo(CapabilitiesTags.GETFEATUREINFO) == 0) |
624 |
end = true;
|
625 |
break;
|
626 |
case KXmlParser.TEXT:
|
627 |
break;
|
628 |
} |
629 |
if(!end)
|
630 |
currentTag = parser.next(); |
631 |
} |
632 |
} |
633 |
|
634 |
/**
|
635 |
* <p>Parses the GetLegendGraphic tag </p>
|
636 |
*/
|
637 |
protected void parseGetLegendGraphicTag(KXmlParser parser) throws IOException, XmlPullParserException |
638 |
{ |
639 |
int currentTag;
|
640 |
boolean end = false; |
641 |
|
642 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.GETLEGENDGRAPHIC);
|
643 |
currentTag = parser.next(); |
644 |
|
645 |
while (!end)
|
646 |
{ |
647 |
switch(currentTag)
|
648 |
{ |
649 |
case KXmlParser.START_TAG:
|
650 |
if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0) |
651 |
{ |
652 |
//TODO:
|
653 |
// add the supported formats by the GetLegendGraphic request
|
654 |
//serviceInfo.formats.add(parser.nextText());
|
655 |
} |
656 |
else if (parser.getName().compareTo(CapabilitiesTags.DCPTYPE)==0) |
657 |
{ |
658 |
parserDcpType(parser, CapabilitiesTags.GETLEGENDGRAPHIC); |
659 |
} |
660 |
break;
|
661 |
case KXmlParser.END_TAG:
|
662 |
if (parser.getName().compareTo(CapabilitiesTags.GETLEGENDGRAPHIC) == 0) |
663 |
end = true;
|
664 |
break;
|
665 |
case KXmlParser.TEXT:
|
666 |
break;
|
667 |
} |
668 |
if(!end)
|
669 |
currentTag = parser.next(); |
670 |
} |
671 |
} |
672 |
} |