Statistics
| Revision:

root / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / gml / parser / v2 / geometries / GeometryMemberTypeBinding.java @ 19366

History | View | Annotate | Download (3.64 KB)

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

    
3
import java.io.IOException;
4

    
5
import org.gvsig.gpe.gml.parser.GPEDefaultGmlParser;
6
import org.gvsig.gpe.gml.utils.CompareUtils;
7
import org.gvsig.gpe.gml.utils.GMLTags;
8
import org.kxml2.io.KXmlParser;
9
import org.xmlpull.v1.XmlPullParser;
10
import org.xmlpull.v1.XmlPullParserException;
11

    
12
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
13
 *
14
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
29
 *
30
 * For more information, contact:
31
 *
32
 *  Generalitat Valenciana
33
 *   Conselleria d'Infraestructures i Transport
34
 *   Av. Blasco Ib??ez, 50
35
 *   46010 VALENCIA
36
 *   SPAIN
37
 *
38
 *      +34 963862235
39
 *   gvsig@gva.es
40
 *      www.gvsig.gva.es
41
 *
42
 *    or
43
 *
44
 *   IVER T.I. S.A
45
 *   Salamanca 50
46
 *   46005 Valencia
47
 *   Spain
48
 *
49
 *   +34 963163400
50
 *   dac@iver.es
51
 */
52
/* CVS MESSAGES:
53
 *
54
 * $Id:GeometryMemberTypeBinding.java 371 2008-01-10 09:30:19Z jpiera $
55
 * $Log$
56
 * Revision 1.2  2007/05/14 09:31:06  jorpiell
57
 * Add the a new class to compare tags
58
 *
59
 * Revision 1.1  2007/05/07 12:58:42  jorpiell
60
 * Add some methods to manage the multigeometries
61
 *
62
 *
63
 */
64
/**
65
 * It parses a gml:geometryMemberType object. Example:
66
 * <p>
67
 * <pre>
68
 * <code>
69
 * &lt;geometryMember&gt;
70
 * &lt;Point gid="P6776"&gt;
71
 * &lt;coord&gt;&lt;X&gt;50.0&lt;/X&gt;&lt;Y&gt;50.0&lt;/Y&gt;&lt;/coord&gt;
72
 * &lt;/Point&gt;
73
 * &lt;/geometryMember&gt;
74
 * </code>
75
 * </pre>
76
 * </p> 
77
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
78
 */
79

    
80

    
81
public class GeometryMemberTypeBinding {
82
        
83
        /**
84
         * It parses the gml:GeometryMember tag
85
         * @param parser
86
         * The XML parser
87
         * @param handler
88
         * The GPE parser that contains the content handler and
89
         * the error handler
90
         * @return
91
         * A Geometry
92
         * @throws XmlPullParserException
93
         * @throws IOException
94
         */
95
        public Object parse(XmlPullParser parser,GPEDefaultGmlParser handler) throws XmlPullParserException, IOException {
96
                boolean endFeature = false;
97
                int currentTag;
98
                Object geometry = null;                
99
                
100
                String tag = parser.getName();
101
                currentTag = parser.getEventType();
102

    
103
                while (!endFeature){
104
                        switch(currentTag){
105
                        case KXmlParser.START_TAG:
106
                                        if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_POINT)){
107
                                                geometry = handler.getProfile().getPointTypeBinding().
108
                                                parse(parser, handler);
109
                                        }else if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_LINESTRING)){
110
                                                geometry = handler.getProfile().getLineStringTypeBinding().
111
                                                parse(parser, handler);
112
                                        }if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_POLYGON)){
113
                                                geometry = handler.getProfile().getPolygonTypeBinding().
114
                                                parse(parser, handler);
115
                                        }
116
                                        break;
117
                                case KXmlParser.END_TAG:
118
                                        if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_GEOMETRYMEMBER)){                                                
119
                                                endFeature = true;                                                
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
                return geometry;        
132
        }
133
}