root / trunk / libraries / libRemoteServices / src / org / gvsig / remoteClient / wms / WMSLayer.java @ 3660
History | View | Annotate | Download (7.01 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 WMSLayer 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 ArrayList styles = new ArrayList(); |
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.ArrayList dimensions = new ArrayList(); |
74 |
/**
|
75 |
* Tells if this layer accepts getFeatureInfo requests.
|
76 |
*/
|
77 |
private boolean queryable; |
78 |
/**
|
79 |
* Tells if this layer can be served with transparency.
|
80 |
*/
|
81 |
private boolean transparency; |
82 |
|
83 |
/**
|
84 |
* <p>Parses the LAYER tag in the WMS capabilities, filling the WMSLayer object
|
85 |
* loading the data in memory to be easily accesed</p>
|
86 |
*
|
87 |
*/
|
88 |
public abstract void parse(KXmlParser parser, TreeMap layerTreeMap) |
89 |
throws IOException, XmlPullParserException; |
90 |
|
91 |
|
92 |
/**
|
93 |
* <p>Adds a style to the styles vector</p>
|
94 |
* @param _style
|
95 |
*/
|
96 |
public void addStyle(org.gvsig.remoteClient.wms.WMSStyle _style) { |
97 |
styles.add( _style ); } |
98 |
|
99 |
/**
|
100 |
* <p>Gets the style vector</p>
|
101 |
* @return
|
102 |
*/
|
103 |
public ArrayList getStyles() { |
104 |
return styles;
|
105 |
} |
106 |
|
107 |
/**
|
108 |
* <p>Adds a bbox to the Bboxes vector</p>
|
109 |
* @param bbox
|
110 |
*/
|
111 |
public void addBBox(BoundaryBox bbox) { |
112 |
bBoxes.put(bbox.getSrs(), bbox); |
113 |
} |
114 |
|
115 |
/**
|
116 |
* <p>returns the bbox with that id in the Bboxes vector</p>
|
117 |
* @param id
|
118 |
*/
|
119 |
public BoundaryBox getBbox(String id) { |
120 |
BoundaryBox b = (BoundaryBox) bBoxes.get(id); |
121 |
if (b == null && parent!=null) |
122 |
return parent.getBbox(id);
|
123 |
return (BoundaryBox)bBoxes.get(id);
|
124 |
} |
125 |
|
126 |
/**
|
127 |
* <p>Gets the bBoxes vector</p>
|
128 |
* @return
|
129 |
*/
|
130 |
public Hashtable getBboxes() { |
131 |
return bBoxes;
|
132 |
} |
133 |
|
134 |
|
135 |
//Methods to manipulate the box that defines the layer extent in LatLon SRS.
|
136 |
public BoundaryBox getLatLonBox()
|
137 |
{ |
138 |
return latLonBbox;
|
139 |
} |
140 |
public void setLatLonBox(BoundaryBox box) |
141 |
{ |
142 |
latLonBbox = box; |
143 |
} |
144 |
/**
|
145 |
* <p>adds a new srs to the srs vector</p>
|
146 |
*/
|
147 |
public void addSrs(String srs) |
148 |
{ |
149 |
this.srs.add(srs);
|
150 |
} |
151 |
|
152 |
public Vector getAllSrs() |
153 |
{ |
154 |
Vector mySRSs = (Vector) this.srs.clone(); |
155 |
if (parent!=null) |
156 |
mySRSs.addAll(parent.getAllSrs()); |
157 |
return mySRSs;
|
158 |
} |
159 |
/**
|
160 |
* <p>gets the maximum scale for this layer</p>
|
161 |
* @return
|
162 |
*/
|
163 |
public double getScaleMax() { |
164 |
return scaleMax;
|
165 |
} |
166 |
|
167 |
/**
|
168 |
* <p>gets the minimum scale for this layer</p>
|
169 |
* @return
|
170 |
*/
|
171 |
public double getScaleMin() { |
172 |
return scaleMin;
|
173 |
} |
174 |
|
175 |
/**
|
176 |
* <p>sets the minimum scale for this layer to be visible.</p>
|
177 |
*
|
178 |
* @param scale
|
179 |
*/
|
180 |
public void setScaleMin(double scale) { |
181 |
scaleMin = scale; |
182 |
} |
183 |
|
184 |
/**
|
185 |
* <p>sets the maximum scale for this layer to be visible</p>
|
186 |
* @param scale
|
187 |
*/
|
188 |
public void setScaleMax(double scale) { |
189 |
scaleMax = scale; |
190 |
} |
191 |
|
192 |
/**
|
193 |
* <p> gets the dimension vector defined in this layer</p>
|
194 |
* @return
|
195 |
*/
|
196 |
public ArrayList getDimensions() { |
197 |
return dimensions;
|
198 |
} |
199 |
|
200 |
// /**
|
201 |
// * <p>Sets the dimension vector defined for this layer</p>
|
202 |
// * @param v
|
203 |
// */
|
204 |
// public void setDimensions(ArrayList v) {
|
205 |
// dimensions = (ArrayList)v.clone();
|
206 |
// }
|
207 |
|
208 |
/**
|
209 |
* <p>Adds a dimension to the dimension vector </p>
|
210 |
* @param dimension
|
211 |
*/
|
212 |
public void addDimension(org.gvsig.remoteClient.wms.WMSDimension dimension) { |
213 |
dimensions.add(dimension); |
214 |
} |
215 |
|
216 |
/**
|
217 |
* <p>Gets layer name</p>
|
218 |
* @return
|
219 |
*/
|
220 |
public String getName() { |
221 |
return this.name; |
222 |
} |
223 |
|
224 |
/**
|
225 |
* <p>Sets layer name</p>
|
226 |
* @param _name
|
227 |
*/
|
228 |
public void setName(String name) { |
229 |
this.name = name;
|
230 |
} |
231 |
|
232 |
/**
|
233 |
* <p>Gets layer title</p>
|
234 |
* @return
|
235 |
*/
|
236 |
public String getTitle() { |
237 |
return title;
|
238 |
} |
239 |
|
240 |
/**
|
241 |
* <p>Sets the layer title</p>
|
242 |
* @param _title
|
243 |
*/
|
244 |
public void setTitle(String title) { |
245 |
this.title = title;
|
246 |
} |
247 |
|
248 |
/**
|
249 |
* <p>Gets the layer abstract</p>
|
250 |
* @return
|
251 |
*/
|
252 |
public String getAbstract() { |
253 |
return layerAbstract;
|
254 |
} |
255 |
|
256 |
/**
|
257 |
* <p>Sets the layer abstract</p>
|
258 |
* @param m_abstract
|
259 |
*/
|
260 |
public void setAbstract(String _abstract) { |
261 |
layerAbstract = _abstract; |
262 |
} |
263 |
|
264 |
|
265 |
public ArrayList getChildren() { |
266 |
return children;
|
267 |
} |
268 |
|
269 |
|
270 |
public void setChildren(ArrayList children) { |
271 |
this.children = children;
|
272 |
} |
273 |
|
274 |
|
275 |
public WMSLayer getParent() {
|
276 |
return parent;
|
277 |
} |
278 |
|
279 |
|
280 |
public void setParent(WMSLayer parent) { |
281 |
this.parent = parent;
|
282 |
} |
283 |
|
284 |
public String toString(){ |
285 |
return this.getTitle(); |
286 |
} |
287 |
|
288 |
|
289 |
/**
|
290 |
* Tells if this layer accepts getFeatureInfo requests.
|
291 |
*/
|
292 |
public boolean isQueryable() { |
293 |
return queryable;
|
294 |
} |
295 |
|
296 |
|
297 |
/**
|
298 |
* @param queryable The queryable to set.
|
299 |
*/
|
300 |
public void setQueryable(boolean queryable) { |
301 |
this.queryable = queryable;
|
302 |
} |
303 |
|
304 |
|
305 |
/**
|
306 |
* @return <b>true</b> if this layer can be served with transparency, otherwise <b>false</b>
|
307 |
*/
|
308 |
public boolean hasTransparency() { |
309 |
return transparency;
|
310 |
} |
311 |
} |