Statistics
| Revision:

root / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / gml / bindings / geometries / BoundingShapeTypeBinding.java @ 11475

History | View | Annotate | Download (3.15 KB)

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

    
3
import java.io.IOException;
4

    
5
import org.gvsig.gpe.gml.GMLTags;
6
import org.gvsig.gpe.gml.GPEGmlParser;
7
import org.kxml2.io.KXmlParser;
8
import org.xmlpull.v1.XmlPullParser;
9
import org.xmlpull.v1.XmlPullParserException;
10

    
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
 *
13
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
 *
15
 * This program is free software; you can redistribute it and/or
16
 * modify it under the terms of the GNU General Public License
17
 * as published by the Free Software Foundation; either version 2
18
 * of the License, or (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
 *
29
 * For more information, contact:
30
 *
31
 *  Generalitat Valenciana
32
 *   Conselleria d'Infraestructures i Transport
33
 *   Av. Blasco Ib??ez, 50
34
 *   46010 VALENCIA
35
 *   SPAIN
36
 *
37
 *      +34 963862235
38
 *   gvsig@gva.es
39
 *      www.gvsig.gva.es
40
 *
41
 *    or
42
 *
43
 *   IVER T.I. S.A
44
 *   Salamanca 50
45
 *   46005 Valencia
46
 *   Spain
47
 *
48
 *   +34 963163400
49
 *   dac@iver.es
50
 */
51
/* CVS MESSAGES:
52
 *
53
 * $Id: BoundingShapeTypeBinding.java 11475 2007-05-07 12:58:42Z jorpiell $
54
 * $Log$
55
 * Revision 1.1  2007-05-07 12:58:42  jorpiell
56
 * Add some methods to manage the multigeometries
57
 *
58
 *
59
 */
60
/**
61
 * It parses a gml:BoundingShapeType object. Example:
62
 * <p>
63
 * <pre>
64
 * <code>
65
 * &lt;gml:boundedBy&gt;
66
 * &lt;gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"&gt;
67
 * &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;
68
 * &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;
69
 * &lt;/gml:Box&gt;
70
 * &lt;/gml:boundedBy&gt;
71
 * </code>
72
 * </pre>
73
 * </p> 
74
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
75
 */
76
public class BoundingShapeTypeBinding {
77
        
78
        /**
79
         * It parses the gml:shapeType tag
80
         * @param parser
81
         * The XML parser
82
         * @param handler
83
         * The GPE parser that contains the content handler and
84
         * the error handler
85
         * @return
86
         * The Bounding box
87
         * @throws XmlPullParserException
88
         * @throws IOException
89
         */
90
        public static Object parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException {
91
                boolean endFeature = false;
92
                int currentTag;
93
                Object bbox = null;                
94
                
95
                String tag = parser.getName();
96
                currentTag = parser.getEventType();
97

    
98
                while (!endFeature){
99
                        switch(currentTag){
100
                        case KXmlParser.START_TAG:
101
                                        if (tag.compareTo(GMLTags.GML_BOX) == 0){
102
                                                bbox = BoxTypeBinding.parse(parser, handler);
103
                                        }
104
                                        break;
105
                                case KXmlParser.END_TAG:
106
                                        if (tag.compareTo(GMLTags.GML_BOUNDEDBY) == 0){                                                
107
                                                endFeature = true;                                                
108
                                        }
109
                                        break;
110
                                case KXmlParser.TEXT:                        
111
                                        
112
                                        break;
113
                                }
114
                                if (!endFeature){                                        
115
                                        currentTag = parser.next();
116
                                        tag = parser.getName();
117
                                }
118
                        }                        
119
                return bbox;        
120
        }
121
}