Revision 38347
tags/v2_0_0_Build_2047/libraries/libRemoteServices/libRemoteServices/src/org/gvsig/remoteclient/ILayer.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.remoteclient; |
|
3 |
/** |
|
4 |
* <p></p> |
|
5 |
* |
|
6 |
*/ |
|
7 |
public interface ILayer { |
|
8 |
/** |
|
9 |
* <p>Does ...</p> |
|
10 |
* |
|
11 |
* |
|
12 |
* @return |
|
13 |
*/ |
|
14 |
public String getName(); |
|
15 |
/** |
|
16 |
* <p>Does ...</p> |
|
17 |
* |
|
18 |
* |
|
19 |
* @param _name |
|
20 |
*/ |
|
21 |
public void setName(String _name); |
|
22 |
/** |
|
23 |
* <p>Does ...</p> |
|
24 |
* |
|
25 |
* |
|
26 |
* @param _title |
|
27 |
*/ |
|
28 |
public void setTitle(String _title); |
|
29 |
/** |
|
30 |
* <p>Does ...</p> |
|
31 |
* |
|
32 |
* |
|
33 |
* @return |
|
34 |
*/ |
|
35 |
public String getTitle(); |
|
36 |
/** |
|
37 |
* <p>Does ...</p> |
|
38 |
* |
|
39 |
* |
|
40 |
* @return |
|
41 |
*/ |
|
42 |
public String getAbstract(); |
|
43 |
/** |
|
44 |
* <p>Does ...</p> |
|
45 |
* |
|
46 |
* |
|
47 |
* @param _abstract |
|
48 |
*/ |
|
49 |
public void setAbstract(String _abstract); |
|
50 |
} |
|
51 |
|
|
52 |
|
|
0 | 53 |
tags/v2_0_0_Build_2047/libraries/libRemoteServices/libRemoteServices/src/org/gvsig/remoteclient/conf/logger.properties | ||
---|---|---|
1 |
# LOGGER PROPERTIES |
|
2 |
|
|
3 |
## limit is ignored if its value is empty or if its value is set to zero. |
|
4 |
## Note: this property only affects info messages. |
|
5 |
#log4j.info.maxsize= |
|
6 |
|
|
7 |
## Set root category priority to DEBUG and its only appender to stdout. |
|
8 |
## on a windows machine: |
|
9 |
#log4j.rootCategory=DEBUG, stdout |
|
10 |
# on the freya: |
|
11 |
log4j.rootCategory=DEBUG, file |
|
12 |
#log4j.rootCategory=FATAL |
|
13 |
|
|
14 |
## stdout is set to be a ConsoleAppender which outputs to System.out. |
|
15 |
log4j.appender.stdout=org.apache.log4j.ConsoleAppender |
|
16 |
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout |
|
17 |
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n |
|
18 |
|
|
19 |
log4j.appender.file=org.apache.log4j.RollingFileAppender |
|
20 |
log4j.appender.file.File=C:\\projects\\gvsig\\RemoteMapClients.log |
|
21 |
log4j.appender.file.MaxBackupIndex=1 |
|
22 |
log4j.appender.file.MaxFileSize=100KB |
|
23 |
log4j.appender.file.layout=org.apache.log4j.PatternLayout |
|
24 |
log4j.appender.file.layout.ConversionPattern=%d [%t] %-5p %c - %m%n |
|
25 |
|
|
26 |
|
|
27 |
## |
|
28 |
## Package Logging |
|
29 |
## |
|
30 |
## Each package can have its own appender |
|
31 |
## |
|
32 |
## Priorities are as follows : |
|
33 |
## |
|
34 |
## 1. FATAL |
|
35 |
## 2. ERROR |
|
36 |
## 3. WARN |
|
37 |
## 4. INFO |
|
38 |
## 5. DEBUG |
|
39 |
## |
|
40 |
## If a package has a priority of DEBUG, this means all |
|
41 |
## messages will be shown in the log. If the priority is |
|
42 |
## INFO, then all messages with a minimum priory of INFO will |
|
43 |
## be shown i.e. INFO, WARN, ERROR and FATAL |
|
44 |
## |
|
45 |
## For minimum log output, set the priority to FATAL |
|
46 |
## |
|
47 |
|
|
48 |
|
|
49 |
#log4j.category.nl.rivm.rrgs.log.NogEenTester=DEBUG, R1 |
|
50 |
|
|
51 |
#log4j.appender.R1=org.apache.log4j.RollingFileAppender |
|
52 |
#log4j.appender.R1.File=d:\\Test1.log |
|
53 |
#log4j.appender.R1.MaxBackupIndex=1 |
|
54 |
#log4j.appender.R1.MaxFileSize=100KB |
|
55 |
#log4j.appender.R1.layout=org.apache.log4j.PatternLayout |
|
56 |
#log4j.appender.R1.layout.ConversionPattern=%d %p %t %c - %m%n |
|
57 |
|
|
58 |
|
|
59 |
#log4j.category.nl.rivm.rrgs.log.Tester=DEBUG, R |
|
60 |
|
|
61 |
#log4j.appender.R=org.apache.log4j.RollingFileAppender |
|
62 |
#log4j.appender.R.File=d:\\Test.log |
|
63 |
#log4j.appender.R.MaxBackupIndex=1 |
|
64 |
#log4j.appender.R.MaxFileSize=100KB |
|
65 |
#log4j.appender.R.layout=org.apache.log4j.PatternLayout |
|
66 |
#log4j.appender.R.layout.ConversionPattern=%d %p %t %c - %m%n |
|
0 | 67 |
tags/v2_0_0_Build_2047/libraries/libRemoteServices/libRemoteServices/src/org/gvsig/remoteclient/wms/WMSLayer.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wms; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Hashtable; |
|
6 |
import java.util.TreeMap; |
|
7 |
import java.util.Vector; |
|
8 |
|
|
9 |
import org.kxml2.io.KXmlParser; |
|
10 |
import org.xmlpull.v1.XmlPullParserException; |
|
11 |
|
|
12 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
|
13 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
14 |
|
|
15 |
/** |
|
16 |
* <p>Abstract class that defines an WMSLayer.</p> |
|
17 |
* |
|
18 |
*/ |
|
19 |
public abstract class WMSLayer implements org.gvsig.remoteclient.ILayer { |
|
20 |
|
|
21 |
protected ArrayList children; |
|
22 |
protected WMSLayer parent; |
|
23 |
|
|
24 |
/** |
|
25 |
* <p>Layer Abstract field in the capabilities document </p> |
|
26 |
*/ |
|
27 |
private String layerAbstract; |
|
28 |
|
|
29 |
/** |
|
30 |
* <p>Themes provided by the WMS for the layer</p> |
|
31 |
*/ |
|
32 |
public ArrayList styles = new ArrayList(); |
|
33 |
|
|
34 |
/** |
|
35 |
* <p>Layer name</p> |
|
36 |
*/ |
|
37 |
private String name; |
|
38 |
|
|
39 |
/** |
|
40 |
* <p>Layer title</p> |
|
41 |
*/ |
|
42 |
private String title; |
|
43 |
|
|
44 |
private ArrayList keywordList = new ArrayList(); |
|
45 |
/** |
|
46 |
* <p>Layer srs.</p> |
|
47 |
*/ |
|
48 |
protected Vector srs = new Vector(); |
|
49 |
|
|
50 |
/** |
|
51 |
* <p>extents for each srs the layer can be reproyected to</p> |
|
52 |
*/ |
|
53 |
private Hashtable bBoxes = new Hashtable(); |
|
54 |
|
|
55 |
/** |
|
56 |
* <p>extents that defines the bbox for the LatLon projection |
|
57 |
* It can be included in the bBoxes vector as well, because it is the most used, we keep it separeted too, according |
|
58 |
* with the OGC WMSCapabilities specifications... |
|
59 |
*/ |
|
60 |
private org.gvsig.remoteclient.utils.BoundaryBox latLonBbox; |
|
61 |
|
|
62 |
/** |
|
63 |
* <p>min scale for the layer to be visible</p> |
|
64 |
*/ |
|
65 |
private double scaleMin; |
|
66 |
|
|
67 |
/** |
|
68 |
* <p>max scale for the layer to be visible</p> |
|
69 |
*/ |
|
70 |
private double scaleMax; |
|
71 |
|
|
72 |
/** |
|
73 |
* <p>Dimensions defined for the layer in the capabilities doc</p> |
|
74 |
*/ |
|
75 |
protected java.util.ArrayList dimensions = new ArrayList(); |
|
76 |
|
|
77 |
/** |
|
78 |
* Tells if this layer accepts getFeatureInfo requests. |
|
79 |
*/ |
|
80 |
private boolean queryable = false; |
|
81 |
|
|
82 |
/** |
|
83 |
* Tells if this layer is opaque. |
|
84 |
*/ |
|
85 |
private boolean opaque = false; |
|
86 |
/** |
|
87 |
* when set to true, noSubsets indicates that the server is not able to make a map |
|
88 |
* of a geographic area other than the layer's bounding box. |
|
89 |
*/ |
|
90 |
private boolean m_noSubSets = false; |
|
91 |
|
|
92 |
/** |
|
93 |
* when present and non-zero fixedWidth and fixedHeight indicate that the server is not |
|
94 |
* able to produce a map of the layer at a width and height different from the fixed sizes indicated. |
|
95 |
*/ |
|
96 |
private int fixedWidth = 0; |
|
97 |
private int fixedHeight = 0; |
|
98 |
|
|
99 |
/** |
|
100 |
* Tells if this layer can be served with transparency. |
|
101 |
*/ |
|
102 |
private boolean transparency; |
|
103 |
|
|
104 |
/** |
|
105 |
* <p>Parses the LAYER tag in the WMS capabilities, filling the WMSLayer object |
|
106 |
* loading the data in memory to be easily accesed</p> |
|
107 |
* |
|
108 |
*/ |
|
109 |
public abstract void parse(KXmlParser parser, TreeMap layerTreeMap) |
|
110 |
throws IOException, XmlPullParserException; |
|
111 |
|
|
112 |
//public abstract ArrayList getAllDimensions(); |
|
113 |
|
|
114 |
/** |
|
115 |
* add a new keyword to the keywordList. |
|
116 |
* @param key |
|
117 |
*/ |
|
118 |
protected void addkeyword(String key) |
|
119 |
{ |
|
120 |
keywordList.add(key); |
|
121 |
} |
|
122 |
public ArrayList getKeywords() |
|
123 |
{ |
|
124 |
return keywordList; |
|
125 |
} |
|
126 |
/** |
|
127 |
* <p>Adds a style to the styles vector</p> |
|
128 |
* @param _style |
|
129 |
*/ |
|
130 |
public void addStyle(org.gvsig.remoteclient.wms.WMSStyle _style) { |
|
131 |
styles.add( _style ); } |
|
132 |
|
|
133 |
/** |
|
134 |
* <p>Gets the style vector</p> |
|
135 |
* @return |
|
136 |
*/ |
|
137 |
public ArrayList getStyles() { |
|
138 |
ArrayList list = new ArrayList(); |
|
139 |
if (styles != null) |
|
140 |
list.addAll(styles); |
|
141 |
if (this.getParent()!= null) |
|
142 |
{ |
|
143 |
//return getAllStyles(this); |
|
144 |
if(this.getParent().getStyles() != null) |
|
145 |
list.addAll(this.getParent().getStyles()); |
|
146 |
} |
|
147 |
return list; |
|
148 |
} |
|
149 |
|
|
150 |
public ArrayList getAllStyles(WMSLayer layer) |
|
151 |
{ |
|
152 |
if (layer.getParent()!= null) |
|
153 |
{ |
|
154 |
ArrayList list = getAllStyles(layer.getParent()); |
|
155 |
for(int i = 0; i < this.styles.size(); i++) |
|
156 |
{ |
|
157 |
list.add(styles.get(i)); |
|
158 |
} |
|
159 |
return list; |
|
160 |
} |
|
161 |
else |
|
162 |
{ |
|
163 |
return styles; |
|
164 |
} |
|
165 |
} |
|
166 |
/** |
|
167 |
* <p>Adds a bbox to the Bboxes vector</p> |
|
168 |
* @param bbox |
|
169 |
*/ |
|
170 |
public void addBBox(BoundaryBox bbox) { |
|
171 |
bBoxes.put(bbox.getSrs(), bbox); |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* <p>returns the bbox with that id in the Bboxes vector</p> |
|
176 |
* @param id |
|
177 |
*/ |
|
178 |
public BoundaryBox getBbox(String id) { |
|
179 |
if ((id.compareToIgnoreCase( CapabilitiesTags.EPSG_4326 )==0) |
|
180 |
||(id.compareToIgnoreCase( CapabilitiesTags.CRS_84)==0)) |
|
181 |
{ |
|
182 |
if (latLonBbox != null) |
|
183 |
return (BoundaryBox)latLonBbox; |
|
184 |
} |
|
185 |
BoundaryBox b = (BoundaryBox) bBoxes.get(id); |
|
186 |
if (b == null && parent!=null) |
|
187 |
return parent.getBbox(id); |
|
188 |
return (BoundaryBox)bBoxes.get(id); |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* <p>Gets the bBoxes vector</p> |
|
193 |
* @return |
|
194 |
*/ |
|
195 |
public Hashtable getBboxes() { |
|
196 |
return bBoxes; |
|
197 |
} |
|
198 |
|
|
199 |
|
|
200 |
//Methods to manipulate the box that defines the layer extent in LatLon SRS. |
|
201 |
public BoundaryBox getLatLonBox() |
|
202 |
{ |
|
203 |
return latLonBbox; |
|
204 |
} |
|
205 |
public void setLatLonBox(BoundaryBox box) |
|
206 |
{ |
|
207 |
latLonBbox = box; |
|
208 |
} |
|
209 |
/** |
|
210 |
* <p>adds a new srs to the srs vector</p> |
|
211 |
*/ |
|
212 |
public void addSrs(String srs) |
|
213 |
{ |
|
214 |
if (!this.srs.contains(srs)) |
|
215 |
this.srs.add(srs); |
|
216 |
} |
|
217 |
|
|
218 |
public Vector getAllSrs() |
|
219 |
{ |
|
220 |
Vector mySRSs = (Vector) this.srs.clone(); |
|
221 |
if (parent!=null) |
|
222 |
mySRSs.addAll(parent.getAllSrs()); |
|
223 |
return mySRSs; |
|
224 |
|
|
225 |
// if (this.getParent()!= null) |
|
226 |
// { |
|
227 |
// Vector list = this.getParent().getAllSrs(); |
|
228 |
// for(int i = 0; i < this.srs.size(); i++) |
|
229 |
// { |
|
230 |
// list.add(srs.get(i)); |
|
231 |
// } |
|
232 |
// return list; |
|
233 |
// } |
|
234 |
// else |
|
235 |
// { |
|
236 |
// return srs; |
|
237 |
// } |
|
238 |
|
|
239 |
} |
|
240 |
/** |
|
241 |
* <p>gets the maximum scale for this layer</p> |
|
242 |
* @return |
|
243 |
*/ |
|
244 |
public double getScaleMax() { |
|
245 |
return scaleMax; |
|
246 |
} |
|
247 |
|
|
248 |
/** |
|
249 |
* <p>gets the minimum scale for this layer</p> |
|
250 |
* @return |
|
251 |
*/ |
|
252 |
public double getScaleMin() { |
|
253 |
return scaleMin; |
|
254 |
} |
|
255 |
|
|
256 |
/** |
|
257 |
* <p>sets the minimum scale for this layer to be visible.</p> |
|
258 |
* |
|
259 |
* @param scale |
|
260 |
*/ |
|
261 |
public void setScaleMin(double scale) { |
|
262 |
scaleMin = scale; |
|
263 |
} |
|
264 |
|
|
265 |
/** |
|
266 |
* <p>sets the maximum scale for this layer to be visible</p> |
|
267 |
* @param scale |
|
268 |
*/ |
|
269 |
public void setScaleMax(double scale) { |
|
270 |
scaleMax = scale; |
|
271 |
} |
|
272 |
|
|
273 |
/** |
|
274 |
* <p> gets the dimension vector defined in this layer</p> |
|
275 |
* @return |
|
276 |
*/ |
|
277 |
public abstract ArrayList getDimensions(); |
|
278 |
// public ArrayList getDimensions() { |
|
279 |
// return dimensions; |
|
280 |
// } |
|
281 |
|
|
282 |
public WMSDimension getDimension(String name) |
|
283 |
{ |
|
284 |
for(int i = 0; i < dimensions.size(); i++ ){ |
|
285 |
if(((WMSDimension)dimensions.get(i)).getName().compareTo(name)==0) |
|
286 |
{ |
|
287 |
return (WMSDimension)dimensions.get(i); |
|
288 |
} |
|
289 |
} |
|
290 |
return null; |
|
291 |
} |
|
292 |
|
|
293 |
// /** |
|
294 |
// * <p>Sets the dimension vector defined for this layer</p> |
|
295 |
// * @param v |
|
296 |
// */ |
|
297 |
// public void setDimensions(ArrayList v) { |
|
298 |
// dimensions = (ArrayList)v.clone(); |
|
299 |
// } |
|
300 |
|
|
301 |
/** |
|
302 |
* <p>Adds a dimension to the dimension vector </p> |
|
303 |
* @param dimension |
|
304 |
*/ |
|
305 |
public void addDimension(org.gvsig.remoteclient.wms.WMSDimension dimension) { |
|
306 |
dimensions.add(dimension); |
|
307 |
} |
|
308 |
|
|
309 |
/** |
|
310 |
* <p>Gets layer name</p> |
|
311 |
* @return |
|
312 |
*/ |
|
313 |
public String getName() { |
|
314 |
return this.name; |
|
315 |
} |
|
316 |
|
|
317 |
/** |
|
318 |
* <p>Sets layer name</p> |
|
319 |
* @param _name |
|
320 |
*/ |
|
321 |
public void setName(String name) { |
|
322 |
this.name = name; |
|
323 |
} |
|
324 |
|
|
325 |
/** |
|
326 |
* <p>Gets layer title</p> |
|
327 |
* @return |
|
328 |
*/ |
|
329 |
public String getTitle() { |
|
330 |
return title; |
|
331 |
} |
|
332 |
|
|
333 |
/** |
|
334 |
* <p>Sets the layer title</p> |
|
335 |
* @param _title |
|
336 |
*/ |
|
337 |
public void setTitle(String title) { |
|
338 |
this.title = title; |
|
339 |
} |
|
340 |
|
|
341 |
/** |
|
342 |
* <p>Gets the layer abstract</p> |
|
343 |
* @return |
|
344 |
*/ |
|
345 |
public String getAbstract() { |
|
346 |
return layerAbstract; |
|
347 |
} |
|
348 |
|
|
349 |
/** |
|
350 |
* <p>Sets the layer abstract</p> |
|
351 |
* @param m_abstract |
|
352 |
*/ |
|
353 |
public void setAbstract(String _abstract) { |
|
354 |
layerAbstract = _abstract; |
|
355 |
} |
|
356 |
|
|
357 |
|
|
358 |
public ArrayList getChildren() { |
|
359 |
return children; |
|
360 |
} |
|
361 |
|
|
362 |
|
|
363 |
public void setChildren(ArrayList children) { |
|
364 |
this.children = children; |
|
365 |
} |
|
366 |
|
|
367 |
|
|
368 |
public WMSLayer getParent() { |
|
369 |
return parent; |
|
370 |
} |
|
371 |
|
|
372 |
|
|
373 |
public void setParent(WMSLayer parent) { |
|
374 |
this.parent = parent; |
|
375 |
} |
|
376 |
|
|
377 |
public String toString(){ |
|
378 |
return this.getTitle(); |
|
379 |
} |
|
380 |
|
|
381 |
|
|
382 |
/** |
|
383 |
* Tells if this layer accepts getFeatureInfo requests. |
|
384 |
*/ |
|
385 |
public boolean isQueryable() { |
|
386 |
return queryable; |
|
387 |
} |
|
388 |
|
|
389 |
|
|
390 |
/** |
|
391 |
* @param queryable The queryable to set. |
|
392 |
*/ |
|
393 |
public void setQueryable(boolean queryable) { |
|
394 |
this.queryable = queryable; |
|
395 |
} |
|
396 |
|
|
397 |
/** |
|
398 |
* Tells if this layer is opaque. |
|
399 |
*/ |
|
400 |
public boolean isOpaque() { |
|
401 |
return opaque; |
|
402 |
} |
|
403 |
/** |
|
404 |
* @param opaque. |
|
405 |
*/ |
|
406 |
public void setOpaque(boolean opaque) { |
|
407 |
this.opaque = opaque; |
|
408 |
} |
|
409 |
|
|
410 |
/** |
|
411 |
* Tells if this layer is subsettable |
|
412 |
*/ |
|
413 |
public boolean noSubSets() { |
|
414 |
return this.m_noSubSets; |
|
415 |
} |
|
416 |
/** |
|
417 |
* @param set layer nosubsets attribute. |
|
418 |
*/ |
|
419 |
public void setNoSubSets(boolean _noSubSets) { |
|
420 |
m_noSubSets = _noSubSets; |
|
421 |
} |
|
422 |
|
|
423 |
public void setfixedWidth(int w) { |
|
424 |
fixedWidth = w; |
|
425 |
} |
|
426 |
|
|
427 |
public int getfixedWidth() { |
|
428 |
return fixedWidth; |
|
429 |
} |
|
430 |
|
|
431 |
public void setfixedHeight(int h) { |
|
432 |
fixedHeight = h; |
|
433 |
} |
|
434 |
|
|
435 |
public int getfixedHeight() { |
|
436 |
return fixedHeight; |
|
437 |
} |
|
438 |
|
|
439 |
/** |
|
440 |
* @return <b>true</b> if this layer can be served with transparency, otherwise <b>false</b> |
|
441 |
*/ |
|
442 |
public boolean hasTransparency() { |
|
443 |
return transparency; |
|
444 |
} |
|
445 |
|
|
446 |
//Methods to parse tags that are common to several versions of WMS. |
|
447 |
//In case there is a version which has different implemantation of one of this tags |
|
448 |
// the subclass can overwrite this method |
|
449 |
|
|
450 |
/** |
|
451 |
* Parses the keywordlist from the capabilities and fills this list in the WMSLayer. |
|
452 |
* @param parser |
|
453 |
*/ |
|
454 |
protected void parseKeywordList(KXmlParser parser) throws IOException, XmlPullParserException |
|
455 |
{ |
|
456 |
int currentTag; |
|
457 |
boolean end = false; |
|
458 |
String value; |
|
459 |
|
|
460 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.KEYWORDLIST); |
|
461 |
currentTag = parser.nextTag(); |
|
462 |
|
|
463 |
while (!end) |
|
464 |
{ |
|
465 |
switch(currentTag) |
|
466 |
{ |
|
467 |
case KXmlParser.START_TAG: |
|
468 |
if (parser.getName().compareTo(CapabilitiesTags.KEYWORD)==0) |
|
469 |
{ |
|
470 |
value = parser.nextText(); |
|
471 |
if ((value != null) && (value.length() > 0 )) |
|
472 |
addkeyword(value); |
|
473 |
} |
|
474 |
break; |
|
475 |
case KXmlParser.END_TAG: |
|
476 |
if (parser.getName().compareTo(CapabilitiesTags.KEYWORDLIST) == 0) |
|
477 |
end = true; |
|
478 |
break; |
|
479 |
case KXmlParser.TEXT: |
|
480 |
break; |
|
481 |
} |
|
482 |
if (!end) |
|
483 |
{ |
|
484 |
currentTag = parser.next(); |
|
485 |
} |
|
486 |
} |
|
487 |
parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.KEYWORDLIST); |
|
488 |
} |
|
489 |
|
|
490 |
/** |
|
491 |
* Reads and parses the layer attributes |
|
492 |
* Maybe this method should be moved to the WMSLayer. Until now the attributes are teh same for all versions. |
|
493 |
* @param parser |
|
494 |
*/ |
|
495 |
protected void readLayerAttributes(KXmlParser parser) |
|
496 |
{ |
|
497 |
String value = new String(); |
|
498 |
|
|
499 |
//First of all set whether the layer is Queryable reading the attribute. |
|
500 |
value = parser.getAttributeValue("", CapabilitiesTags.QUERYABLE); |
|
501 |
if (value != null) |
|
502 |
{ |
|
503 |
if (value.compareTo("0")==0) |
|
504 |
setQueryable(false); |
|
505 |
else |
|
506 |
setQueryable(true); |
|
507 |
} |
|
508 |
value = parser.getAttributeValue("", CapabilitiesTags.OPAQUE); |
|
509 |
if (value != null) |
|
510 |
{ |
|
511 |
if (value.compareTo("0")==0) |
|
512 |
setOpaque(false); |
|
513 |
else |
|
514 |
setOpaque(true); |
|
515 |
} |
|
516 |
value = parser.getAttributeValue("", CapabilitiesTags.NOSUBSETS); |
|
517 |
if (value != null) |
|
518 |
{ |
|
519 |
if (value.compareTo("0")==0) |
|
520 |
setNoSubSets(false); |
|
521 |
else |
|
522 |
setNoSubSets(true); |
|
523 |
} |
|
524 |
value = parser.getAttributeValue("", CapabilitiesTags.FIXEDWIDTH); |
|
525 |
if (value != null) |
|
526 |
{ |
|
527 |
setfixedWidth(Integer.parseInt(value)); |
|
528 |
} |
|
529 |
value = parser.getAttributeValue("", CapabilitiesTags.FIXEDHEIGHT); |
|
530 |
if (value != null) |
|
531 |
{ |
|
532 |
setfixedHeight(Integer.parseInt(value)); |
|
533 |
} |
|
534 |
} |
|
535 |
|
|
536 |
|
|
537 |
/** |
|
538 |
* <p>Inner class describing the MetadataURL tag in OGC specifications in WMS</p> |
|
539 |
* |
|
540 |
*/ |
|
541 |
protected class MetadataURL |
|
542 |
{ |
|
543 |
public MetadataURL() |
|
544 |
{ |
|
545 |
type = new String(); |
|
546 |
format = new String(); |
|
547 |
onlineResource_xlink = new String(); |
|
548 |
onlineResource_type = new String(); |
|
549 |
onlineResource_href = new String(); |
|
550 |
} |
|
551 |
public String type; |
|
552 |
public String format; |
|
553 |
public String onlineResource_xlink; |
|
554 |
public String onlineResource_type; |
|
555 |
public String onlineResource_href; |
|
556 |
} |
|
557 |
|
|
558 |
/** |
|
559 |
* <p>Inner class describing the DataURL tag in OGC specifications in WMS</p> |
|
560 |
* |
|
561 |
*/ |
|
562 |
protected class DataURL |
|
563 |
{ |
|
564 |
public DataURL() |
|
565 |
{ |
|
566 |
type = new String(); |
|
567 |
format = new String(); |
|
568 |
onlineResource_xlink = new String(); |
|
569 |
onlineResource_type = new String(); |
|
570 |
onlineResource_href = new String(); |
|
571 |
} |
|
572 |
public String type; |
|
573 |
public String format; |
|
574 |
public String onlineResource_xlink; |
|
575 |
public String onlineResource_type; |
|
576 |
public String onlineResource_href; |
|
577 |
} |
|
578 |
} |
|
0 | 579 |
tags/v2_0_0_Build_2047/libraries/libRemoteServices/libRemoteServices/src/org/gvsig/remoteclient/wms/WMSClient.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.remoteclient.wms; |
|
3 |
|
|
4 |
import java.awt.geom.Rectangle2D; |
|
5 |
import java.io.File; |
|
6 |
import java.io.IOException; |
|
7 |
import java.net.ConnectException; |
|
8 |
import java.net.URL; |
|
9 |
import java.util.TreeMap; |
|
10 |
import java.util.Vector; |
|
11 |
|
|
12 |
import org.gvsig.compat.net.ICancellable; |
|
13 |
import org.gvsig.remoteclient.exceptions.ServerErrorException; |
|
14 |
import org.gvsig.remoteclient.exceptions.WMSException; |
|
15 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
|
16 |
|
|
17 |
|
|
18 |
/** |
|
19 |
* <p>Represents the class the with the necessary logic to connect to a OGCWMS and interpretate the data </p> |
|
20 |
* |
|
21 |
*/ |
|
22 |
public class WMSClient extends org.gvsig.remoteclient.RasterClient { |
|
23 |
|
|
24 |
private org.gvsig.remoteclient.wms.WMSProtocolHandler handler; |
|
25 |
// private TreeMap layers = new TreeMap(); |
|
26 |
// private WMSLayer rootLayer; |
|
27 |
|
|
28 |
/** |
|
29 |
* @return Returns the rootLayer. |
|
30 |
*/ |
|
31 |
public WMSLayer getRootLayer() { |
|
32 |
return handler.rootLayer; |
|
33 |
} |
|
34 |
|
|
35 |
/** |
|
36 |
* Constructor. |
|
37 |
* the parameter host, indicates the WMS host to connect. |
|
38 |
* */ |
|
39 |
public WMSClient(String host) throws ConnectException, IOException |
|
40 |
{ |
|
41 |
setHost(host); |
|
42 |
try { |
|
43 |
handler = WMSProtocolHandlerFactory.negotiate(host); |
|
44 |
handler.setHost(host); |
|
45 |
} catch(ConnectException conE) { |
|
46 |
conE.printStackTrace(); |
|
47 |
throw conE; |
|
48 |
} catch(IOException ioE) { |
|
49 |
ioE.printStackTrace(); |
|
50 |
throw ioE; |
|
51 |
} catch(Exception e) { |
|
52 |
e.printStackTrace(); |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
56 |
public String getVersion() |
|
57 |
{ |
|
58 |
return handler.getVersion(); |
|
59 |
} |
|
60 |
/** |
|
61 |
* <p>One of the three interfaces that OGC WMS defines. Request a map.</p> |
|
62 |
* @throws ServerErrorException |
|
63 |
*/ |
|
64 |
public File getMap(WMSStatus status, ICancellable cancel) throws WMSException, ServerErrorException{ |
|
65 |
return handler.getMap(status, cancel); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* <p>Gets the GetMap URL. The final client should download the file</p> |
|
70 |
* @throws ServerErrorException |
|
71 |
*/ |
|
72 |
public URL getGetMapURL(WMSStatus status, ICancellable cancel) throws WMSException, ServerErrorException{ |
|
73 |
return handler.getMapURL(status, cancel); |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Returns the exception message if the file is a XML instead of a image. |
|
78 |
* @param file |
|
79 |
* @return |
|
80 |
* @throws IOException |
|
81 |
*/ |
|
82 |
public String getExceptionMessage(File file) throws IOException { |
|
83 |
return handler.getExceptionMessage(file); |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* <p>One of the three interfaces defined by OGC WMS, it gets the service capabilities</p> |
|
88 |
* @param override, if true the previous downloaded data will be overridden |
|
89 |
*/ |
|
90 |
public void getCapabilities(WMSStatus status, boolean override, ICancellable cancel) { |
|
91 |
handler.getCapabilities(status, override, cancel); |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* <p>One of the three interfaces defined by the OGC WMS, it gets the information about a feature requested</p> |
|
96 |
* @return |
|
97 |
*/ |
|
98 |
public String getFeatureInfo(WMSStatus status, int x, int y, int featureCount, ICancellable cancel) throws WMSException{ |
|
99 |
return handler.getFeatureInfo(status, x, y, featureCount, cancel); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* <p>One of the three interfaces defined by the OGC WMS, it gets legend of a layer</p> |
|
104 |
* @return |
|
105 |
*/ |
|
106 |
public File getLegendGraphic(WMSStatus status, String layerName, ICancellable cancel) throws WMSException, ServerErrorException{ |
|
107 |
return handler.getLegendGraphic(status, layerName, cancel); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* <p> Reads from the WMS Capabilities, the layers available in the service</p> |
|
112 |
* @return a TreeMap with the available layers in the WMS |
|
113 |
*/ |
|
114 |
public TreeMap getLayers() { |
|
115 |
return handler.layers; |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* <p>Reads from the WMS Capabilities the number if layers available in the service</p> |
|
120 |
* @return, number of layers available |
|
121 |
*/ |
|
122 |
public int getNumberOfLayers() { |
|
123 |
if (handler.layers != null) |
|
124 |
{ |
|
125 |
return handler.layers.size(); |
|
126 |
} |
|
127 |
return 0; |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* <p>Gets the WMSLayer with this name</p> |
|
132 |
* |
|
133 |
* @param _name, layer name |
|
134 |
* @return the layer with this name |
|
135 |
*/ |
|
136 |
public WMSLayer getLayer(String _name) { |
|
137 |
if (handler.layers.get(_name) != null) |
|
138 |
{ |
|
139 |
return (WMSLayer)handler.layers.get(_name); |
|
140 |
} |
|
141 |
|
|
142 |
return null; |
|
143 |
} |
|
144 |
|
|
145 |
public String[] getLayerNames() |
|
146 |
{ |
|
147 |
WMSLayer[] lyrs; |
|
148 |
|
|
149 |
lyrs = (WMSLayer[])handler.layers.values().toArray(new WMSLayer[0]); |
|
150 |
|
|
151 |
String[] names = new String[lyrs.length]; |
|
152 |
|
|
153 |
for(int i = 0; i<lyrs.length; i++) |
|
154 |
{ |
|
155 |
names[i] = ((WMSLayer)lyrs[i]).getName(); |
|
156 |
} |
|
157 |
return names; |
|
158 |
} |
|
159 |
|
|
160 |
public String[] getLayerTitles() |
|
161 |
{ |
|
162 |
WMSLayer[] lyrs; |
|
163 |
|
|
164 |
lyrs = (WMSLayer[])handler.layers.values().toArray(new WMSLayer[0]); |
|
165 |
|
|
166 |
String[] titles = new String[lyrs.length]; |
|
167 |
|
|
168 |
for(int i = 0; i<lyrs.length; i++) |
|
169 |
{ |
|
170 |
titles[i] = ((WMSLayer)lyrs[i]).getTitle(); |
|
171 |
} |
|
172 |
return titles; |
|
173 |
} |
|
174 |
/** |
|
175 |
* <p>Gets the image formats available in the Service to retrieve the maps</p> |
|
176 |
* @return a vector with all the available formats |
|
177 |
*/ |
|
178 |
public Vector getFormats() { |
|
179 |
return ((WMSServiceInformation)handler.getServiceInformation()).formats; |
|
180 |
} |
|
181 |
|
|
182 |
public boolean isQueryable() |
|
183 |
{ |
|
184 |
return ((WMSServiceInformation)handler.getServiceInformation()).isQueryable(); |
|
185 |
} |
|
186 |
public boolean hasLegendGraphic() |
|
187 |
{ |
|
188 |
return ((WMSServiceInformation)handler.getServiceInformation()).hasLegendGraphic(); |
|
189 |
} |
|
190 |
|
|
191 |
public void close() { |
|
192 |
// your code here |
|
193 |
} |
|
194 |
|
|
195 |
|
|
196 |
/** |
|
197 |
* Returns the max extent that envolves the requested layers |
|
198 |
* */ |
|
199 |
public Rectangle2D getLayersExtent(String[]layerNames, String srs) |
|
200 |
{ |
|
201 |
try |
|
202 |
{ |
|
203 |
if (layerNames == null) return null; |
|
204 |
BoundaryBox bbox; |
|
205 |
WMSLayer layer = getLayer(layerNames[0]); |
|
206 |
|
|
207 |
bbox = layer.getBbox(srs); |
|
208 |
if (bbox == null) return null; |
|
209 |
double xmin = bbox.getXmin(); |
|
210 |
double xmax = bbox.getXmax(); |
|
211 |
double ymin = bbox.getYmin(); |
|
212 |
double ymax = bbox.getYmax(); |
|
213 |
|
|
214 |
for(int i=1; i<layerNames.length; i++) |
|
215 |
{ |
|
216 |
layer = getLayer(layerNames[i]); |
|
217 |
bbox = layer.getBbox(srs); |
|
218 |
if (bbox == null) return null; |
|
219 |
if (bbox.getXmin() < xmin) |
|
220 |
{ |
|
221 |
xmin = bbox.getXmin(); |
|
222 |
} |
|
223 |
if (bbox.getYmin() < ymin) |
|
224 |
{ |
|
225 |
ymin = bbox.getYmin(); |
|
226 |
} |
|
227 |
if (bbox.getXmax() > xmax) |
|
228 |
{ |
|
229 |
xmax = bbox.getXmax(); |
|
230 |
} |
|
231 |
if (bbox.getYmax() > ymax) |
|
232 |
{ |
|
233 |
ymax = bbox.getYmax(); |
|
234 |
} |
|
235 |
} |
|
236 |
|
|
237 |
Rectangle2D extent = new Rectangle2D.Double(xmin,ymin,Math.abs(xmax-xmin),Math.abs(ymax-ymin)); |
|
238 |
return extent; |
|
239 |
} |
|
240 |
catch(Exception e) |
|
241 |
{ |
|
242 |
e.printStackTrace(); |
|
243 |
return null; |
|
244 |
} |
|
245 |
} |
|
246 |
|
|
247 |
|
|
248 |
/** |
|
249 |
* Gets the Service information included in the Capabilities |
|
250 |
* */ |
|
251 |
public WMSServiceInformation getServiceInformation() |
|
252 |
{ |
|
253 |
return ((WMSServiceInformation)handler.getServiceInformation()); |
|
254 |
} |
|
255 |
|
|
256 |
|
|
257 |
/** |
|
258 |
* <p>Checks the connection to de remote WMS and requests its capabilities.</p> |
|
259 |
* @param override, if true the previous downloaded data will be overridden |
|
260 |
*/ |
|
261 |
public boolean connect(boolean override, ICancellable cancel) |
|
262 |
{ |
|
263 |
try { |
|
264 |
if (handler == null) |
|
265 |
{ |
|
266 |
if (getHost().trim().length() > 0) |
|
267 |
{ |
|
268 |
//TODO: Implement correctly the negotiate algorithm |
|
269 |
handler = WMSProtocolHandlerFactory.negotiate(getHost()); |
|
270 |
//handler = new WMSProtocolHandler1_1_1(); |
|
271 |
handler.setHost(getHost()); |
|
272 |
} |
|
273 |
else |
|
274 |
{ |
|
275 |
//must to specify host first!!!! |
|
276 |
return false; |
|
277 |
} |
|
278 |
} |
|
279 |
getCapabilities(null, override, cancel); |
|
280 |
return true; |
|
281 |
|
|
282 |
} catch (Exception e) { |
|
283 |
e.printStackTrace(); |
|
284 |
return false; |
|
285 |
} |
|
286 |
} |
|
287 |
|
|
288 |
//TODO Check this out: Always 1 layer at first level... |
|
289 |
public WMSLayer getLayersRoot() { |
|
290 |
return handler.rootLayer; |
|
291 |
} |
|
292 |
|
|
293 |
public boolean connect(ICancellable cancel) { |
|
294 |
return connect(false, cancel); |
|
295 |
} |
|
296 |
} |
|
0 | 297 |
tags/v2_0_0_Build_2047/libraries/libRemoteServices/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/WMSLayer1_1_0.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.remoteclient.wms.wms_1_1_0; |
|
3 |
|
|
4 |
import java.io.IOException; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.TreeMap; |
|
7 |
|
|
8 |
import org.kxml2.io.KXmlParser; |
|
9 |
import org.xmlpull.v1.XmlPullParserException; |
|
10 |
|
|
11 |
import org.gvsig.compat.CompatLocator; |
|
12 |
import org.gvsig.compat.lang.StringUtils; |
|
13 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
|
14 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
15 |
import org.gvsig.remoteclient.utils.Utilities; |
|
16 |
import org.gvsig.remoteclient.wms.WMSDimension; |
|
17 |
import org.gvsig.remoteclient.wms.WMSExtent; |
|
18 |
|
|
19 |
|
|
20 |
/** |
|
21 |
* <p>WMS Layer for WMS 1.1.0</p> |
|
22 |
* |
|
23 |
*/ |
|
24 |
public class WMSLayer1_1_0 extends org.gvsig.remoteclient.wms.WMSLayer { |
|
25 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
26 |
|
|
27 |
/** |
|
28 |
* <p>Extents defined for the layer in the capabilities doc</p> |
|
29 |
*/ |
|
30 |
private java.util.ArrayList extents = new ArrayList(); |
|
31 |
|
|
32 |
/** |
|
33 |
* <p> gets the extent vector defined in this layer</p> |
|
34 |
* @return |
|
35 |
*/ |
|
36 |
public ArrayList getExtents() { |
|
37 |
return extents; |
|
38 |
} |
|
39 |
|
|
40 |
public WMSExtent getExtent(String name) |
|
41 |
{ |
|
42 |
for(int i = 0; i < extents.size(); i++ ){ |
|
43 |
if(((WMSExtent)extents.get(i)).getName().compareTo(name)==0) |
|
44 |
{ |
|
45 |
return (WMSExtent)extents.get(i); |
|
46 |
} |
|
47 |
} |
|
48 |
return null; |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* <p>Adds an extent to the extent vector </p> |
|
53 |
* @param extent |
|
54 |
*/ |
|
55 |
public void addExtent(org.gvsig.remoteclient.wms.WMSExtent extent) { |
|
56 |
extents.add(extent); |
|
57 |
} |
|
58 |
|
|
59 |
public ArrayList getDimensions() |
|
60 |
{ |
|
61 |
WMSDimension dimension; |
|
62 |
WMSExtent extent; |
|
63 |
for(int i = 0; i < dimensions.size(); i++) |
|
64 |
{ |
|
65 |
dimension = (WMSDimension)dimensions.get(i); |
|
66 |
extent = getExtent(dimension.getName()); |
|
67 |
if(extent != null) |
|
68 |
{ |
|
69 |
((WMSDimension)dimensions.get(i)).setDimensionExpression( extent.getExtentExpression()); |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
WMSDimension pDimension; |
|
74 |
WMSDimension myDimension; |
|
75 |
ArrayList myDimensions = (ArrayList) this.dimensions.clone(); |
|
76 |
ArrayList pDimensions; |
|
77 |
if (parent!=null) |
|
78 |
{ |
|
79 |
pDimensions = parent.getDimensions(); |
|
80 |
for (int i= 0; i < pDimensions.size(); i++){ |
|
81 |
pDimension = (WMSDimension)pDimensions.get(i); |
|
82 |
myDimension = getDimension(pDimension.getName()); |
|
83 |
if (myDimension != null){ |
|
84 |
pDimensions.remove(pDimension); |
|
85 |
} |
|
86 |
} |
|
87 |
myDimensions.addAll(pDimensions); |
|
88 |
} |
|
89 |
return myDimensions; |
|
90 |
} |
|
91 |
|
|
92 |
public WMSLayer1_1_0() |
|
93 |
{ |
|
94 |
children = new ArrayList(); |
|
95 |
} |
|
96 |
/** |
|
97 |
* <p>Parses the contents of the parser(WMSCapabilities) |
|
98 |
* to extract the information about an WMSLayer</p> |
|
99 |
* |
|
100 |
*/ |
|
101 |
public void parse(KXmlParser parser, TreeMap layerTreeMap) |
|
102 |
throws IOException, XmlPullParserException |
|
103 |
{ |
|
104 |
int currentTag; |
|
105 |
boolean end = false; |
|
106 |
String value; |
|
107 |
BoundaryBox bbox; |
|
108 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.LAYER); |
|
109 |
|
|
110 |
//First of all set whether the layer is Queryable reading the attribute. |
|
111 |
value = parser.getAttributeValue("", CapabilitiesTags.QUERYABLE); |
|
112 |
if (value != null) |
|
113 |
{ |
|
114 |
if (value.compareTo("0")==0) |
|
115 |
setQueryable(false); |
|
116 |
else |
|
117 |
setQueryable(true); |
|
118 |
} |
|
119 |
|
|
120 |
currentTag = parser.nextTag(); |
|
121 |
|
|
122 |
while (!end) |
|
123 |
{ |
|
124 |
switch(currentTag) |
|
125 |
{ |
|
126 |
case KXmlParser.START_TAG: |
|
127 |
if (parser.getName().compareTo(CapabilitiesTags.LAYER)==0) |
|
128 |
{ |
|
129 |
WMSLayer1_1_0 lyr = new WMSLayer1_1_0(); |
|
130 |
//parser.next(); |
|
131 |
lyr.parse(parser, layerTreeMap); |
|
132 |
lyr.setParent(this); |
|
133 |
this.children.add(lyr); |
|
134 |
// Jaume |
|
135 |
if (lyr.getName()!=null) |
|
136 |
layerTreeMap.put(lyr.getName(), lyr); |
|
137 |
} |
|
138 |
else if (parser.getName().compareTo(CapabilitiesTags.ATTRIBUTION)==0){ |
|
139 |
// TODO comprobar que esto se necesite o se deseche |
|
140 |
parser.skipSubTree(); |
|
141 |
} |
|
142 |
else if (parser.getName().compareTo(CapabilitiesTags.NAME)==0) |
|
143 |
{ |
|
144 |
value = parser.nextText(); |
|
145 |
if (value != null) setName(value); |
|
146 |
} |
|
147 |
else if (parser.getName().compareTo(CapabilitiesTags.TITLE)==0) |
|
148 |
{ |
|
149 |
value = parser.nextText(); |
|
150 |
if (value != null) setTitle(value); |
|
151 |
} |
|
152 |
else if (parser.getName().compareTo(CapabilitiesTags.ABSTRACT)==0) |
|
153 |
{ |
|
154 |
value = parser.nextText(); |
|
155 |
if (value != null) setAbstract(value); |
|
156 |
} |
|
157 |
else if (parser.getName().compareTo(CapabilitiesTags.SRS)==0) |
|
158 |
{ |
|
159 |
value = parser.nextText(); |
|
160 |
if (value != null){ |
|
161 |
String[] mySRSs = stringUtils.split(value, " "); |
|
162 |
for (int i = 0; i < mySRSs.length; i++) { |
|
163 |
addSrs(mySRSs[i]); |
|
164 |
} |
|
165 |
|
|
166 |
} |
|
167 |
} |
|
168 |
else if (parser.getName().compareTo(CapabilitiesTags.BOUNDINGBOX)==0) |
|
169 |
{ |
|
170 |
bbox = new BoundaryBox(); |
|
171 |
value = parser.getAttributeValue("",CapabilitiesTags.SRS); |
|
172 |
if (value != null) |
|
173 |
bbox.setSrs(value); |
|
174 |
value = parser.getAttributeValue("",CapabilitiesTags.MINX); |
|
175 |
if ((value != null) && (Utilities.isNumber(value))) |
|
176 |
bbox.setXmin(Double.parseDouble(value)); |
|
177 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY); |
|
178 |
if ((value != null) && (Utilities.isNumber(value))) |
|
179 |
bbox.setYmin(Double.parseDouble(value)); |
|
180 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX); |
|
181 |
if ((value != null) && (Utilities.isNumber(value))) |
|
182 |
bbox.setXmax(Double.parseDouble(value)); |
|
183 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY); |
|
184 |
if ((value != null) && (Utilities.isNumber(value))) |
|
185 |
bbox.setYmax(Double.parseDouble(value)); |
|
186 |
addBBox(bbox); |
|
187 |
addSrs(bbox.getSrs()); |
|
188 |
} |
|
189 |
else if (parser.getName().compareTo(CapabilitiesTags.LATLONBOUNDINGBOX)==0) |
|
190 |
{ |
|
191 |
bbox = new BoundaryBox(); |
|
192 |
bbox.setSrs(CapabilitiesTags.EPSG_4326); |
|
193 |
value = parser.getAttributeValue("",CapabilitiesTags.MINX); |
|
194 |
if ((value != null) && (Utilities.isNumber(value))) |
|
195 |
bbox.setXmin(Double.parseDouble(value)); |
|
196 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY); |
|
197 |
if ((value != null) && (Utilities.isNumber(value))) |
|
198 |
bbox.setYmin(Double.parseDouble(value)); |
|
199 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX); |
|
200 |
if ((value != null) && (Utilities.isNumber(value))) |
|
201 |
bbox.setXmax(Double.parseDouble(value)); |
|
202 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY); |
|
203 |
if ((value != null) && (Utilities.isNumber(value))) |
|
204 |
bbox.setYmax(Double.parseDouble(value)); |
|
205 |
addBBox(bbox); |
|
206 |
setLatLonBox(bbox); |
|
207 |
addSrs(bbox.getSrs()); |
|
208 |
} |
|
209 |
else if (parser.getName().compareTo(CapabilitiesTags.SCALEHINT)==0) |
|
210 |
{ |
|
211 |
value = parser.getAttributeValue("",CapabilitiesTags.MIN); |
|
212 |
if ((value != null) && (Utilities.isNumber(value))) |
|
213 |
setScaleMin(Double.parseDouble(value)); |
|
214 |
value = parser.getAttributeValue("",CapabilitiesTags.MAX); |
|
215 |
if ((value != null) && (Utilities.isNumber(value))) |
|
216 |
setScaleMax(Double.parseDouble(value)); |
|
217 |
} |
|
218 |
else if (parser.getName().compareTo(CapabilitiesTags.STYLE)==0) |
|
219 |
{ |
|
220 |
WMSStyle1_1_0 style = new WMSStyle1_1_0(); |
|
221 |
style.parse(parser); |
|
222 |
if ((style != null) && (style.getName() != null)) |
|
223 |
{ |
|
224 |
styles.add(style); |
|
225 |
} |
|
226 |
} |
|
227 |
else if (parser.getName().compareTo(CapabilitiesTags.DIMENSION)==0) |
|
228 |
{ |
|
229 |
WMSDimension dim = new WMSDimension(); |
|
230 |
dim.parse(parser); |
|
231 |
if ((dim != null) && (dim.getName() != null)) |
|
232 |
{ |
|
233 |
addDimension(dim); |
|
234 |
} |
|
235 |
} |
|
236 |
else if (parser.getName().compareTo(CapabilitiesTags.EXTENT)==0) |
|
237 |
{ |
|
238 |
WMSExtent extent = new WMSExtent(); |
|
239 |
extent.parse(parser); |
|
240 |
if ((extent != null) && (extent.getName() != null)) |
|
241 |
{ |
|
242 |
addExtent(extent); |
|
243 |
|
|
244 |
} |
|
245 |
} |
|
246 |
break; |
|
247 |
case KXmlParser.END_TAG: |
|
248 |
if (parser.getName().compareTo(CapabilitiesTags.LAYER) == 0) |
|
249 |
end = true; |
|
250 |
break; |
|
251 |
case KXmlParser.TEXT: |
|
252 |
break; |
|
253 |
} |
|
254 |
if (!end) |
|
255 |
currentTag = parser.next(); |
|
256 |
} |
|
257 |
parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.LAYER); |
|
258 |
} |
|
259 |
|
|
260 |
public String toString(){ |
|
261 |
return super.toString(); |
|
262 |
} |
|
263 |
} |
|
0 | 264 |
tags/v2_0_0_Build_2047/libraries/libRemoteServices/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/WMSProtocolHandler1_1_0.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.remoteclient.wms.wms_1_1_0; |
|
3 |
|
|
4 |
import java.io.ByteArrayInputStream; |
|
5 |
import java.io.File; |
|
6 |
import java.io.IOException; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.TreeMap; |
|
9 |
|
|
10 |
import org.kxml2.io.KXmlParser; |
|
11 |
import org.xmlpull.v1.XmlPullParserException; |
|
12 |
|
|
13 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
14 |
import org.gvsig.remoteclient.utils.EncodingXMLParser; |
|
15 |
import org.gvsig.remoteclient.utils.ExceptionTags; |
|
16 |
import org.gvsig.remoteclient.wms.WMSServiceInformation; |
|
17 |
import org.gvsig.remoteclient.wms.WMSStatus; |
|
18 |
import org.gvsig.remoteclient.wms.request.WMSGetCapabilitiesRequest; |
|
19 |
import org.gvsig.remoteclient.wms.request.WMSGetFeatureInfoRequest; |
|
20 |
import org.gvsig.remoteclient.wms.request.WMSGetLegendGraphicRequest; |
|
21 |
import org.gvsig.remoteclient.wms.request.WMSGetMapRequest; |
|
22 |
import org.gvsig.remoteclient.wms.wms_1_1_0.request.WMSGetCapabilitiesRequest1_1_0; |
|
23 |
import org.gvsig.remoteclient.wms.wms_1_1_0.request.WMSGetFeatureInfoRequest1_1_0; |
|
24 |
import org.gvsig.remoteclient.wms.wms_1_1_0.request.WMSGetLegendGraphicRequest1_1_0; |
|
25 |
import org.gvsig.remoteclient.wms.wms_1_1_0.request.WMSGetMapRequest1_1_0; |
|
26 |
|
|
27 |
/** |
|
28 |
* <p> |
|
29 |
* Describes the handler to comunicate to a WMS 1.1.0 |
|
30 |
* </p> |
|
31 |
*/ |
|
32 |
public class WMSProtocolHandler1_1_0 extends org.gvsig.remoteclient.wms.WMSProtocolHandler |
|
33 |
{ |
|
34 |
private WMSLayer1_1_0 fakeRootLayer; |
|
35 |
|
|
36 |
public WMSProtocolHandler1_1_0() |
|
37 |
{ |
|
38 |
this.version = "1.1.0"; |
|
39 |
this.name = "WMS1.1.0"; |
|
40 |
this.serviceInfo = new WMSServiceInformation(); |
|
41 |
this.layers = new TreeMap(); |
|
42 |
} |
|
43 |
|
|
44 |
//------------------------------------------------------------------------------ |
|
45 |
// Parsing methods.... |
|
46 |
//------------------------------------------------------------------------------ |
|
47 |
|
|
48 |
|
|
49 |
public boolean parseCapabilities(File f) |
|
50 |
{ |
|
51 |
rootLayer = null; |
|
52 |
int tag; |
|
53 |
EncodingXMLParser kxmlParser = null; |
|
54 |
kxmlParser = new EncodingXMLParser(); |
|
55 |
try |
|
56 |
{ |
|
57 |
kxmlParser.setInput(f); |
|
58 |
kxmlParser.nextTag(); |
|
59 |
if ( kxmlParser.getEventType() != KXmlParser.END_DOCUMENT ) |
|
60 |
{ |
|
61 |
kxmlParser.require(KXmlParser.START_TAG, null, CapabilitiesTags.CAPABILITIES_ROOT1_1_1); |
|
62 |
tag = kxmlParser.nextTag(); |
|
63 |
while(tag != KXmlParser.END_DOCUMENT) |
|
64 |
{ |
|
65 |
switch(tag) |
|
66 |
{ |
|
67 |
|
|
68 |
case KXmlParser.START_TAG: |
|
69 |
if (kxmlParser.getName().compareTo(CapabilitiesTags.SERVICE )==0) |
|
70 |
{ |
|
71 |
parseServiceTag(kxmlParser); |
|
72 |
} |
|
73 |
else if (kxmlParser.getName().compareTo(CapabilitiesTags.CAPABILITY)==0) |
|
74 |
{ |
|
75 |
parseCapabilityTag(kxmlParser); |
|
76 |
} |
|
77 |
break; |
|
78 |
case KXmlParser.END_TAG: |
|
79 |
break; |
|
80 |
case KXmlParser.TEXT: |
|
81 |
|
|
82 |
break; |
|
83 |
} |
|
84 |
tag = kxmlParser.next(); |
|
85 |
} |
|
86 |
|
|
87 |
kxmlParser.require(KXmlParser.END_DOCUMENT, null, null); |
|
88 |
} |
|
89 |
} |
|
90 |
catch(XmlPullParserException parser_ex){ |
|
91 |
parser_ex.printStackTrace(); |
|
92 |
return false; |
|
93 |
} |
|
94 |
catch (IOException ioe) { |
|
95 |
ioe.printStackTrace(); |
|
96 |
return false; |
|
97 |
} finally { |
|
98 |
return true; |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* <p>Parses the Service Information </p> |
|
104 |
*/ |
|
105 |
private void parseServiceTag(KXmlParser parser) throws IOException, XmlPullParserException |
|
106 |
{ |
|
107 |
int currentTag; |
|
108 |
boolean end = false; |
|
109 |
|
|
110 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.SERVICE); |
|
111 |
currentTag = parser.next(); |
|
112 |
|
|
113 |
while (!end) |
|
114 |
{ |
|
115 |
switch(currentTag) |
|
116 |
{ |
|
117 |
case KXmlParser.START_TAG: |
|
118 |
if (parser.getName().compareTo(CapabilitiesTags.NAME)==0) |
|
119 |
{ |
|
120 |
serviceInfo.name = parser.nextText(); |
|
121 |
} |
|
122 |
else if (parser.getName().compareTo(CapabilitiesTags.TITLE)==0) |
|
123 |
{ |
|
124 |
serviceInfo.title = parser.nextText(); |
|
125 |
} |
|
126 |
else if (parser.getName().compareTo(CapabilitiesTags.ABSTRACT)==0) |
|
127 |
{ |
|
128 |
serviceInfo.abstr = parser.nextText(); |
|
129 |
} |
|
130 |
else if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0) |
|
131 |
{ |
|
132 |
String value = null; |
|
133 |
value = parser.getAttributeValue("", CapabilitiesTags.XLINK_HREF); |
|
134 |
if (value != null){ |
|
135 |
serviceInfo.online_resource = value; |
|
136 |
} |
|
137 |
} |
|
138 |
else if ((parser.getName().compareTo(CapabilitiesTags.KEYWORDLIST)==0) || |
|
139 |
(parser.getName().compareTo(CapabilitiesTags.CONTACTINFORMATION)==0)) |
|
140 |
{ |
|
141 |
parser.skipSubTree(); |
|
142 |
} |
|
143 |
break; |
|
144 |
case KXmlParser.END_TAG: |
|
145 |
if (parser.getName().compareTo(CapabilitiesTags.SERVICE) == 0) |
|
146 |
end = true; |
|
147 |
break; |
|
148 |
case KXmlParser.TEXT: |
|
149 |
break; |
|
150 |
} |
|
151 |
if (!end) |
|
152 |
currentTag = parser.next(); |
|
153 |
} |
|
154 |
parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.SERVICE); |
|
155 |
} |
|
156 |
|
|
157 |
/** |
|
158 |
* <p>Parses the Capability Tag </p> |
|
159 |
*/ |
|
160 |
private void parseCapabilityTag(KXmlParser parser) throws IOException, XmlPullParserException |
|
161 |
{ |
|
162 |
int currentTag; |
|
163 |
boolean end = false; |
|
164 |
|
|
165 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.CAPABILITY); |
|
166 |
currentTag = parser.next(); |
|
167 |
|
|
168 |
while (!end) |
|
169 |
{ |
|
170 |
switch(currentTag) |
|
171 |
{ |
|
172 |
case KXmlParser.START_TAG: |
|
173 |
if (parser.getName().compareTo(CapabilitiesTags.REQUEST)==0) |
|
174 |
{ |
|
175 |
parseRequestTag(parser); |
Also available in: Unified diff