Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wmts / wmts_1_0_0 / struct / WMTSLayer_1_0_0.java @ 37802

History | View | Annotate | Download (4.44 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
        public void parse(KXmlParser parser) throws IOException, XmlPullParserException {
52
            int currentTag;
53
            boolean end = false;
54
            
55
            currentTag = parser.next();
56
            
57
            while (!end) {
58
                         switch(currentTag) {
59
                                case KXmlParser.START_TAG:
60
                                        if (compareName(parser, CapabilitiesTags.WMTS_TITLE)) {
61
                                                setTitle(nextText(parser));
62
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_WGS84BOUNDINGBOX)) {
63
                                                getWGS84BBox().parse(parser); 
64
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_IDENTIFIER)) {
65
                                                setIdentifier(nextText(parser)); 
66
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_ABSTRACT)) {
67
                                                setAbstract(nextText(parser)); 
68
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_KEYWORDS)) {
69
                                                WMTSKeywords_1_0_0 keywords = new WMTSKeywords_1_0_0();
70
                                                keywords.parse(parser);
71
                                                setKeywords(keywords.getKeywords());
72
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_BOUNDINGBOX)) {
73
                                                getBBox().parse(parser);  
74
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_STYLE)) {
75
                                                WMTSStyle_1_0_0 style = new WMTSStyle_1_0_0();
76
                                                style.parse(parser); 
77
                                                getStyle().add(style);
78
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_FORMAT)) {
79
                                                getFormat().add(nextText(parser));
80
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_INFOFORMAT)) {
81
                                                getInfoFormat().add(nextText(parser)); 
82
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_DIMENSION)) {
83
                                                getDimension().parse(parser);  
84
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_METADATA)) {
85
                                                setMetadata(nextText(parser)); 
86
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_TILEMATRIXSETLINK)) {
87
                                                WMTSTileMatrixSetLink tileMatrixSetLink = new WMTSTileMatrixSetLink_1_0_0();
88
                                                tileMatrixSetLink.setForceLongitudeFirstAxisOrder(forceLongitudeFirstAxisOrder);
89
                                                tileMatrixSetLink.parse(parser);
90
                                                getTileMatrixSetLink().add(tileMatrixSetLink); 
91
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_RESOURCEURL)) {
92
                                                getResourceURL().parse(parser); 
93
                                        } 
94
                                        
95
                                        break;
96
                                case KXmlParser.END_TAG:
97
                                        if (compareName(parser, CapabilitiesTags.WMTS_LAYER))
98
                                                end = true;
99
                                        break;
100
                                case KXmlParser.TEXT:                                        
101
                                break;
102
                         }
103
             if (!end)
104
                 currentTag = parser.next();
105
            }
106
            
107
                   status.getLayerList().add(this);
108
    }
109
        
110
        public WMTSBoundingBox getWGS84BBox() {
111
                if(wgs84bbox == null) {
112
                        wgs84bbox = new WMTSBoundingBox_1_0_0();
113
                        wgs84bbox.setForceLongitudeFirstAxisOrder(forceLongitudeFirstAxisOrder);
114
                }
115
                return wgs84bbox;
116
        }
117
        
118
        public WMTSBoundingBox getBBox() {
119
                if(bbox == null) {
120
                        bbox = new WMTSBoundingBox_1_0_0();
121
                        bbox.setForceLongitudeFirstAxisOrder(forceLongitudeFirstAxisOrder);
122
                }
123
                return bbox;
124
        }
125
}