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