root / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wmts / wmts_1_0_0 / struct / WMTSBoundingBox_1_0_0.java @ 34402
History | View | Annotate | Download (3.49 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.compat.CompatLocator; |
27 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
28 |
import org.gvsig.remoteclient.wmts.struct.WMTSBaseStruct; |
29 |
import org.gvsig.remoteclient.wmts.struct.WMTSBoundingBox; |
30 |
import org.kxml2.io.KXmlParser; |
31 |
import org.xmlpull.v1.XmlPullParserException; |
32 |
|
33 |
/**
|
34 |
* Describes the bounding box of a layer in a WMTS server
|
35 |
*
|
36 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
37 |
*/
|
38 |
public class WMTSBoundingBox_1_0_0 extends WMTSBoundingBox { |
39 |
|
40 |
/**
|
41 |
* Parses a WGS84BoundingBox object
|
42 |
* @param parser
|
43 |
* @throws IOException
|
44 |
* @throws XmlPullParserException
|
45 |
*/
|
46 |
public void parse(KXmlParser parser) throws IOException, XmlPullParserException { |
47 |
int currentTag;
|
48 |
boolean end = false; |
49 |
|
50 |
currentTag = parser.next(); |
51 |
|
52 |
while (!end) {
|
53 |
switch(currentTag) {
|
54 |
case KXmlParser.START_TAG:
|
55 |
if (compareName(parser, CapabilitiesTags.WMTS_LOWERCORNER)) {
|
56 |
String v = parser.nextText();
|
57 |
if(v != null) { |
58 |
String[] list = CompatLocator.getStringUtils().split(v, " "); |
59 |
if(list.length == 2) { |
60 |
try {
|
61 |
getLowerCorner()[0] = Double.parseDouble(list[0]); |
62 |
getLowerCorner()[1] = Double.parseDouble(list[1]); |
63 |
} catch (NumberFormatException e) { |
64 |
} |
65 |
} |
66 |
} |
67 |
} else if (compareName(parser, CapabilitiesTags.WMTS_UPPERCORNER)) { |
68 |
String v = parser.nextText();
|
69 |
if(v != null) { |
70 |
String[] list = CompatLocator.getStringUtils().split(v, " "); |
71 |
if(list.length == 2) { |
72 |
try {
|
73 |
getUpperCorner()[0] = Double.parseDouble(list[0]); |
74 |
getUpperCorner()[1] = Double.parseDouble(list[1]); |
75 |
} catch (NumberFormatException e) { |
76 |
} |
77 |
} |
78 |
} |
79 |
} else if (compareName(parser, CapabilitiesTags.WMTS_CRS)) { |
80 |
setCrs(parser.nextText()); |
81 |
} else if (compareName(parser, CapabilitiesTags.WMTS_DIMENSIONS)) { |
82 |
try {
|
83 |
setDimensions(Integer.parseInt(parser.nextText()));
|
84 |
} catch (NumberFormatException e) { |
85 |
} |
86 |
} |
87 |
break;
|
88 |
case KXmlParser.END_TAG:
|
89 |
if (compareName(parser, CapabilitiesTags.WMTS_WGS84BOUNDINGBOX) || compareName(parser, CapabilitiesTags.WMTS_BOUNDINGBOX))
|
90 |
end = true;
|
91 |
break;
|
92 |
case KXmlParser.TEXT:
|
93 |
break;
|
94 |
} |
95 |
if (!end)
|
96 |
currentTag = parser.next(); |
97 |
} |
98 |
} |
99 |
|
100 |
/**
|
101 |
* Compares the next name in the selected parser with the string passed
|
102 |
* by value.
|
103 |
* @param parser
|
104 |
* @param name
|
105 |
* @return
|
106 |
*/
|
107 |
public boolean compareName(KXmlParser parser, String name) { |
108 |
String s = parser.getName();
|
109 |
if(s.compareTo(name) == 0 || s.compareTo(WMTSBaseStruct.gmlTag + name) == 0) |
110 |
return true; |
111 |
return false; |
112 |
} |
113 |
} |