Statistics
| Revision:

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

History | View | Annotate | Download (2.96 KB)

1
package org.gvsig.gpe.kml.bindings.geometries;
2

    
3
import java.io.IOException;
4
import java.util.ArrayList;
5

    
6
import org.gvsig.gpe.kml.GPEKmlParser;
7
import org.gvsig.gpe.kml.KmlTags;
8
import org.gvsig.gpe.kml.exceptions.KmlBodyParseException;
9
import org.kxml2.io.KXmlParser;
10
import org.xmlpull.v1.XmlPullParser;
11
import org.xmlpull.v1.XmlPullParserException;
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: PolygonTypeBinding.java 11205 2007-04-13 13:16:21Z jorpiell $
56
 * $Log$
57
 * Revision 1.1  2007-04-13 13:16:21  jorpiell
58
 * Add KML reading support
59
 *
60
 * Revision 1.1  2007/03/07 08:19:10  jorpiell
61
 * Pasadas las clases de KML de libGPE-GML a libGPE-KML
62
 *
63
 * Revision 1.1  2007/02/28 11:48:31  csanchez
64
 * *** empty log message ***
65
 *
66
 * Revision 1.1  2007/02/20 10:53:20  jorpiell
67
 * A?adidos los proyectos de kml y gml antiguos
68
 *
69
 * Revision 1.1  2007/02/12 13:49:18  jorpiell
70
 * A?adido el driver de KML
71
 *
72
 *
73
 */
74
/**
75
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
76
 */
77
public class PolygonTypeBinding {
78

    
79
        public static void parse(XmlPullParser parser,GPEKmlParser handler) throws KmlBodyParseException {
80
                boolean endFeature = false;
81
                int currentTag;        
82
                        
83
                try {
84
                        String tag = parser.getName();
85
                        currentTag = parser.getEventType();
86
                        
87
                        while (!endFeature){
88
                                switch(currentTag){
89
                                case KXmlParser.START_TAG:
90
                                        if (tag.compareTo(KmlTags.OUTERBOUNDARYIS) == 0){
91
                                                OuterBoundaryIsBinding.parse(parser, handler);
92
                                        }
93
                                        break;
94
                                case KXmlParser.END_TAG:
95
                                        if (tag.compareTo(KmlTags.POLYGON) == 0){                                                
96
                                                endFeature = true;
97
                                        }
98
                                        break;
99
                                case KXmlParser.TEXT:                                        
100
                                        
101
                                        break;
102
                                }
103
                                if (!endFeature){                                        
104
                                        currentTag = parser.next();
105
                                        tag = parser.getName();
106
                                }
107
                        }                        
108
                } catch (XmlPullParserException e) {
109
                        throw new KmlBodyParseException(e);
110
                } catch (IOException e) {
111
                        throw new KmlBodyParseException(e);
112
                }                
113
        }
114
}