Statistics
| Revision:

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

History | View | Annotate | Download (6.95 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.kxml2.io.KXmlParser;
11
import org.xmlpull.v1.XmlPullParserException;
12

    
13
/**
14
 * <p>Abstract class that defines an WMSLayer.</p>
15
 * 
16
 */
17
public abstract class WMSLayer implements org.gvsig.remoteClient.ILayer {
18
    
19
    protected ArrayList children;
20
    protected WMSLayer parent;
21
    
22
    /**
23
     * <p>Layer Abstract field in the capabilities document </p> 
24
     */
25
    private String layerAbstract;
26
    
27
    /**
28
     * <p>Themes provided by the WMS for the layer</p> 
29
     */
30
    public ArrayList styles = new ArrayList();
31
    
32
    /**
33
     * <p>Layer name</p>
34
     */
35
    private String name;
36
    
37
    /**
38
     * <p>Layer title</p>
39
     */
40
    private String title;
41
    
42
    /**
43
     * <p>Layer srs.</p>
44
     */
45
    private Vector srs = new Vector();
46
    
47
    /**
48
     * <p>extents for each srs the layer can be reproyected to</p>
49
     */
50
    private Hashtable bBoxes  = new Hashtable();
51
    
52
    /**
53
     * <p>extents that defines the bbox for the LatLon projection
54
     * It can be included in the bBoxes vector as well, because it is the most used, we keep it separeted too, according
55
     *  with the OGC WMSCapabilities specifications...
56
     */    
57
    private org.gvsig.remoteClient.utils.BoundaryBox latLonBbox;
58
    
59
    /**
60
     * <p>min scale for the layer to be visible</p>
61
     */
62
    private double scaleMin;
63
    
64
    /**
65
     * <p>max scale for the layer to be visible</p>
66
     */
67
    private double scaleMax;
68
    
69
    /**
70
     * <p>Dimensions defined for the layer in the capabilities doc</p>
71
     */
72
    private java.util.ArrayList dimensions = new ArrayList();
73
    /**
74
     * Tells if this layer accepts getFeatureInfo requests.
75
     */
76
    private boolean queryable;
77
    /**
78
     * Tells if this layer can be served with transparency.
79
     */
80
    private boolean transparency;
81
    
82
    /**
83
     * <p>Parses the LAYER tag in the WMS capabilities, filling the WMSLayer object
84
     * loading the data in memory to be easily accesed</p>
85
     * 
86
     */
87
    public abstract void parse(KXmlParser parser, TreeMap layerTreeMap)   
88
    throws IOException, XmlPullParserException;    
89
    
90
    
91
    /**
92
     * <p>Adds a style to the styles vector</p>
93
     * @param _style 
94
     */
95
    public void addStyle(org.gvsig.remoteClient.wms.WMSStyle _style) {        
96
        styles.add( _style );    } 
97
    
98
   /**
99
     * <p>Gets the style vector</p> 
100
     * @return 
101
     */
102
    public ArrayList getStyles() {        
103
        return styles;
104
    } 
105
    
106
    /**
107
     * <p>Adds a bbox to the Bboxes vector</p>
108
     * @param bbox
109
     */
110
    public void addBBox(BoundaryBox bbox) {
111
        bBoxes.put(bbox.getSrs(), bbox);
112
    } 
113
    
114
    /**
115
     * <p>returns the bbox with that id in the Bboxes vector</p> 
116
     * @param id 
117
     */
118
    public BoundaryBox getBbox(String id) {
119
        BoundaryBox b = (BoundaryBox) bBoxes.get(id);
120
        if (b == null && parent!=null)
121
            return parent.getBbox(id);
122
        return (BoundaryBox)bBoxes.get(id);
123
    } 
124
    
125
    /**
126
     * <p>Gets the bBoxes vector</p> 
127
     * @return 
128
     */
129
    public Hashtable getBboxes() {
130
        return bBoxes;
131
    } 
132
    
133
    
134
    //Methods to manipulate the box that defines the layer extent in LatLon SRS.
135
    public BoundaryBox getLatLonBox()
136
    {
137
        return latLonBbox;
138
    }
139
    public void setLatLonBox(BoundaryBox box)
140
    {
141
        latLonBbox = box;
142
    }   
143
    /**
144
     * <p>adds a new srs to the srs vector</p>  
145
     */    
146
    public void addSrs(String srs)
147
    {
148
        this.srs.add(srs);
149
    }
150
    
151
    public Vector getAllSrs()
152
    {   
153
        Vector mySRSs = (Vector) this.srs.clone();
154
        if (parent!=null)
155
            mySRSs.addAll(parent.getAllSrs());
156
        return mySRSs;
157
    }
158
    /**
159
     * <p>gets the maximum scale for this layer</p>
160
     * @return 
161
     */
162
    public double getScaleMax() {        
163
        return scaleMax;
164
    } 
165
    
166
    /**
167
     * <p>gets the minimum scale for this layer</p>
168
     * @return 
169
     */
170
    public double getScaleMin() {        
171
        return scaleMin;
172
    } 
173
    
174
    /**
175
     * <p>sets the minimum scale for this layer to be visible.</p>
176
     * 
177
     * @param scale 
178
     */
179
    public void setScaleMin(double scale) {        
180
        scaleMin = scale;
181
    } 
182
    
183
    /**
184
     * <p>sets the maximum scale for this layer to be visible</p>
185
     * @param scale 
186
     */
187
    public void setScaleMax(double scale) {        
188
        scaleMax = scale;
189
    } 
190
    
191
    /**
192
     * <p> gets the dimension vector defined in this layer</p>
193
     * @return 
194
     */
195
    public ArrayList getDimensions() {        
196
        return dimensions;
197
    } 
198
    
199
//    /**
200
//     * <p>Sets the dimension vector defined for this layer</p>
201
//     * @param v 
202
//     */
203
//    public void setDimensions(ArrayList v) {        
204
//        dimensions = (ArrayList)v.clone(); 
205
//    } 
206
    
207
    /**
208
     * <p>Adds a dimension to the dimension vector </p>
209
     * @param dimension 
210
     */
211
    public void addDimension(org.gvsig.remoteClient.wms.WMSDimension dimension) {        
212
        dimensions.add(dimension);
213
    } 
214
    
215
    /**
216
     * <p>Gets layer name</p>
217
     * @return 
218
     */
219
    public String getName() {        
220
        return this.name;
221
    } 
222
    
223
    /**
224
     * <p>Sets layer name</p>
225
     * @param _name 
226
     */
227
    public void setName(String name) {        
228
        this.name = name;            
229
    } 
230
    
231
    /**
232
     * <p>Gets layer title</p>
233
     * @return 
234
     */
235
    public String getTitle() {        
236
        return title;
237
    } 
238
    
239
    /**
240
     * <p>Sets the layer title</p>
241
     * @param _title 
242
     */
243
    public void setTitle(String title) {        
244
        this.title = title;
245
    } 
246
    
247
    /**
248
     * <p>Gets the layer abstract</p>
249
     * @return 
250
     */
251
    public String getAbstract() {        
252
        return layerAbstract;
253
    } 
254
    
255
    /**
256
     * <p>Sets the layer abstract</p>
257
     * @param m_abstract 
258
     */
259
    public void setAbstract(String _abstract) {        
260
        layerAbstract = _abstract;
261
    }
262
    
263
    
264
    public ArrayList getChildren() {
265
        return children;
266
    }
267
    
268
    
269
    public void setChildren(ArrayList children) {
270
        this.children = children;
271
    }
272
    
273
    
274
    public WMSLayer getParent() {
275
        return parent;
276
    }
277
    
278
    
279
    public void setParent(WMSLayer parent) {
280
        this.parent = parent;
281
    }
282
    
283
    public String toString(){
284
        return this.getTitle();
285
    }
286
  
287

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

    
295

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

    
303

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