Statistics
| Revision:

gvsig-raster / org.gvsig.raster.wmts / trunk / org.gvsig.raster.wmts / org.gvsig.raster.wmts.ogc / org.gvsig.raster.wmts.ogc.impl / src / main / java / org / gvsig / raster / wmts / ogc / impl / wmts_1_0_0 / struct / WMTSLegendURL_1_0_0.java @ 1811

History | View | Annotate | Download (3.16 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.raster.wmts.ogc.impl.wmts_1_0_0.struct;
23

    
24
import java.io.IOException;
25

    
26
import org.gvsig.raster.wmts.ogc.impl.Tags;
27
import org.gvsig.raster.wmts.ogc.impl.struct.WMTSBaseStruct;
28
import org.gvsig.raster.wmts.ogc.impl.struct.WMTSLegendURLImpl;
29
import org.kxml2.io.KXmlParser;
30
import org.xmlpull.v1.XmlPullParserException;
31

    
32
/**
33
 * Describes the attributes of a layer in a WMTS server using the protocol version 1.0.0
34
 *
35
 * @author Nacho Brodin (nachobrodin@gmail.com)
36
 */
37
public class WMTSLegendURL_1_0_0 extends WMTSLegendURLImpl {
38

    
39
        public void parse(KXmlParser parser) throws IOException, XmlPullParserException {
40
            int currentTag;
41
            boolean end = false;
42
            
43
            currentTag = parser.next();
44
            
45
            while (!end) {
46
                         switch(currentTag) {
47
                                case KXmlParser.START_TAG:
48
                                        if (compareName(parser, Tags.WMTS_FORMAT)) {
49
                                                parser.skipSubTree();
50
                                        } else if (compareName(parser, Tags.WMTS_MINSCALEDEN)) {
51
                                                try {
52
                                                        setMinScaleDenominator(Double.parseDouble(parser.nextText()));
53
                                                } catch (NumberFormatException e) {
54
                                                }
55
                                        } else if (compareName(parser, Tags.WMTS_MAXSCALEDEN)) {
56
                                                try {
57
                                                        setMaxScaleDenominator(Double.parseDouble(parser.nextText()));
58
                                                } catch (NumberFormatException e) {
59
                                                }
60
                                        } else if (compareName(parser, Tags.WMTS_HREF)) {
61
                                                setHref(parser.nextText());
62
                                        } else if (compareName(parser, Tags.WMTS_WIDTH)) {
63
                                                try {
64
                                                        setWidth(Integer.parseInt(parser.nextText()));
65
                                                } catch (NumberFormatException e) {
66
                                                }
67
                                        } else if (compareName(parser, Tags.WMTS_HEIGHT)) {
68
                                                try {
69
                                                        setHeight(Integer.parseInt(parser.nextText()));
70
                                                } catch (NumberFormatException e) {
71
                                                }
72
                                        }                        
73
                                        break;
74
                                case KXmlParser.END_TAG:
75
                                        if (compareName(parser, Tags.WMTS_LEGENDURL))
76
                                                end = true;
77
                                        break;
78
                                case KXmlParser.TEXT:                                        
79
                                break;
80
                         }
81
             if (!end)
82
                 currentTag = parser.next();
83
            }
84
    }
85
        
86
        /**
87
     * Compares the next name in the selected parser with the string passed
88
     * by value.
89
     * @param parser
90
     * @param name
91
     * @return
92
     */
93
    public boolean compareName(KXmlParser parser, String name) {
94
            String s = parser.getName();
95
            if(s.compareTo(name) == 0 || s.compareTo(WMTSBaseStruct.gmlTag + name) == 0)
96
                    return true;
97
            return false;
98
    }
99
        
100
}