Statistics
| Revision:

root / trunk / libraries / libRemoteServices / src / org / gvsig / remoteClient / wms / WMSLayer.java @ 3523

History | View | Annotate | Download (6.91 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.Hashtable dimensions = new Hashtable();
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
        return (Vector)this.srs.clone();
155
    }
156
    /**
157
     * <p>gets the maximum scale for this layer</p>
158
     * @return 
159
     */
160
    public double getScaleMax() {        
161
        return scaleMax;
162
    } 
163
    
164
    /**
165
     * <p>gets the minimum scale for this layer</p>
166
     * @return 
167
     */
168
    public double getScaleMin() {        
169
        return scaleMin;
170
    } 
171
    
172
    /**
173
     * <p>sets the minimum scale for this layer to be visible.</p>
174
     * 
175
     * @param scale 
176
     */
177
    public void setScaleMin(double scale) {        
178
        scaleMin = scale;
179
    } 
180
    
181
    /**
182
     * <p>sets the maximum scale for this layer to be visible</p>
183
     * @param scale 
184
     */
185
    public void setScaleMax(double scale) {        
186
        scaleMax = scale;
187
    } 
188
    
189
    /**
190
     * <p> gets the dimension vector defined in this layer</p>
191
     * @return 
192
     */
193
    public Hashtable getDimensions() {        
194
        return dimensions;
195
    } 
196
    
197
    /**
198
     * <p>Sets the dimension vector defined for this layer</p>
199
     * @param v 
200
     */
201
    public void setDimensions(Hashtable v) {        
202
        dimensions = (Hashtable)v.clone(); 
203
    } 
204
    
205
    /**
206
     * <p>Adds a dimension to the dimension vector </p>
207
     * @param dimension 
208
     */
209
    public void addDimension(org.gvsig.remoteClient.wms.WMSDimension dimension) {        
210
        dimensions.put(dimension.getName(), dimension);
211
    } 
212
    
213
    /**
214
     * <p>Gets layer name</p>
215
     * @return 
216
     */
217
    public String getName() {        
218
        return this.name;
219
    } 
220
    
221
    /**
222
     * <p>Sets layer name</p>
223
     * @param _name 
224
     */
225
    public void setName(String name) {        
226
        this.name = name;            
227
    } 
228
    
229
    /**
230
     * <p>Gets layer title</p>
231
     * @return 
232
     */
233
    public String getTitle() {        
234
        return title;
235
    } 
236
    
237
    /**
238
     * <p>Sets the layer title</p>
239
     * @param _title 
240
     */
241
    public void setTitle(String title) {        
242
        this.title = title;
243
    } 
244
    
245
    /**
246
     * <p>Gets the layer abstract</p>
247
     * @return 
248
     */
249
    public String getAbstract() {        
250
        return layerAbstract;
251
    } 
252
    
253
    /**
254
     * <p>Sets the layer abstract</p>
255
     * @param m_abstract 
256
     */
257
    public void setAbstract(String _abstract) {        
258
        layerAbstract = _abstract;
259
    }
260
    
261
    
262
    public ArrayList getChildren() {
263
        return children;
264
    }
265
    
266
    
267
    public void setChildren(ArrayList children) {
268
        this.children = children;
269
    }
270
    
271
    
272
    public WMSLayer getParent() {
273
        return parent;
274
    }
275
    
276
    
277
    public void setParent(WMSLayer1_1_1 parent) {
278
        this.parent = parent;
279
    }
280
    
281
    public String toString(){
282
        return this.getTitle();
283
    }
284
  
285

    
286
    /**
287
     * Tells if this layer accepts getFeatureInfo requests.
288
     */
289
    public boolean isQueryable() {
290
        return queryable;
291
    }
292

    
293

    
294
    /**
295
     * @param queryable The queryable to set.
296
     */
297
    public void setQueryable(boolean queryable) {
298
        this.queryable = queryable;
299
    }
300

    
301

    
302
    /**
303
     * @return <b>true</b> if this layer can be served with transparency, otherwise <b>false</b>
304
     */
305
    public boolean hasTransparency() {
306
        return transparency;
307
    }
308
}