Statistics
| Revision:

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

History | View | Annotate | Download (3.4 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.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:OuterBoundaryIsTypeBinding.java 371 2008-01-10 09:30:19Z jpiera $
54
 * $Log$
55
 * Revision 1.3  2007/05/15 11:55:11  jorpiell
56
 * MultiGeometry is now supported
57
 *
58
 * Revision 1.2  2007/05/14 09:31:06  jorpiell
59
 * Add the a new class to compare tags
60
 *
61
 * Revision 1.1  2007/05/07 12:58:42  jorpiell
62
 * Add some methods to manage the multigeometries
63
 *
64
 *
65
 */
66
/**
67
 * It parses a gml:outerBoundaryType object. Example:
68
 * <p>
69
 * <pre>
70
 * <code>
71
 * &lt;outerBoundaryIs&gt;
72
 * &lt;LinearRing&gt;
73
 * &lt;coordinates&gt;10.0,10.0 10.0,40.0 40.0,40.0 40.0,10.0 10.0,10.0&lt;/coordinates&gt;
74
 * &lt;/LinearRing&gt;
75
 * &lt;/outerBoundaryIs&gt;
76
 * </code>
77
 * </pre>
78
 * </p> 
79
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
80
 */
81
public class OuterBoundaryIsTypeBinding {
82
        
83
        /**
84
         * It parses the gml:outerBoundaryIs tag
85
         * @param parser
86
         * The XML parser
87
         * @param handler
88
         * The GPE parser that contains the content handler and
89
         * the error handler
90
         * @return
91
         * An array of coordinates
92
         * @throws XmlPullParserException
93
         * @throws IOException
94
         */
95
        public double[][] parse(XmlPullParser parser,GPEDefaultGmlParser handler) throws XmlPullParserException, IOException {
96
                boolean endFeature = false;
97
                int currentTag;
98
                        
99
                double[][] coordinates = null;
100

    
101
                String tag = parser.getName();
102
                currentTag = parser.getEventType();
103

    
104
                while (!endFeature){
105
                        switch(currentTag){
106
                        case XmlPullParser.START_TAG:
107
                                if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_LINEARRING)){
108
                                        coordinates = handler.getProfile().getLinearRingTypeBinding().
109
                                        parseCoordinates(parser, handler);
110
                                }
111
                                break;
112
                        case XmlPullParser.END_TAG:
113
                                if (CompareUtils.compareWithOutNamespace(tag,GMLTags.GML_OUTERBOUNDARYIS)){                                                
114
                                        endFeature = true;
115
                                }
116
                                break;
117
                        case XmlPullParser.TEXT:                                        
118

    
119
                                break;
120
                        }
121
                        if (!endFeature){                                        
122
                                currentTag = parser.next();
123
                                tag = parser.getName();
124
                        }
125
                }                        
126

    
127
                return coordinates;
128
        }
129
}