Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / libraries / libGPE-GML / src / org / gvsig / gpe / gml / parser / v2 / geometries / MultiPolygonPropertyTypeBinding.java @ 18882

History | View | Annotate | Download (4.11 KB)

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

    
3
import java.io.IOException;
4

    
5
import org.gvsig.gpe.gml.GMLTags;
6
import org.gvsig.gpe.gml.GPEDefaultGmlParser;
7
import org.gvsig.gpe.gml.utils.CompareUtils;
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:MultiPolygonPropertyTypeBinding.java 371 2008-01-10 09:30:19Z jpiera $
55
 * $Log$
56
 * Revision 1.2  2007/05/24 07:29:47  csanchez
57
 * A?adidos Alias GML2
58
 *
59
 * Revision 1.1  2007/05/15 07:30:38  jorpiell
60
 * Add the geometryProperties tags
61
 *
62
 *
63
 */
64
/**
65
 * It parses a gml:multiPolygonProperty object. Example:
66
 * <p>
67
 * <pre>
68
 * <code> 
69
 * &lt;multiPolygonProperty&gt;
70
 * &lt;MultiPolygon gid="c731" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"&gt;
71
 * &lt;polygonMember&gt;
72
 * &lt;Polygon gid="_877789"&gt;
73
 * &lt;outerBoundaryIs&gt;
74
 * &lt;LinearRing&gt;
75
 * &lt;coordinates&gt;0.0,0.0 100.0,0.0 50.0,100.0 0.0,0.0&lt;/coordinates&gt;
76
 * &lt;/LinearRing&gt;
77
 * &lt;/outerBoundaryIs&gt;
78
 * &lt;/Polygon&gt;
79
 * &lt;/polygonMember&gt;
80
 * &lt;polygonMember&gt;
81
 * &lt;Polygon gid="_877790"&gt;
82
 * &lt;outerBoundaryIs&gt;
83
 * &lt;LinearRing&gt;
84
 * &lt;coordinates&gt;0.0,0.0 100.0,0.0 50.0,100.0 0.0,0.0&lt;/coordinates&gt;
85
 * &lt;/LinearRing&gt;
86
 * &lt;/outerBoundaryIs&gt;
87
 * &lt;/Polygon&gt;
88
 * &lt;/polygonMember&gt;
89
 * &lt;MultiPolygon&gt;
90
 * &lt;/multiPolygonProperty&gt;
91
 * </code>
92
 * </pre>
93
 * </p> 
94
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
95
 */
96
public class MultiPolygonPropertyTypeBinding extends GeometryBinding{
97
        
98
        /**
99
         * It parses the gml:MultiPolygon tag
100
         * @param parser
101
         * The XML parser
102
         * @param handler
103
         * The GPE parser that contains the content handler and
104
         * the error handler
105
         * @return
106
         * A multipolygon
107
         * @throws XmlPullParserException
108
         * @throws IOException
109
         */
110
        public Object parse(XmlPullParser parser,GPEDefaultGmlParser handler) throws XmlPullParserException, IOException {
111
                boolean endFeature = false;
112
                int currentTag;
113
                Object multiPolygon = null;                
114
                
115
                super.setAtributtes(parser, handler.getErrorHandler());
116
                
117
                String tag = parser.getName();
118
                currentTag = parser.getEventType();
119

    
120
                while (!endFeature){
121
                        switch(currentTag){
122
                        case KXmlParser.START_TAG:
123
                                        if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_MULTIPOLYGON)){
124
                                                multiPolygon = handler.getProfile().getMultiPolygonTypeBinding().
125
                                                parse(parser, handler);
126
                                        }
127
                                        break;
128
                                case KXmlParser.END_TAG:
129
                                        if ((CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_MULTIPOLYGONPROPERTY))||
130
                                        (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_MULTIEXTENTOF))||
131
                                        (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_MULTICOVERAGE)))
132
                                        {                                                
133
                                                endFeature = true;                                                        
134
                                        }
135
                                        break;
136
                                case KXmlParser.TEXT:                                        
137
                                        
138
                                        break;
139
                                }
140
                                if (!endFeature){                                        
141
                                        currentTag = parser.next();
142
                                        tag = parser.getName();
143
                                }
144
                        }                        
145
                return multiPolygon;        
146
        }
147
}
148