Statistics
| Revision:

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

History | View | Annotate | Download (3.42 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.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: PolygonPropertyTypeBinding.java 11781 2007-05-24 07:29:47Z csanchez $
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:polygonProperty object. Example:
66
 * <p>
67
 * <pre>
68
 * <code>
69
 * &lt;polygonProperty&gt;
70
 * &lt;Polygon gid="_877789"&gt;
71
 * &lt;outerBoundaryIs&gt;
72
 * &lt;LinearRing&gt;
73
 * &lt;coordinates&gt;0.0,0.0 100.0,0.0 50.0,100.0 0.0,0.0&lt;/coordinates&gt;
74
 * &lt;/LinearRing&gt;
75
 * &lt;/outerBoundaryIs&gt;
76
 * &lt;/Polygon&gt;
77
 * &lt;/polygonProperty&gt;
78
 * </code>
79
 * </pre>
80
 * </p> 
81
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
82
 */
83
public class PolygonPropertyTypeBinding {
84
        
85
        /**
86
         * It parses the gml:PolygonProperty tag
87
         * @param parser
88
         * The XML parser
89
         * @param handler
90
         * The GPE parser that contains the content handler and
91
         * the error handler
92
         * @return
93
         * A polygon
94
         * @throws XmlPullParserException
95
         * @throws IOException
96
         */
97
        public static Object parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException {
98
                boolean endFeature = false;
99
                int currentTag;
100
                Object polygon = null;                
101
                
102
                String tag = parser.getName();
103
                currentTag = parser.getEventType();
104

    
105
                while (!endFeature){
106
                        switch(currentTag){
107
                        case KXmlParser.START_TAG:
108
                                        if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_POLYGON)){
109
                                                polygon = PolygonTypeBinding.parse(parser, handler);
110
                                        }
111
                                        break;
112
                                case KXmlParser.END_TAG:
113
                                        if ((CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_POLYGONPROPERTY))||
114
                                        (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_EXTENTOF))||
115
                                        (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_COVERAGE)))
116
                                        {                                                
117
                                                endFeature = true;                                                
118
                                        }
119
                                        break;
120
                                case KXmlParser.TEXT:                        
121
                                        
122
                                        break;
123
                                }
124
                                if (!endFeature){                                        
125
                                        currentTag = parser.next();
126
                                        tag = parser.getName();
127
                                }
128
                        }                        
129
                return polygon;        
130
        }
131
}
132