Statistics
| Revision:

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

History | View | Annotate | Download (3.25 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

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

    
80
        public static Object parse(XmlPullParser parser,GPEKmlParser handler) throws KmlBodyParseException {
81
                boolean endFeature = false;
82
                int currentTag;
83
                Object geometry = null;
84
                        
85
                try {
86
                        String tag = parser.getName();
87
                        currentTag = parser.getEventType();
88
                        
89
                        while (!endFeature){
90
                                switch(currentTag){
91
                                case KXmlParser.START_TAG:
92
                                        if (tag.compareTo(KmlTags.COORDINATES) == 0){
93
                                                double[][] coordinates = CoordinatesTypeBinding.parse(parser, handler);
94
                                                Object point = handler.getContentHandler().startPoint(coordinates[0][0],
95
                                                                        coordinates[1][0],
96
                                                                        coordinates[2][0],
97
                                                                        null,
98
                                                                        KmlTags.DEFAULT_SRS);
99
                                                handler.getContentHandler().endPoint(point);
100
                                        }
101
                                        break;
102
                                case KXmlParser.END_TAG:
103
                                        if (tag.compareTo(KmlTags.POINT) == 0){                                                
104
                                                endFeature = true;
105
                                        }
106
                                        break;
107
                                case KXmlParser.TEXT:                                        
108
                                        
109
                                        break;
110
                                }
111
                                if (!endFeature){                                        
112
                                        currentTag = parser.next();
113
                                        tag = parser.getName();
114
                                }
115
                        }                        
116
                } catch (XmlPullParserException e) {
117
                        throw new KmlBodyParseException(e);
118
                } catch (IOException e) {
119
                        throw new KmlBodyParseException(e);
120
                }
121
                return geometry;        
122
        }
123

    
124

    
125

    
126
}