Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / gml / v2 / GMLFeaturesParser_v2.java @ 11697

History | View | Annotate | Download (4.44 KB)

1
package org.gvsig.gpe.gml.v2;
2

    
3
import java.io.IOException;
4

    
5
import org.gvsig.exceptions.BaseException;
6
import org.gvsig.gpe.gml.GMLTags;
7
import org.gvsig.gpe.gml.exceptions.GMLException;
8
import org.gvsig.gpe.gml.exceptions.GMLFileReadException;
9
import org.gvsig.gpe.gml.exceptions.GMLParserException;
10
import org.gvsig.gpe.gml.factories.IGeometriesFactory;
11
import org.gvsig.gpe.gml.old.IGMLFeaturesIterator;
12
import org.gvsig.gpe.gml.schemas.XMLSchemaParser;
13
import org.gvsig.gpe.gml.utils.CapabilitiesTags;
14
import org.gvsig.gpe.gml.utils.GMLUtilsParser;
15
import org.kxml2.io.KXmlParser;
16
import org.xmlpull.v1.XmlPullParserException;
17

    
18
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
19
 *
20
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
21
 *
22
 * This program is free software; you can redistribute it and/or
23
 * modify it under the terms of the GNU General Public License
24
 * as published by the Free Software Foundation; either version 2
25
 * of the License, or (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
35
 *
36
 * For more information, contact:
37
 *
38
 *  Generalitat Valenciana
39
 *   Conselleria d'Infraestructures i Transport
40
 *   Av. Blasco Ib??ez, 50
41
 *   46010 VALENCIA
42
 *   SPAIN
43
 *
44
 *      +34 963862235
45
 *   gvsig@gva.es
46
 *      www.gvsig.gva.es
47
 *
48
 *    or
49
 *
50
 *   IVER T.I. S.A
51
 *   Salamanca 50
52
 *   46005 Valencia
53
 *   Spain
54
 *
55
 *   +34 963163400
56
 *   dac@iver.es
57
 */
58
/* CVS MESSAGES:
59
 *
60
 * $Id: GMLFeaturesParser_v2.java 11697 2007-05-16 13:00:48Z csanchez $
61
 * $Log$
62
 * Revision 1.2  2007-05-16 13:00:48  csanchez
63
 * Actualizaci?n de libGPE-GML
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.6  2007/01/15 13:11:00  csanchez
72
 * Sistema de Warnings y Excepciones adaptado a BasicException
73
 *
74
 * Revision 1.5  2006/12/22 11:25:44  csanchez
75
 * Nuevo parser GML 2.x para gml's sin esquema
76
 *
77
 * Revision 1.4  2006/10/11 16:19:50  jorpiell
78
 * No se pod?an cargar GMLs con 0 geometr?as
79
 *
80
 * Revision 1.3  2006/10/10 12:52:28  jorpiell
81
 * Soporte para features complejas.
82
 *
83
 * Revision 1.2  2006/08/10 12:37:05  jorpiell
84
 * A?adido el tag description al GML parser
85
 *
86
 * Revision 1.1  2006/08/10 12:00:49  jorpiell
87
 * Primer commit del driver de Gml
88
 *
89
 *
90
 */
91
/**
92
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
93
 * @author Carlos S?nchez Peri??n (sanchez_carper@gva.es)
94
 */
95
public class GMLFeaturesParser_v2 extends org.gvsig.gpe.gml.old.GMLFeaturesParser {
96
        
97
        public GMLFeaturesParser_v2(IGeometriesFactory factory, XMLSchemaParser parser) throws Exception{
98
                super(factory, parser);                
99
        }
100

    
101
        /*
102
         *  (non-Javadoc)
103
         * @see org.gvsig.remoteClient.gml.GMLParser#getFeaturesReader()
104
         */
105
        public IGMLFeaturesIterator getFeaturesReader() throws GMLException {
106
                return new GMLFeaturesIterator_v2(getParser(),getFactory());
107
        }
108

    
109
        /*
110
         *  (non-Javadoc)
111
         * @see org.gvsig.remoteClient.gml.GMLParser#initializeHeader()
112
         */
113
        public void initializeHeader() throws BaseException {
114
                getParser().setSchema("gml");                
115
                int currentTag;
116
                boolean startFeatures = false;
117
                
118
                try {
119
                        currentTag = getParser().next();                
120
                        while(!startFeatures){                                                
121
                                switch(currentTag){
122
                                case KXmlParser.START_TAG:
123
                                        if (getParser().getName().compareTo(GMLTags.GML_NAME)==0){
124
                                                
125
                                        }else if (getParser().getName().compareTo(GMLTags.GML_DESCRIPTION)==0){
126
                                                
127
                                        }else if (getParser().getName().compareTo(GMLTags.GML_BOUNDEDBY)==0){
128
                                                setExtent(GMLUtilsParser.parseBoundedBy(getParser()));
129
                                        }else{
130
                                                startFeatures = true;
131
                                        }
132
                                        break;
133
                                case KXmlParser.END_TAG:
134
                                        if (getParser().getName().compareTo(CapabilitiesTags.WFS_FEATURE_COLLECTION) == 0){
135
                                                                startFeatures = true;
136
                                        }
137
                                        break;
138
                                case KXmlParser.TEXT:                   
139
                                        break;
140
                                }
141
                                if (!startFeatures){
142
                                        currentTag = getParser().next();
143
                                }
144
                        }
145
                } catch (XmlPullParserException e) {
146
                        //Captured KXML parsing Exception
147
                        throw new GMLParserException(e);
148
                } catch (IOException e) {
149
                        // TODO Auto-generated catch block
150
                        throw new GMLFileReadException(e);
151
                }                 
152
        }
153

    
154
        
155
}