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 / WMTSTileMatrix_1_0_0.java @ 2613
History | View | Annotate | Download (4.63 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 |
import java.util.List; |
26 |
|
27 |
import org.gvsig.compat.CompatLocator; |
28 |
import org.gvsig.raster.wmts.ogc.impl.Tags; |
29 |
import org.gvsig.raster.wmts.ogc.impl.struct.WMTSBaseStruct; |
30 |
import org.gvsig.raster.wmts.ogc.impl.struct.WMTSTileMatrixImpl; |
31 |
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrix; |
32 |
import org.kxml2.io.KXmlParser; |
33 |
import org.xmlpull.v1.XmlPullParserException; |
34 |
|
35 |
/**
|
36 |
* Describes the attributes of a layer in a WMTS server using the protocol version 1.0.0
|
37 |
*
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
39 |
*/
|
40 |
public class WMTSTileMatrix_1_0_0 extends WMTSTileMatrixImpl { |
41 |
|
42 |
/**
|
43 |
* Parses the tile matrix
|
44 |
* @param parser
|
45 |
* @throws IOException
|
46 |
* @throws XmlPullParserException
|
47 |
*/
|
48 |
public void parse(KXmlParser parser, List<WMTSTileMatrix> tileMatrixList) 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, Tags.WMTS_IDENTIFIER)) {
|
58 |
setIdentifier(nextText(parser)); |
59 |
} else if (compareName(parser, Tags.WMTS_TITLE)) { |
60 |
setTitle(nextText(parser)); |
61 |
} else if (compareName(parser, Tags.WMTS_ABSTRACT)) { |
62 |
setAbstract(nextText(parser)); |
63 |
} else if (compareName(parser, Tags.WMTS_KEYWORDS)) { |
64 |
parser.skipSubTree(); |
65 |
//setKeywords(nextText(parser));
|
66 |
} else if (compareName(parser, Tags.WMTS_SCALEDENOMINATOR)) { |
67 |
try {
|
68 |
setScaleDenominator(Double.parseDouble(nextText(parser)));
|
69 |
} catch (NumberFormatException e) { |
70 |
} |
71 |
} else if (compareName(parser, Tags.WMTS_TOPLEFTCORNER)) { |
72 |
String v = nextText(parser);
|
73 |
if(v != null) { |
74 |
String[] list = CompatLocator.getStringUtils().split(v, " "); |
75 |
if(list.length == 2) { |
76 |
try {
|
77 |
getTopLeftCorner()[0] = Double.parseDouble(list[0]); |
78 |
getTopLeftCorner()[1] = Double.parseDouble(list[1]); |
79 |
/*if(!forceLongitudeFirstAxisOrder) {
|
80 |
getTopLeftCorner()[0] = Double.parseDouble(list[0]);
|
81 |
getTopLeftCorner()[1] = Double.parseDouble(list[1]);
|
82 |
} else {
|
83 |
getTopLeftCorner()[1] = Double.parseDouble(list[0]);
|
84 |
getTopLeftCorner()[0] = Double.parseDouble(list[1]);
|
85 |
}*/
|
86 |
} catch (NumberFormatException e) { |
87 |
} |
88 |
} |
89 |
} |
90 |
} else if (compareName(parser, Tags.WMTS_TILEWIDTH)) { |
91 |
try {
|
92 |
setTileWidth(Integer.parseInt(nextText(parser)));
|
93 |
} catch (NumberFormatException e) { |
94 |
} |
95 |
} else if (compareName(parser, Tags.WMTS_TILEHEIGHT)) { |
96 |
try {
|
97 |
setTileHeight(Integer.parseInt(nextText(parser)));
|
98 |
} catch (NumberFormatException e) { |
99 |
} |
100 |
} else if (compareName(parser, Tags.WMTS_MATRIXWIDTH)) { |
101 |
try {
|
102 |
setMatrixWidth(Long.parseLong(nextText(parser)));
|
103 |
} catch (NumberFormatException e) { |
104 |
} |
105 |
} else if (compareName(parser, Tags.WMTS_MATRIXHEIGHT)) { |
106 |
try {
|
107 |
setMatrixHeight(Long.parseLong(nextText(parser)));
|
108 |
} catch (NumberFormatException e) { |
109 |
} |
110 |
} |
111 |
break;
|
112 |
case KXmlParser.END_TAG:
|
113 |
if (compareName(parser, Tags.WMTS_TILEMATRIX))
|
114 |
end = true;
|
115 |
break;
|
116 |
case KXmlParser.TEXT:
|
117 |
break;
|
118 |
} |
119 |
if (!end)
|
120 |
currentTag = parser.next(); |
121 |
} |
122 |
tileMatrixList.add(this);
|
123 |
} |
124 |
|
125 |
/**
|
126 |
* Compares the next name in the selected parser with the string passed
|
127 |
* by value.
|
128 |
* @param parser
|
129 |
* @param name
|
130 |
* @return
|
131 |
*/
|
132 |
public boolean compareName(KXmlParser parser, String name) { |
133 |
String s = parser.getName();
|
134 |
if(s.compareTo(name) == 0 || s.compareTo(WMTSBaseStruct.gmlTag + name) == 0) |
135 |
return true; |
136 |
return false; |
137 |
} |
138 |
} |