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 / WMTSLegendURL_1_0_0.java @ 40769
History | View | Annotate | Download (3.42 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 |
|
28 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
29 |
import org.gvsig.remoteclient.wmts.struct.WMTSBaseStruct; |
30 |
import org.gvsig.remoteclient.wmts.struct.WMTSLegendURL; |
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 WMTSLegendURL_1_0_0 extends WMTSLegendURL { |
40 |
|
41 |
/*
|
42 |
* (non-Javadoc)
|
43 |
* @see org.gvsig.remoteclient.wmts.struct.WMTSLegendURL#parse(org.kxml2.io.KXmlParser)
|
44 |
*/
|
45 |
public void parse(KXmlParser parser) throws IOException, XmlPullParserException { |
46 |
int currentTag;
|
47 |
boolean end = false; |
48 |
|
49 |
currentTag = parser.next(); |
50 |
|
51 |
while (!end) {
|
52 |
switch(currentTag) {
|
53 |
case KXmlParser.START_TAG:
|
54 |
if (compareName(parser, CapabilitiesTags.WMTS_FORMAT)) {
|
55 |
parser.skipSubTree(); |
56 |
} else if (compareName(parser, CapabilitiesTags.WMTS_MINSCALEDEN)) { |
57 |
try {
|
58 |
setMinScaleDenominator(Double.parseDouble(parser.nextText()));
|
59 |
} catch (NumberFormatException e) { |
60 |
} |
61 |
} else if (compareName(parser, CapabilitiesTags.WMTS_MAXSCALEDEN)) { |
62 |
try {
|
63 |
setMaxScaleDenominator(Double.parseDouble(parser.nextText()));
|
64 |
} catch (NumberFormatException e) { |
65 |
} |
66 |
} else if (compareName(parser, CapabilitiesTags.WMTS_HREF)) { |
67 |
setHref(parser.nextText()); |
68 |
} else if (compareName(parser, CapabilitiesTags.WMTS_WIDTH)) { |
69 |
try {
|
70 |
setWidth(Integer.parseInt(parser.nextText()));
|
71 |
} catch (NumberFormatException e) { |
72 |
} |
73 |
} else if (compareName(parser, CapabilitiesTags.WMTS_HEIGHT)) { |
74 |
try {
|
75 |
setHeight(Integer.parseInt(parser.nextText()));
|
76 |
} catch (NumberFormatException e) { |
77 |
} |
78 |
} |
79 |
break;
|
80 |
case KXmlParser.END_TAG:
|
81 |
if (compareName(parser, CapabilitiesTags.WMTS_LEGENDURL))
|
82 |
end = true;
|
83 |
break;
|
84 |
case KXmlParser.TEXT:
|
85 |
break;
|
86 |
} |
87 |
if (!end)
|
88 |
currentTag = parser.next(); |
89 |
} |
90 |
} |
91 |
|
92 |
/**
|
93 |
* Compares the next name in the selected parser with the string passed
|
94 |
* by value.
|
95 |
* @param parser
|
96 |
* @param name
|
97 |
* @return
|
98 |
*/
|
99 |
public boolean compareName(KXmlParser parser, String name) { |
100 |
String s = parser.getName();
|
101 |
if(s.compareTo(name) == 0 || s.compareTo(WMTSBaseStruct.gmlTag + name) == 0) |
102 |
return true; |
103 |
return false; |
104 |
} |
105 |
|
106 |
} |