Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wmts / wmts_1_0_0 / struct / WMTSLayer_1_0_0.java @ 34305

History | View | Annotate | Download (4.15 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22
package org.gvsig.remoteclient.wmts.wmts_1_0_0.struct;
23

    
24
import java.io.IOException;
25

    
26
import org.gvsig.remoteclient.utils.CapabilitiesTags;
27
import org.gvsig.remoteclient.wmts.WMTSServerDescription;
28
import org.gvsig.remoteclient.wmts.struct.WMTSBoundingBox;
29
import org.gvsig.remoteclient.wmts.struct.WMTSLayer;
30
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrixSetLink;
31
import org.kxml2.io.KXmlParser;
32
import org.xmlpull.v1.XmlPullParserException;
33

    
34
/**
35
 * Describes the attributes of a layer in a WMTS server using the protocol version 1.0.0
36
 *
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 */
39
public class WMTSLayer_1_0_0 extends WMTSLayer {
40
        
41
        public WMTSLayer_1_0_0(WMTSServerDescription status) {
42
                super(status);
43
        }
44
        
45
        /**
46
     * Parses a WMTS layer
47
     * @param parser
48
     * @throws IOException
49
     * @throws XmlPullParserException
50
     */
51
        @SuppressWarnings("unchecked")
52
        public void parse(KXmlParser parser) throws IOException, XmlPullParserException {
53
            int currentTag;
54
            boolean end = false;
55
            
56
            currentTag = parser.next();
57
            
58
            while (!end) {
59
                         switch(currentTag) {
60
                                case KXmlParser.START_TAG:
61
                                        if (compareName(parser, CapabilitiesTags.WMTS_TITLE)) {
62
                                                setTitle(parser.nextText());
63
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_WGS84BOUNDINGBOX)) {
64
                                                getWGS84BBox().parse(parser); 
65
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_IDENTIFIER)) {
66
                                                setIdentifier(parser.nextText()); 
67
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_ABSTRACT)) {
68
                                                setAbstract(parser.nextText()); 
69
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_KEYWORDS)) {
70
                                                setKeywords(parser.nextText()); 
71
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_BOUNDINGBOX)) {
72
                                                getBBox().parse(parser);  
73
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_STYLE)) {
74
                                                WMTSStyle_1_0_0 style = new WMTSStyle_1_0_0();
75
                                                style.parse(parser); 
76
                                                getStyle().add(style);
77
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_FORMAT)) {
78
                                                getFormat().add(parser.nextText());
79
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_INFOFORMAT)) {
80
                                                getInfoFormat().add(parser.nextText()); 
81
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_DIMENSION)) {
82
                                                getDimension().parse(parser);  
83
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_METADATA)) {
84
                                                setMetadata(parser.nextText()); 
85
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_TILEMATRIXSETLINK)) {
86
                                                WMTSTileMatrixSetLink tileMatrixSetLink = new WMTSTileMatrixSetLink_1_0_0();
87
                                                tileMatrixSetLink.parse(parser);
88
                                                getTileMatrixSetLink().add(tileMatrixSetLink); 
89
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_RESOURCEURL)) {
90
                                                getResourceURL().parse(parser); 
91
                                        } 
92
                                        
93
                                        break;
94
                                case KXmlParser.END_TAG:
95
                                        if (compareName(parser, CapabilitiesTags.WMTS_LAYER))
96
                                                end = true;
97
                                        break;
98
                                case KXmlParser.TEXT:                                        
99
                                break;
100
                         }
101
             if (!end)
102
                 currentTag = parser.next();
103
            }
104
            
105
                   status.getLayerList().add(this);
106
    }
107
        
108
        public WMTSBoundingBox getWGS84BBox() {
109
                if(wgs84bbox == null)
110
                        wgs84bbox = new WMTSBoundingBox_1_0_0();
111
                return wgs84bbox;
112
        }
113
        
114
        public WMTSBoundingBox getBBox() {
115
                if(bbox == null)
116
                        bbox = new WMTSBoundingBox_1_0_0();
117
                return bbox;
118
        }
119
}