Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / gml / bindings / geometries / MultiPolygonPropertyTypeBinding.java @ 11781

History | View | Annotate | Download (4.18 KB)

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

    
3
import java.io.IOException;
4
import java.util.Hashtable;
5

    
6
import org.gvsig.gpe.gml.GMLTags;
7
import org.gvsig.gpe.gml.GPEGmlParser;
8
import org.gvsig.gpe.gml.utils.CompareUtils;
9
import org.gvsig.gpe.gml.utils.GMLUtilsParser;
10
import org.kxml2.io.KXmlParser;
11
import org.xmlpull.v1.XmlPullParser;
12
import org.xmlpull.v1.XmlPullParserException;
13

    
14
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
15
 *
16
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
17
 *
18
 * This program is free software; you can redistribute it and/or
19
 * modify it under the terms of the GNU General Public License
20
 * as published by the Free Software Foundation; either version 2
21
 * of the License, or (at your option) any later version.
22
 *
23
 * This program is distributed in the hope that it will be useful,
24
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
 * GNU General Public License for more details.
27
 *
28
 * You should have received a copy of the GNU General Public License
29
 * along with this program; if not, write to the Free Software
30
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
31
 *
32
 * For more information, contact:
33
 *
34
 *  Generalitat Valenciana
35
 *   Conselleria d'Infraestructures i Transport
36
 *   Av. Blasco Ib??ez, 50
37
 *   46010 VALENCIA
38
 *   SPAIN
39
 *
40
 *      +34 963862235
41
 *   gvsig@gva.es
42
 *      www.gvsig.gva.es
43
 *
44
 *    or
45
 *
46
 *   IVER T.I. S.A
47
 *   Salamanca 50
48
 *   46005 Valencia
49
 *   Spain
50
 *
51
 *   +34 963163400
52
 *   dac@iver.es
53
 */
54
/* CVS MESSAGES:
55
 *
56
 * $Id: MultiPolygonPropertyTypeBinding.java 11781 2007-05-24 07:29:47Z csanchez $
57
 * $Log$
58
 * Revision 1.2  2007-05-24 07:29:47  csanchez
59
 * A?adidos Alias GML2
60
 *
61
 * Revision 1.1  2007/05/15 07:30:38  jorpiell
62
 * Add the geometryProperties tags
63
 *
64
 *
65
 */
66
/**
67
 * It parses a gml:multiPolygonProperty object. Example:
68
 * <p>
69
 * <pre>
70
 * <code> 
71
 * &lt;multiPolygonProperty&gt;
72
 * &lt;MultiPolygon gid="c731" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"&gt;
73
 * &lt;polygonMember&gt;
74
 * &lt;Polygon gid="_877789"&gt;
75
 * &lt;outerBoundaryIs&gt;
76
 * &lt;LinearRing&gt;
77
 * &lt;coordinates&gt;0.0,0.0 100.0,0.0 50.0,100.0 0.0,0.0&lt;/coordinates&gt;
78
 * &lt;/LinearRing&gt;
79
 * &lt;/outerBoundaryIs&gt;
80
 * &lt;/Polygon&gt;
81
 * &lt;/polygonMember&gt;
82
 * &lt;polygonMember&gt;
83
 * &lt;Polygon gid="_877790"&gt;
84
 * &lt;outerBoundaryIs&gt;
85
 * &lt;LinearRing&gt;
86
 * &lt;coordinates&gt;0.0,0.0 100.0,0.0 50.0,100.0 0.0,0.0&lt;/coordinates&gt;
87
 * &lt;/LinearRing&gt;
88
 * &lt;/outerBoundaryIs&gt;
89
 * &lt;/Polygon&gt;
90
 * &lt;/polygonMember&gt;
91
 * &lt;MultiPolygon&gt;
92
 * &lt;/multiPolygonProperty&gt;
93
 * </code>
94
 * </pre>
95
 * </p> 
96
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
97
 */
98
public class MultiPolygonPropertyTypeBinding {
99
        
100
        /**
101
         * It parses the gml:MultiPolygon tag
102
         * @param parser
103
         * The XML parser
104
         * @param handler
105
         * The GPE parser that contains the content handler and
106
         * the error handler
107
         * @return
108
         * A multipolygon
109
         * @throws XmlPullParserException
110
         * @throws IOException
111
         */
112
        public static Object parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException {
113
                boolean endFeature = false;
114
                int currentTag;
115
                Object multiPolygon = null;                
116
                
117
                Hashtable attributes = GMLUtilsParser.getAttributes(parser);                
118
                String srsName = GeometryBinding.getSrs(attributes,handler.getErrorHandler());
119
                String id = GeometryBinding.getID(attributes);        
120
                
121
                String tag = parser.getName();
122
                currentTag = parser.getEventType();
123

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