root / trunk / libraries / libGPE-KML / src / org / gvsig / gpe / kml / versions / KmlParserV2_0.java @ 11205
History | View | Annotate | Download (3.31 KB)
1 |
package org.gvsig.gpe.kml.versions; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import org.gvsig.gpe.kml.GPEKmlParser; |
6 |
import org.gvsig.gpe.kml.KmlTags; |
7 |
import org.gvsig.gpe.kml.bindings.DocumentBinding; |
8 |
import org.gvsig.gpe.kml.bindings.LookAtBinding; |
9 |
import org.gvsig.gpe.kml.bindings.PlaceMarketBinding; |
10 |
import org.gvsig.gpe.kml.exceptions.KmlBodyParseException; |
11 |
import org.kxml2.io.KXmlParser; |
12 |
import org.xmlpull.v1.XmlPullParser; |
13 |
import org.xmlpull.v1.XmlPullParserException; |
14 |
|
15 |
|
16 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
17 |
*
|
18 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
19 |
*
|
20 |
* This program is free software; you can redistribute it and/or
|
21 |
* modify it under the terms of the GNU General Public License
|
22 |
* as published by the Free Software Foundation; either version 2
|
23 |
* of the License, or (at your option) any later version.
|
24 |
*
|
25 |
* This program is distributed in the hope that it will be useful,
|
26 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
27 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
28 |
* GNU General Public License for more details.
|
29 |
*
|
30 |
* You should have received a copy of the GNU General Public License
|
31 |
* along with this program; if not, write to the Free Software
|
32 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
33 |
*
|
34 |
* For more information, contact:
|
35 |
*
|
36 |
* Generalitat Valenciana
|
37 |
* Conselleria d'Infraestructures i Transport
|
38 |
* Av. Blasco Ib??ez, 50
|
39 |
* 46010 VALENCIA
|
40 |
* SPAIN
|
41 |
*
|
42 |
* +34 963862235
|
43 |
* gvsig@gva.es
|
44 |
* www.gvsig.gva.es
|
45 |
*
|
46 |
* or
|
47 |
*
|
48 |
* IVER T.I. S.A
|
49 |
* Salamanca 50
|
50 |
* 46005 Valencia
|
51 |
* Spain
|
52 |
*
|
53 |
* +34 963163400
|
54 |
* dac@iver.es
|
55 |
*/
|
56 |
/* CVS MESSAGES:
|
57 |
*
|
58 |
* $Id: KmlParserV2_0.java 11205 2007-04-13 13:16:21Z jorpiell $
|
59 |
* $Log$
|
60 |
* Revision 1.1 2007-04-13 13:16:21 jorpiell
|
61 |
* Add KML reading support
|
62 |
*
|
63 |
* Revision 1.1 2007/03/07 08:19:10 jorpiell
|
64 |
* Pasadas las clases de KML de libGPE-GML a libGPE-KML
|
65 |
*
|
66 |
* Revision 1.1 2007/02/28 11:48:31 csanchez
|
67 |
* *** empty log message ***
|
68 |
*
|
69 |
* Revision 1.1 2007/02/20 10:53:20 jorpiell
|
70 |
* A?adidos los proyectos de kml y gml antiguos
|
71 |
*
|
72 |
* Revision 1.1 2007/02/12 13:49:18 jorpiell
|
73 |
* A?adido el driver de KML
|
74 |
*
|
75 |
*
|
76 |
*/
|
77 |
/**
|
78 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
79 |
*/
|
80 |
public class KmlParserV2_0 extends AbstractKmlParser{ |
81 |
|
82 |
public KmlParserV2_0(XmlPullParser parser, GPEKmlParser handler) {
|
83 |
super(parser, handler);
|
84 |
} |
85 |
|
86 |
/*
|
87 |
* (non-Javadoc)
|
88 |
* @see org.gvsig.remoteClient.gmlEngine.IFeaturesParser#getVersion()
|
89 |
*/
|
90 |
public String getVersion() { |
91 |
return "2.0"; |
92 |
} |
93 |
|
94 |
/*
|
95 |
* (non-Javadoc)
|
96 |
* @see org.gvsig.gpe.kml.versions.AbstractKmlParser#initParse()
|
97 |
*/
|
98 |
public void initParse() throws KmlBodyParseException { |
99 |
boolean endFeature = false; |
100 |
int currentTag;
|
101 |
|
102 |
try {
|
103 |
String tag = getParser().getName();
|
104 |
currentTag = getParser().getEventType(); |
105 |
|
106 |
while (!endFeature){
|
107 |
switch(currentTag){
|
108 |
case XmlPullParser.START_TAG:
|
109 |
if (tag.compareTo(KmlTags.DOCUMENT) == 0){ |
110 |
DocumentBinding.parse(getParser(), getHandler()); |
111 |
} |
112 |
break;
|
113 |
case XmlPullParser.END_DOCUMENT:
|
114 |
endFeature = true;
|
115 |
|
116 |
break;
|
117 |
} |
118 |
if (!endFeature){
|
119 |
currentTag = getParser().next(); |
120 |
tag = getParser().getName(); |
121 |
} |
122 |
} |
123 |
|
124 |
} catch (XmlPullParserException e) {
|
125 |
throw new KmlBodyParseException (e); |
126 |
} catch (IOException e) { |
127 |
throw new KmlBodyParseException (e); |
128 |
} |
129 |
} |
130 |
|
131 |
} |