Statistics
| Revision:

root / trunk / libraries / libGPE-KML / src / org / gvsig / gpe / kml / bindings / PlaceMarketBinding.java @ 11205

History | View | Annotate | Download (4.03 KB)

1
package org.gvsig.gpe.kml.bindings;
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.geometries.LineStringTypeBinding;
8
import org.gvsig.gpe.kml.bindings.geometries.PointTypeBinding;
9
import org.gvsig.gpe.kml.bindings.geometries.PolygonTypeBinding;
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
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
16
 *
17
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
18
 *
19
 * This program is free software; you can redistribute it and/or
20
 * modify it under the terms of the GNU General Public License
21
 * as published by the Free Software Foundation; either version 2
22
 * of the License, or (at your option) any later version.
23
 *
24
 * This program is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 * GNU General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU General Public License
30
 * along with this program; if not, write to the Free Software
31
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
32
 *
33
 * For more information, contact:
34
 *
35
 *  Generalitat Valenciana
36
 *   Conselleria d'Infraestructures i Transport
37
 *   Av. Blasco Ib??ez, 50
38
 *   46010 VALENCIA
39
 *   SPAIN
40
 *
41
 *      +34 963862235
42
 *   gvsig@gva.es
43
 *      www.gvsig.gva.es
44
 *
45
 *    or
46
 *
47
 *   IVER T.I. S.A
48
 *   Salamanca 50
49
 *   46005 Valencia
50
 *   Spain
51
 *
52
 *   +34 963163400
53
 *   dac@iver.es
54
 */
55
/* CVS MESSAGES:
56
 *
57
 * $Id: PlaceMarketBinding.java 11205 2007-04-13 13:16:21Z jorpiell $
58
 * $Log$
59
 * Revision 1.2  2007-04-13 13:16:21  jorpiell
60
 * Add KML reading support
61
 *
62
 * Revision 1.1  2007/03/07 08:19:10  jorpiell
63
 * Pasadas las clases de KML de libGPE-GML a libGPE-KML
64
 *
65
 * Revision 1.1  2007/02/28 11:48:31  csanchez
66
 * *** empty log message ***
67
 *
68
 * Revision 1.1  2007/02/20 10:53:20  jorpiell
69
 * A?adidos los proyectos de kml y gml antiguos
70
 *
71
 * Revision 1.1  2007/02/12 13:49:18  jorpiell
72
 * A?adido el driver de KML
73
 *
74
 *
75
 */
76
/**
77
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
78
 */
79
public class PlaceMarketBinding {
80

    
81
        public static void parse(XmlPullParser parser,GPEKmlParser handler)  throws KmlBodyParseException {
82
                boolean endFeature = false;
83
                int currentTag;                
84
                        
85
                Object feature = handler.getContentHandler().startFeature(null, null);
86
                
87
                try {
88
                        String tag = parser.getName();
89
                        currentTag = parser.getEventType();
90
                        
91
                        while (!endFeature){
92
                                switch(currentTag){
93
                                case KXmlParser.START_TAG:
94
                                        if (tag.compareTo(KmlTags.NAME) == 0){
95
                                                parser.next();
96
                                                handler.getContentHandler().addNameToFeature(feature,parser.getText());
97
                                        }else if (tag.compareTo(KmlTags.DESCRIPTION) == 0){
98
                                                parser.next();
99
                                                String description = parser.getText();
100
                                        }else if (tag.compareTo(KmlTags.VISIBILITY) == 0){
101
                                                parser.next();
102
                                                String visibility = parser.getText();
103
                                        }else if (tag.compareTo(KmlTags.LOOKAT) == 0){
104
                                                LookAtBinding.parse(parser, handler);
105
                                        }else if (tag.compareTo(KmlTags.STYLEURL) == 0){
106
                                                parser.next();
107
                                                String styleURL = parser.getText();
108
                                        }else if (tag.compareTo(KmlTags.POINT) == 0){
109
                                                PointTypeBinding.parse(parser, handler);
110
                                        }else if (tag.compareTo(KmlTags.LINESTRING) == 0){
111
                                                LineStringTypeBinding.parse(parser, handler);
112
                                        }else if (tag.compareTo(KmlTags.POLYGON) == 0){
113
                                                PolygonTypeBinding.parse(parser, handler);
114
                                        }
115
                                        break;
116
                                case KXmlParser.END_TAG:
117
                                        if (tag.compareTo(KmlTags.PLACEMARK) == 0){                                                
118
                                                endFeature = true;
119
                                                handler.getContentHandler().endFeature(feature);
120
                                        }
121
                                        break;
122
                                case KXmlParser.TEXT:                                        
123
                                        
124
                                        break;
125
                                }
126
                                if (!endFeature){                                        
127
                                        currentTag = parser.next();
128
                                        tag = parser.getName();
129
                                }
130
                        }                        
131
                } catch (XmlPullParserException e) {
132
                        throw new KmlBodyParseException(e);
133
                } catch (IOException e) {
134
                        throw new KmlBodyParseException(e);
135
                }                
136
        }
137
}