root / trunk / libraries / libRemoteServices / src / org / gvsig / remoteClient / wms / WMSLayer.java @ 3505
History | View | Annotate | Download (7.93 KB)
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.gvsig.remoteClient.utils.BoundaryBox; |
10 |
import org.gvsig.remoteClient.wms.wms_1_1_1.WMSLayer1_1_1; |
11 |
import org.kxml2.io.KXmlParser; |
12 |
import org.xmlpull.v1.XmlPullParserException; |
13 |
|
14 |
/**
|
15 |
* <p>Abstract class that defines an WMSLayer.</p>
|
16 |
*
|
17 |
*/
|
18 |
public abstract class WMSLayer implements org.gvsig.remoteClient.ILayer { |
19 |
|
20 |
protected ArrayList children; |
21 |
protected WMSLayer1_1_1 parent;
|
22 |
|
23 |
/**
|
24 |
* <p>Layer Abstract field in the capabilities document </p>
|
25 |
*/
|
26 |
private String layerAbstract; |
27 |
|
28 |
/**
|
29 |
* <p>Themes provided by the WMS for the layer</p>
|
30 |
*/
|
31 |
public Hashtable styles = new Hashtable(); |
32 |
|
33 |
/**
|
34 |
* <p>Layer name</p>
|
35 |
*/
|
36 |
private String name; |
37 |
|
38 |
/**
|
39 |
* <p>Layer title</p>
|
40 |
*/
|
41 |
private String title; |
42 |
|
43 |
/**
|
44 |
* <p>Layer srs.</p>
|
45 |
*/
|
46 |
private Vector srs = new Vector(); |
47 |
|
48 |
/**
|
49 |
* <p>extents for each srs the layer can be reproyected to</p>
|
50 |
*/
|
51 |
private Hashtable bBoxes = new Hashtable(); |
52 |
|
53 |
/**
|
54 |
* <p>extents that defines the bbox for the LatLon projection
|
55 |
* It can be included in the bBoxes vector as well, because it is the most used, we keep it separeted too, according
|
56 |
* with the OGC WMSCapabilities specifications...
|
57 |
*/
|
58 |
private org.gvsig.remoteClient.utils.BoundaryBox latLonBbox;
|
59 |
|
60 |
/**
|
61 |
* <p>min scale for the layer to be visible</p>
|
62 |
*/
|
63 |
private double scaleMin; |
64 |
|
65 |
/**
|
66 |
* <p>max scale for the layer to be visible</p>
|
67 |
*/
|
68 |
private double scaleMax; |
69 |
|
70 |
/**
|
71 |
* <p>Dimensions defined for the layer in the capabilities doc</p>
|
72 |
*/
|
73 |
private java.util.Hashtable dimensions = new Hashtable(); |
74 |
/**
|
75 |
* <p>NamedStyles defined for this layer in the capabilities document</p>
|
76 |
*/
|
77 |
private ArrayList namedStyles = new ArrayList(); |
78 |
/**
|
79 |
* Tells if this layer accepts getFeatureInfo requests.
|
80 |
*/
|
81 |
private boolean queryable; |
82 |
/**
|
83 |
* Tells if this layer can be served with transparency.
|
84 |
*/
|
85 |
private boolean transparency; |
86 |
|
87 |
/**
|
88 |
* <p>Parses the LAYER tag in the WMS capabilities, filling the WMSLayer object
|
89 |
* loading the data in memory to be easily accesed</p>
|
90 |
*
|
91 |
*/
|
92 |
public abstract void parse(KXmlParser parser, TreeMap layerTreeMap) |
93 |
throws IOException, XmlPullParserException; |
94 |
|
95 |
|
96 |
/**
|
97 |
* <p>Adds a style to the styles vector</p>
|
98 |
* @param _style
|
99 |
*/
|
100 |
public void addStyle(org.gvsig.remoteClient.wms.WMSStyle _style) { |
101 |
styles.put( _style.getName(), _style ); |
102 |
} |
103 |
|
104 |
/**
|
105 |
* <p>returns the style with that name in the styles vector</p>
|
106 |
* @param _name
|
107 |
*/
|
108 |
public WMSStyle getStyle(String _name) { |
109 |
return (WMSStyle)styles.get(_name);
|
110 |
} |
111 |
|
112 |
/**
|
113 |
* <p>Gets the style vector</p>
|
114 |
* @return
|
115 |
*/
|
116 |
public Hashtable getStyles() { |
117 |
return styles;
|
118 |
} |
119 |
|
120 |
/**
|
121 |
* <p>Adds a bbox to the Bboxes vector</p>
|
122 |
* @param bbox
|
123 |
*/
|
124 |
public void addBBox(BoundaryBox bbox) { |
125 |
bBoxes.put(bbox.getSrs(), bbox); |
126 |
} |
127 |
|
128 |
/**
|
129 |
* <p>returns the bbox with that id in the Bboxes vector</p>
|
130 |
* @param id
|
131 |
*/
|
132 |
public BoundaryBox getBbox(String id) { |
133 |
return (BoundaryBox)bBoxes.get(id);
|
134 |
} |
135 |
|
136 |
/**
|
137 |
* <p>Gets the bBoxes vector</p>
|
138 |
* @return
|
139 |
*/
|
140 |
public Hashtable getBboxes() { |
141 |
return bBoxes;
|
142 |
} |
143 |
|
144 |
|
145 |
//Methods to manipulate the box that defines the layer extent in LatLon SRS.
|
146 |
public BoundaryBox getLatLonBox()
|
147 |
{ |
148 |
return latLonBbox;
|
149 |
} |
150 |
public void setLatLonBox(BoundaryBox box) |
151 |
{ |
152 |
latLonBbox = box; |
153 |
} |
154 |
/**
|
155 |
* <p>adds a new srs to the srs vector</p>
|
156 |
*/
|
157 |
public void addSrs(String srs) |
158 |
{ |
159 |
this.srs.add(srs);
|
160 |
} |
161 |
|
162 |
public Vector getAllSrs() |
163 |
{ |
164 |
return (Vector)this.srs.clone(); |
165 |
} |
166 |
/**
|
167 |
* <p>gets the maximum scale for this layer</p>
|
168 |
* @return
|
169 |
*/
|
170 |
public double getScaleMax() { |
171 |
return scaleMax;
|
172 |
} |
173 |
|
174 |
/**
|
175 |
* <p>gets the minimum scale for this layer</p>
|
176 |
* @return
|
177 |
*/
|
178 |
public double getScaleMin() { |
179 |
return scaleMin;
|
180 |
} |
181 |
|
182 |
/**
|
183 |
* <p>sets the minimum scale for this layer to be visible.</p>
|
184 |
*
|
185 |
* @param scale
|
186 |
*/
|
187 |
public void setScaleMin(double scale) { |
188 |
scaleMin = scale; |
189 |
} |
190 |
|
191 |
/**
|
192 |
* <p>sets the maximum scale for this layer to be visible</p>
|
193 |
* @param scale
|
194 |
*/
|
195 |
public void setScaleMax(double scale) { |
196 |
scaleMax = scale; |
197 |
} |
198 |
|
199 |
/**
|
200 |
* <p> gets the dimension vector defined in this layer</p>
|
201 |
* @return
|
202 |
*/
|
203 |
public Hashtable getDimensions() { |
204 |
return dimensions;
|
205 |
} |
206 |
|
207 |
/**
|
208 |
* <p>Sets the dimension vector defined for this layer</p>
|
209 |
* @param v
|
210 |
*/
|
211 |
public void setDimensions(Hashtable v) { |
212 |
dimensions = (Hashtable)v.clone();
|
213 |
} |
214 |
|
215 |
/**
|
216 |
* <p>Adds a dimension to the dimension vector </p>
|
217 |
* @param dimension
|
218 |
*/
|
219 |
public void addDimension(org.gvsig.remoteClient.wms.Dimension dimension) { |
220 |
dimensions.put(dimension.getName(), dimension); |
221 |
} |
222 |
|
223 |
/**
|
224 |
* <p>Gets layer name</p>
|
225 |
* @return
|
226 |
*/
|
227 |
public String getName() { |
228 |
return this.name; |
229 |
} |
230 |
|
231 |
/**
|
232 |
* <p>Sets layer name</p>
|
233 |
* @param _name
|
234 |
*/
|
235 |
public void setName(String name) { |
236 |
this.name = name;
|
237 |
} |
238 |
|
239 |
/**
|
240 |
* <p>Gets layer title</p>
|
241 |
* @return
|
242 |
*/
|
243 |
public String getTitle() { |
244 |
return title;
|
245 |
} |
246 |
|
247 |
/**
|
248 |
* <p>Sets the layer title</p>
|
249 |
* @param _title
|
250 |
*/
|
251 |
public void setTitle(String title) { |
252 |
this.title = title;
|
253 |
} |
254 |
|
255 |
/**
|
256 |
* <p>Gets the layer abstract</p>
|
257 |
* @return
|
258 |
*/
|
259 |
public String getAbstract() { |
260 |
return layerAbstract;
|
261 |
} |
262 |
|
263 |
/**
|
264 |
* <p>Sets the layer abstract</p>
|
265 |
* @param m_abstract
|
266 |
*/
|
267 |
public void setAbstract(String _abstract) { |
268 |
layerAbstract = _abstract; |
269 |
} |
270 |
|
271 |
|
272 |
public ArrayList getChildren() { |
273 |
return children;
|
274 |
} |
275 |
|
276 |
|
277 |
public void setChildren(ArrayList children) { |
278 |
this.children = children;
|
279 |
} |
280 |
|
281 |
|
282 |
public WMSLayer1_1_1 getParent() {
|
283 |
return parent;
|
284 |
} |
285 |
|
286 |
|
287 |
public void setParent(WMSLayer1_1_1 parent) { |
288 |
this.parent = parent;
|
289 |
} |
290 |
|
291 |
public String toString(){ |
292 |
return this.getTitle(); |
293 |
} |
294 |
|
295 |
/**
|
296 |
* Adds a new named style to the named styles list of this layer.
|
297 |
*
|
298 |
* @param namedStyle the new named style to be added.
|
299 |
*/
|
300 |
public void addNamedStyle(String namedStyle) { |
301 |
String[] stylesArray = namedStyle.split(" "); |
302 |
for (int i = 0; i < stylesArray.length; i++){ |
303 |
this.namedStyles.add(stylesArray[i]);
|
304 |
} |
305 |
} |
306 |
|
307 |
/**
|
308 |
* Gets the list of named styles of this layer
|
309 |
*
|
310 |
* @return ArrayList containing those styles
|
311 |
*/
|
312 |
public ArrayList getNamedStyles() { |
313 |
ArrayList ret = new ArrayList(); |
314 |
ret.addAll(namedStyles); |
315 |
|
316 |
if (parent != null) { |
317 |
ret.addAll(parent.getNamedStyles()); |
318 |
} |
319 |
|
320 |
return ret;
|
321 |
} |
322 |
|
323 |
|
324 |
/**
|
325 |
* Tells if this layer accepts getFeatureInfo requests.
|
326 |
*/
|
327 |
public boolean isQueryable() { |
328 |
return queryable;
|
329 |
} |
330 |
|
331 |
|
332 |
/**
|
333 |
* @param queryable The queryable to set.
|
334 |
*/
|
335 |
public void setQueryable(boolean queryable) { |
336 |
this.queryable = queryable;
|
337 |
} |
338 |
|
339 |
|
340 |
/**
|
341 |
* @return <b>true</b> if this layer can be served with transparency, otherwise <b>false</b>
|
342 |
*/
|
343 |
public boolean hasTransparency() { |
344 |
return transparency;
|
345 |
} |
346 |
} |