Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wmts / wmts_1_0_0 / struct / WMTSTileMatrix_1_0_0.java @ 40769

History | View | Annotate | Download (4.63 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.remoteclient.wmts.wmts_1_0_0.struct;
25

    
26
import java.io.IOException;
27
import java.util.ArrayList;
28

    
29
import org.gvsig.compat.CompatLocator;
30
import org.gvsig.remoteclient.utils.CapabilitiesTags;
31
import org.gvsig.remoteclient.wmts.struct.WMTSBaseStruct;
32
import org.gvsig.remoteclient.wmts.struct.WMTSTileMatrix;
33
import org.kxml2.io.KXmlParser;
34
import org.xmlpull.v1.XmlPullParserException;
35

    
36
/**
37
 * Describes the attributes of a layer in a WMTS server using the protocol version 1.0.0
38
 *
39
 * @author Nacho Brodin (nachobrodin@gmail.com)
40
 */
41
public class WMTSTileMatrix_1_0_0 extends WMTSTileMatrix {
42
        
43
        /**
44
     * Parses the tile matrix
45
     * @param parser
46
     * @throws IOException
47
     * @throws XmlPullParserException
48
     */
49
        public void parse(KXmlParser parser, ArrayList tileMatrixList) throws IOException, XmlPullParserException {
50
            int currentTag;
51
            boolean end = false;
52
            
53
            currentTag = parser.next();
54
            
55
            while (!end) {
56
                         switch(currentTag) {
57
                                case KXmlParser.START_TAG:
58
                                        if (compareName(parser, CapabilitiesTags.WMTS_IDENTIFIER)) {
59
                                                setIdentifier(nextText(parser));
60
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_TITLE)) {
61
                                                setTitle(nextText(parser));
62
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_ABSTRACT)) {
63
                                                setAbstract(nextText(parser));
64
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_KEYWORDS)) {
65
                                                parser.skipSubTree();
66
                                                //setKeywords(nextText(parser));
67
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_SCALEDENOMINATOR)) {
68
                                                try {
69
                                                        setScaleDenominator(Double.parseDouble(nextText(parser)));
70
                                                } catch (NumberFormatException e) {
71
                                                }
72
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_TOPLEFTCORNER)) {
73
                                                String v = nextText(parser);
74
                                                if(v != null) {
75
                                                        String[] list = CompatLocator.getStringUtils().split(v, " ");
76
                                                        if(list.length == 2) {
77
                                                                try {
78
                                                                        if(!forceLongitudeFirstAxisOrder) {
79
                                                                                getTopLeftCorner()[0] = Double.parseDouble(list[0]);
80
                                                                                getTopLeftCorner()[1] = Double.parseDouble(list[1]);
81
                                                                        } else {
82
                                                                                getTopLeftCorner()[1] = Double.parseDouble(list[0]);
83
                                                                                getTopLeftCorner()[0] = Double.parseDouble(list[1]);
84
                                                                        }
85
                                                                } catch (NumberFormatException e) {
86
                                                                }
87
                                                        }
88
                                                }
89
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_TILEWIDTH)) {
90
                                                try {
91
                                                        setTileWidth(Integer.parseInt(nextText(parser)));
92
                                                } catch (NumberFormatException e) {
93
                                                }
94
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_TILEHEIGHT)) {
95
                                                try {
96
                                                        setTileHeight(Integer.parseInt(nextText(parser)));
97
                                                } catch (NumberFormatException e) {
98
                                                }
99
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_MATRIXWIDTH)) {
100
                                                try {
101
                                                        setMatrixWidth(Long.parseLong(nextText(parser)));
102
                                                } catch (NumberFormatException e) {
103
                                                }
104
                                        } else if (compareName(parser, CapabilitiesTags.WMTS_MATRIXHEIGHT)) {
105
                                                try {
106
                                                        setMatrixHeight(Long.parseLong(nextText(parser)));
107
                                                } catch (NumberFormatException e) {
108
                                                }
109
                                        }
110
                                        break;
111
                                case KXmlParser.END_TAG:
112
                                        if (compareName(parser, CapabilitiesTags.WMTS_TILEMATRIX))
113
                                                end = true;
114
                                        break;
115
                                case KXmlParser.TEXT:                                        
116
                                break;
117
                         }
118
             if (!end)
119
                 currentTag = parser.next();
120
            }
121
            tileMatrixList.add(this);
122
    }
123
        
124
    /**
125
     * Compares the next name in the selected parser with the string passed
126
     * by value.
127
     * @param parser
128
     * @param name
129
     * @return
130
     */
131
    public boolean compareName(KXmlParser parser, String name) {
132
            String s = parser.getName();
133
            if(s.compareTo(name) == 0 || s.compareTo(WMTSBaseStruct.gmlTag + name) == 0)
134
                    return true;
135
            return false;
136
    }
137
}