Statistics
| Revision:

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

History | View | Annotate | Download (3.78 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:BoundedByTypeBinding.java 371 2008-01-10 09:30:19Z jpiera $
55
 * $Log$
56
 * Revision 1.1  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:BoundingShapeType object. Example:
66
 * <p>
67
 * <pre>
68
 * <code>
69
 * &lt;gml:boundedBy&gt;
70
 * &lt;gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"&gt;
71
 * &lt;gml:coord&gt;&lt;gml:X&gt;0&lt;/gml:X&gt;&lt;gml:Y&gt;0&lt;/gml:Y&gt;&lt;/gml:coord&gt;
72
 * &lt;gml:coord&gt;&lt;gml:X&gt;50&lt;/gml:X&gt;&lt;gml:Y&gt;50&lt;/gml:Y&gt;&lt;/gml:coord&gt;
73
 * &lt;/gml:Box&gt;
74
 * &lt;/gml:boundedBy&gt;
75
 * </code>
76
 * </pre>
77
 * </p> 
78
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
79
 */
80
public class BoundedByTypeBinding {
81
        
82
        /**
83
         * It parses the gml:shapeType tag
84
         * @param parser
85
         * The XML parser
86
         * @param handler
87
         * The GPE parser that contains the content handler and
88
         * the error handler
89
         * @return
90
         * The Bounding box
91
         * @throws XmlPullParserException
92
         * @throws IOException
93
         */
94
        public Object parse(XmlPullParser parser,GPEDefaultGmlParser handler) throws XmlPullParserException, IOException {
95
                boolean endFeature = false;
96
                int currentTag;
97
                Object bbox = null;                
98
                
99
                String tag = parser.getName();
100
                currentTag = parser.getEventType();
101

    
102
                while (!endFeature){
103
                        switch(currentTag){
104
                        case KXmlParser.START_TAG:
105
                                        bbox = parseTag(parser, handler, tag);
106
                                        break;
107
                                case KXmlParser.END_TAG:
108
                                        if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_BOUNDEDBY)){                                                
109
                                                endFeature = true;                                                
110
                                        }
111
                                        break;
112
                                case KXmlParser.TEXT:                        
113
                                        
114
                                        break;
115
                                }
116
                                if (!endFeature){                                        
117
                                        currentTag = parser.next();
118
                                        tag = parser.getName();
119
                                }
120
                        }                        
121
                return bbox;        
122
        }
123
        
124
        /**
125
         * Parses the tag
126
         * @param parser
127
         * @param handler
128
         * @param tag
129
         * @return
130
         * @throws XmlPullParserException
131
         * @throws IOException
132
         */
133
        protected Object parseTag(XmlPullParser parser,GPEDefaultGmlParser handler, String tag) throws XmlPullParserException, IOException{
134
                Object bbox = null;
135
                if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_BOX)){
136
                        bbox = handler.getProfile().getBoxTypeBinding().parse(parser, handler);
137
                }
138
                return bbox;
139
        }
140
}