root / trunk / libraries / libGPE-KML / src / org / gvsig / gpe / kml / parser / v21 / geometries / RegionBinding.java @ 21966
History | View | Annotate | Download (3.43 KB)
1 |
package org.gvsig.gpe.kml.parser.v21.geometries; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import javax.xml.namespace.QName; |
6 |
|
7 |
import org.gvsig.gpe.kml.parser.GPEDeafultKmlParser; |
8 |
import org.gvsig.gpe.kml.utils.Kml2_1_Tags; |
9 |
import org.gvsig.gpe.xml.stream.IXmlStreamReader; |
10 |
import org.gvsig.gpe.xml.stream.XmlStreamException; |
11 |
import org.gvsig.gpe.xml.utils.CompareUtils; |
12 |
|
13 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
14 |
*
|
15 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
16 |
*
|
17 |
* This program is free software; you can redistribute it and/or
|
18 |
* modify it under the terms of the GNU General Public License
|
19 |
* as published by the Free Software Foundation; either version 2
|
20 |
* of the License, or (at your option) any later version.
|
21 |
*
|
22 |
* This program is distributed in the hope that it will be useful,
|
23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
25 |
* GNU General Public License for more details.
|
26 |
*
|
27 |
* You should have received a copy of the GNU General Public License
|
28 |
* along with this program; if not, write to the Free Software
|
29 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
30 |
*
|
31 |
* For more information, contact:
|
32 |
*
|
33 |
* Generalitat Valenciana
|
34 |
* Conselleria d'Infraestructures i Transport
|
35 |
* Av. Blasco Ib??ez, 50
|
36 |
* 46010 VALENCIA
|
37 |
* SPAIN
|
38 |
*
|
39 |
* +34 963862235
|
40 |
* gvsig@gva.es
|
41 |
* www.gvsig.gva.es
|
42 |
*
|
43 |
* or
|
44 |
*
|
45 |
* IVER T.I. S.A
|
46 |
* Salamanca 50
|
47 |
* 46005 Valencia
|
48 |
* Spain
|
49 |
*
|
50 |
* +34 963163400
|
51 |
* dac@iver.es
|
52 |
*/
|
53 |
/* CVS MESSAGES:
|
54 |
*
|
55 |
* $Id:RegionBinding.java 357 2008-01-09 17:50:08Z jpiera $
|
56 |
* $Log$
|
57 |
* Revision 1.1 2007/05/11 07:06:29 jorpiell
|
58 |
* Refactoring of some package names
|
59 |
*
|
60 |
* Revision 1.1 2007/05/09 08:36:24 jorpiell
|
61 |
* Add the bbox to the layer
|
62 |
*
|
63 |
*
|
64 |
*/
|
65 |
/**
|
66 |
* This class parses a Region Kml tag. Example:
|
67 |
* <p>
|
68 |
* <pre>
|
69 |
* <code>
|
70 |
* <Region>
|
71 |
* <LatLonAltBox>
|
72 |
* <north>43.374</north>
|
73 |
* <south>42.983</south>
|
74 |
* <east>-0.335</east>
|
75 |
* <west>-1.423</west>
|
76 |
* <rotation>39.37878630116985</rotation>
|
77 |
* </LatLonAltBox>
|
78 |
* </Region>
|
79 |
* </code>
|
80 |
* </pre>
|
81 |
* </p>
|
82 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
83 |
* @see http://code.google.com/apis/kml/documentation/kml_tags_21.html#region
|
84 |
*/
|
85 |
public class RegionBinding { |
86 |
|
87 |
/**
|
88 |
* It parses the Region tag
|
89 |
* @param parser
|
90 |
* The XML parser
|
91 |
* @param handler
|
92 |
* The GPE parser that contains the content handler and
|
93 |
* the error handler
|
94 |
* @return
|
95 |
* A Bounding box
|
96 |
* @throws IOException
|
97 |
* @throws XmlStreamException
|
98 |
*/
|
99 |
public Object parse(IXmlStreamReader parser,GPEDeafultKmlParser handler) throws XmlStreamException, IOException { |
100 |
boolean endFeature = false; |
101 |
int currentTag;
|
102 |
Object bbox = null; |
103 |
|
104 |
QName tag = parser.getName();
|
105 |
currentTag = parser.getEventType(); |
106 |
|
107 |
while (!endFeature){
|
108 |
switch(currentTag){
|
109 |
case IXmlStreamReader.START_ELEMENT:
|
110 |
if (CompareUtils.compareWithNamespace(tag,Kml2_1_Tags.LATLONALTBOX)){
|
111 |
bbox = handler.getProfile().getLatLonAltBoxBinding().parse(parser, handler); |
112 |
} |
113 |
break;
|
114 |
case IXmlStreamReader.END_ELEMENT:
|
115 |
if (CompareUtils.compareWithNamespace(tag,Kml2_1_Tags.REGION)){
|
116 |
endFeature = true;
|
117 |
} |
118 |
break;
|
119 |
case IXmlStreamReader.CHARACTERS:
|
120 |
|
121 |
break;
|
122 |
} |
123 |
if (!endFeature){
|
124 |
currentTag = parser.next(); |
125 |
tag = parser.getName(); |
126 |
} |
127 |
} |
128 |
return bbox;
|
129 |
} |
130 |
} |
131 |
|