Revision 3755
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/WMSLayer.java | ||
---|---|---|
7 | 7 |
import java.util.Vector; |
8 | 8 |
|
9 | 9 |
import org.gvsig.remoteClient.utils.BoundaryBox; |
10 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
|
10 | 11 |
import org.kxml2.io.KXmlParser; |
11 | 12 |
import org.xmlpull.v1.XmlPullParserException; |
12 | 13 |
|
... | ... | |
107 | 108 |
throws IOException, XmlPullParserException; |
108 | 109 |
|
109 | 110 |
|
111 |
/** |
|
112 |
* add a new keyword to the keywordList. |
|
113 |
* @param key |
|
114 |
*/ |
|
110 | 115 |
protected void addkeyword(String key) |
111 | 116 |
{ |
112 | 117 |
keywordList.add(key); |
... | ... | |
376 | 381 |
return transparency; |
377 | 382 |
} |
378 | 383 |
|
384 |
//Methods to parse tags that are common to several versions of WMS. |
|
385 |
//In case there is a version which has different implemantation of one of this tags |
|
386 |
// the subclass can overwrite this method |
|
387 |
|
|
379 | 388 |
/** |
389 |
* Parses the keywordlist from the capabilities and fills this list in the WMSLayer. |
|
390 |
* @param parser |
|
391 |
*/ |
|
392 |
protected void parseKeywordList(KXmlParser parser) throws IOException, XmlPullParserException |
|
393 |
{ |
|
394 |
int currentTag; |
|
395 |
boolean end = false; |
|
396 |
String value; |
|
397 |
|
|
398 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.KEYWORDLIST); |
|
399 |
currentTag = parser.nextTag(); |
|
400 |
|
|
401 |
while (!end) |
|
402 |
{ |
|
403 |
switch(currentTag) |
|
404 |
{ |
|
405 |
case KXmlParser.START_TAG: |
|
406 |
if (parser.getName().compareTo(CapabilitiesTags.KEYWORD)==0) |
|
407 |
{ |
|
408 |
value = parser.nextText(); |
|
409 |
if ((value != null) && (value.length() > 0 )) |
|
410 |
addkeyword(value); |
|
411 |
} |
|
412 |
break; |
|
413 |
case KXmlParser.END_TAG: |
|
414 |
if (parser.getName().compareTo(CapabilitiesTags.KEYWORDLIST) == 0) |
|
415 |
end = true; |
|
416 |
break; |
|
417 |
case KXmlParser.TEXT: |
|
418 |
break; |
|
419 |
} |
|
420 |
if (!end) |
|
421 |
{ |
|
422 |
currentTag = parser.next(); |
|
423 |
} |
|
424 |
} |
|
425 |
parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.KEYWORDLIST); |
|
426 |
} |
|
427 |
|
|
428 |
/** |
|
429 |
* Reads and parses the layer attributes |
|
430 |
* Maybe this method should be moved to the WMSLayer. Until now the attributes are teh same for all versions. |
|
431 |
* @param parser |
|
432 |
*/ |
|
433 |
protected void readLayerAttributes(KXmlParser parser) |
|
434 |
{ |
|
435 |
String value = new String(); |
|
436 |
|
|
437 |
//First of all set whether the layer is Queryable reading the attribute. |
|
438 |
value = parser.getAttributeValue("", CapabilitiesTags.QUERYABLE); |
|
439 |
if (value != null) |
|
440 |
{ |
|
441 |
if (value.compareTo("0")==0) |
|
442 |
setQueryable(false); |
|
443 |
else |
|
444 |
setQueryable(true); |
|
445 |
} |
|
446 |
value = parser.getAttributeValue("", CapabilitiesTags.OPAQUE); |
|
447 |
if (value != null) |
|
448 |
{ |
|
449 |
if (value.compareTo("0")==0) |
|
450 |
setOpaque(false); |
|
451 |
else |
|
452 |
setOpaque(true); |
|
453 |
} |
|
454 |
value = parser.getAttributeValue("", CapabilitiesTags.NOSUBSETS); |
|
455 |
if (value != null) |
|
456 |
{ |
|
457 |
if (value.compareTo("0")==0) |
|
458 |
setNoSubSets(false); |
|
459 |
else |
|
460 |
setNoSubSets(true); |
|
461 |
} |
|
462 |
value = parser.getAttributeValue("", CapabilitiesTags.FIXEDWIDTH); |
|
463 |
if (value != null) |
|
464 |
{ |
|
465 |
setfixedWidth(Double.parseDouble(value)); |
|
466 |
} |
|
467 |
value = parser.getAttributeValue("", CapabilitiesTags.FIXEDHEIGHT); |
|
468 |
if (value != null) |
|
469 |
{ |
|
470 |
setfixedHeight(Double.parseDouble(value)); |
|
471 |
} |
|
472 |
} |
|
473 |
|
|
474 |
|
|
475 |
/** |
|
380 | 476 |
* <p>Inner class describing the MetadataURL tag in OGC specifications in WMS</p> |
381 | 477 |
* |
382 | 478 |
*/ |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/wms_1_1_1/WMSLayer1_1_1.java | ||
---|---|---|
154 | 154 |
} |
155 | 155 |
else if (parser.getName().compareTo(CapabilitiesTags.KEYWORDLIST)==0) |
156 | 156 |
{ |
157 |
// get all the keywords (childre) and add them.
|
|
157 |
parseKeywordList(parser);
|
|
158 | 158 |
} |
159 | 159 |
break; |
160 | 160 |
case KXmlParser.END_TAG: |
... | ... | |
167 | 167 |
currentTag = parser.next(); |
168 | 168 |
} |
169 | 169 |
} |
170 |
|
|
171 |
/** |
|
172 |
* Reads and parses the layer attributes |
|
173 |
* Maybe this method should be moved to the WMSLayer. Until now the attributes are teh same for all versions. |
|
174 |
* @param parser |
|
175 |
*/ |
|
176 |
private void readLayerAttributes(KXmlParser parser) |
|
177 |
{ |
|
178 |
String value = new String(); |
|
179 |
|
|
180 |
//First of all set whether the layer is Queryable reading the attribute. |
|
181 |
value = parser.getAttributeValue("", CapabilitiesTags.QUERYABLE); |
|
182 |
if (value != null) |
|
183 |
{ |
|
184 |
if (value.compareTo("0")==0) |
|
185 |
setQueryable(false); |
|
186 |
else |
|
187 |
setQueryable(true); |
|
188 |
} |
|
189 |
value = parser.getAttributeValue("", CapabilitiesTags.OPAQUE); |
|
190 |
if (value != null) |
|
191 |
{ |
|
192 |
if (value.compareTo("0")==0) |
|
193 |
setOpaque(false); |
|
194 |
else |
|
195 |
setOpaque(true); |
|
196 |
} |
|
197 |
value = parser.getAttributeValue("", CapabilitiesTags.NOSUBSETS); |
|
198 |
if (value != null) |
|
199 |
{ |
|
200 |
if (value.compareTo("0")==0) |
|
201 |
setNoSubSets(false); |
|
202 |
else |
|
203 |
setNoSubSets(true); |
|
204 |
} |
|
205 |
value = parser.getAttributeValue("", CapabilitiesTags.FIXEDWIDTH); |
|
206 |
if (value != null) |
|
207 |
{ |
|
208 |
setfixedWidth(Double.parseDouble(value)); |
|
209 |
} |
|
210 |
value = parser.getAttributeValue("", CapabilitiesTags.FIXEDHEIGHT); |
|
211 |
if (value != null) |
|
212 |
{ |
|
213 |
setfixedHeight(Double.parseDouble(value)); |
|
214 |
} |
|
215 |
} |
|
216 | 170 |
|
217 | 171 |
public String toString(){ |
218 | 172 |
return super.toString(); |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/wms_1_3_0/WMSLayer1_3_0.java | ||
---|---|---|
153 | 153 |
} |
154 | 154 |
else if (parser.getName().compareTo(CapabilitiesTags.KEYWORDLIST)==0) |
155 | 155 |
{ |
156 |
// get all the keywords (childre) and add them.
|
|
156 |
parseKeywordList(parser);
|
|
157 | 157 |
} |
158 | 158 |
break; |
159 | 159 |
case KXmlParser.END_TAG: |
... | ... | |
166 | 166 |
currentTag = parser.next(); |
167 | 167 |
} |
168 | 168 |
} |
169 |
|
|
169 | 170 |
|
170 | 171 |
/** |
171 | 172 |
* <p>Parses the EX_GeographicBoundingBox </p> |
... | ... | |
225 | 226 |
return bbox; |
226 | 227 |
} |
227 | 228 |
|
228 |
/** |
|
229 |
* Reads and parses the layer attributes |
|
230 |
* @param parser |
|
231 |
*/ |
|
232 |
private void readLayerAttributes(KXmlParser parser) |
|
233 |
{ |
|
234 |
String value = new String(); |
|
235 |
|
|
236 |
//First of all set whether the layer is Queryable reading the attribute. |
|
237 |
value = parser.getAttributeValue("", CapabilitiesTags.QUERYABLE); |
|
238 |
if (value != null) |
|
239 |
{ |
|
240 |
if (value.compareTo("0")==0) |
|
241 |
setQueryable(false); |
|
242 |
else |
|
243 |
setQueryable(true); |
|
244 |
} |
|
245 |
value = parser.getAttributeValue("", CapabilitiesTags.OPAQUE); |
|
246 |
if (value != null) |
|
247 |
{ |
|
248 |
if (value.compareTo("0")==0) |
|
249 |
setOpaque(false); |
|
250 |
else |
|
251 |
setOpaque(true); |
|
252 |
} |
|
253 |
value = parser.getAttributeValue("", CapabilitiesTags.NOSUBSETS); |
|
254 |
if (value != null) |
|
255 |
{ |
|
256 |
if (value.compareTo("0")==0) |
|
257 |
setNoSubSets(false); |
|
258 |
else |
|
259 |
setNoSubSets(true); |
|
260 |
} |
|
261 |
value = parser.getAttributeValue("", CapabilitiesTags.FIXEDWIDTH); |
|
262 |
if (value != null) |
|
263 |
{ |
|
264 |
setfixedWidth(Double.parseDouble(value)); |
|
265 |
} |
|
266 |
value = parser.getAttributeValue("", CapabilitiesTags.FIXEDHEIGHT); |
|
267 |
if (value != null) |
|
268 |
{ |
|
269 |
setfixedHeight(Double.parseDouble(value)); |
|
270 |
} |
|
271 |
} |
|
272 |
|
|
273 | 229 |
public String toString(){ |
274 | 230 |
return super.toString(); |
275 | 231 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/WMSProtocolHandlerFactory.java | ||
---|---|---|
3 | 3 |
|
4 | 4 |
import java.io.InputStream; |
5 | 5 |
import java.io.InputStreamReader; |
6 |
import java.io.StringReader; |
|
6 | 7 |
import java.net.URL; |
7 | 8 |
import java.util.ArrayList; |
8 | 9 |
import java.util.Iterator; |
9 | 10 |
|
11 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
|
12 |
import org.kxml2.io.KXmlParser; |
|
13 |
|
|
10 | 14 |
/** |
11 | 15 |
* <p></p> |
12 | 16 |
* |
... | ... | |
139 | 143 |
{ |
140 | 144 |
String request = WMSProtocolHandler.buildCapabilitiesSuitableVersionRequest(host, _version); |
141 | 145 |
String version = new String(); |
142 |
InputStreamReader reader = null;
|
|
146 |
StringReader reader = null;
|
|
143 | 147 |
InputStream is = null; |
144 | 148 |
try |
145 | 149 |
{ |
... | ... | |
149 | 153 |
is.read(buffer); |
150 | 154 |
|
151 | 155 |
String readed = new String(buffer); |
152 |
int pos = readed.toLowerCase().indexOf("version"); |
|
153 |
if (pos!= -1) |
|
154 |
{ |
|
155 |
version = readed.substring( pos + 7, pos + 13); |
|
156 |
} |
|
157 | 156 |
|
158 |
/* |
|
159 |
reader = new InputStreamReader(is); |
|
157 |
// //NOTE: look for the version string in the stream we read from the WMS. |
|
158 |
// //double quote are included in the string to discriminate from the xml version. version='1.0' |
|
159 |
// int pos = readed.toLowerCase().indexOf("version=\""); |
|
160 |
// if (pos!= -1) |
|
161 |
// { |
|
162 |
// version = readed.substring( pos + 9, pos + 14); |
|
163 |
// } |
|
164 |
// else |
|
165 |
// { |
|
166 |
// System.out.println("ERROR getting version from WMService"); |
|
167 |
// } |
|
168 |
|
|
169 |
reader = new StringReader(readed); |
|
160 | 170 |
KXmlParser kxmlParser = null; |
161 | 171 |
kxmlParser = new KXmlParser(); |
162 | 172 |
|
... | ... | |
171 | 181 |
version = kxmlParser.getAttributeValue("", CapabilitiesTags.VERSION); |
172 | 182 |
} |
173 | 183 |
} |
174 |
|
|
175 | 184 |
// do not forget to close the Stream. |
176 |
reader.close(); |
|
177 |
*/ |
|
185 |
reader.close(); |
|
178 | 186 |
is.close(); |
179 | 187 |
return version; |
180 | 188 |
} catch(Exception e){ |
Also available in: Unified diff