root / branches / v1_9_0 / libGPE-GML / src / org / gvsig / gpe / gml / parser / v2 / geometries / OuterBoundaryIsTypeBinding.java @ 53
History | View | Annotate | Download (3.57 KB)
1 |
package org.gvsig.gpe.gml.parser.v2.geometries; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import javax.xml.namespace.QName; |
6 |
|
7 |
import org.gvsig.gpe.gml.parser.GPEDefaultGmlParser; |
8 |
import org.gvsig.gpe.gml.utils.GMLTags; |
9 |
import org.gvsig.gpe.parser.ICoordinateIterator; |
10 |
import org.gvsig.gpe.xml.stream.EventType; |
11 |
import org.gvsig.gpe.xml.stream.IXmlStreamReader; |
12 |
import org.gvsig.gpe.xml.stream.XmlStreamException; |
13 |
import org.gvsig.gpe.xml.utils.CompareUtils; |
14 |
|
15 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
16 |
*
|
17 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
18 |
*
|
19 |
* This program is free software; you can redistribute it and/or
|
20 |
* modify it under the terms of the GNU General Public License
|
21 |
* as published by the Free Software Foundation; either version 2
|
22 |
* of the License, or (at your option) any later version.
|
23 |
*
|
24 |
* This program is distributed in the hope that it will be useful,
|
25 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27 |
* GNU General Public License for more details.
|
28 |
*
|
29 |
* You should have received a copy of the GNU General Public License
|
30 |
* along with this program; if not, write to the Free Software
|
31 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
32 |
*
|
33 |
* For more information, contact:
|
34 |
*
|
35 |
* Generalitat Valenciana
|
36 |
* Conselleria d'Infraestructures i Transport
|
37 |
* Av. Blasco Ib??ez, 50
|
38 |
* 46010 VALENCIA
|
39 |
* SPAIN
|
40 |
*
|
41 |
* +34 963862235
|
42 |
* gvsig@gva.es
|
43 |
* www.gvsig.gva.es
|
44 |
*
|
45 |
* or
|
46 |
*
|
47 |
* IVER T.I. S.A
|
48 |
* Salamanca 50
|
49 |
* 46005 Valencia
|
50 |
* Spain
|
51 |
*
|
52 |
* +34 963163400
|
53 |
* dac@iver.es
|
54 |
*/
|
55 |
/* CVS MESSAGES:
|
56 |
*
|
57 |
* $Id:OuterBoundaryIsTypeBinding.java 371 2008-01-10 09:30:19Z jpiera $
|
58 |
* $Log$
|
59 |
* Revision 1.3 2007/05/15 11:55:11 jorpiell
|
60 |
* MultiGeometry is now supported
|
61 |
*
|
62 |
* Revision 1.2 2007/05/14 09:31:06 jorpiell
|
63 |
* Add the a new class to compare tags
|
64 |
*
|
65 |
* Revision 1.1 2007/05/07 12:58:42 jorpiell
|
66 |
* Add some methods to manage the multigeometries
|
67 |
*
|
68 |
*
|
69 |
*/
|
70 |
/**
|
71 |
* It parses a gml:outerBoundaryType object. Example:
|
72 |
* <p>
|
73 |
* <pre>
|
74 |
* <code>
|
75 |
* <outerBoundaryIs>
|
76 |
* <LinearRing>
|
77 |
* <coordinates>10.0,10.0 10.0,40.0 40.0,40.0 40.0,10.0 10.0,10.0</coordinates>
|
78 |
* </LinearRing>
|
79 |
* </outerBoundaryIs>
|
80 |
* </code>
|
81 |
* </pre>
|
82 |
* </p>
|
83 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
84 |
*/
|
85 |
public class OuterBoundaryIsTypeBinding { |
86 |
|
87 |
/**
|
88 |
* It parses the gml:outerBoundaryIs tag
|
89 |
* @param parser
|
90 |
* The XML parser
|
91 |
* @param handler
|
92 |
* The GPE parser that contains the content handler and
|
93 |
* the error handler
|
94 |
* @return
|
95 |
* An array of coordinates
|
96 |
* @throws XmlStreamException
|
97 |
* @throws IOException
|
98 |
*/
|
99 |
public ICoordinateIterator parse(IXmlStreamReader parser,GPEDefaultGmlParser handler) throws XmlStreamException, IOException { |
100 |
|
101 |
parser.require(EventType.START_ELEMENT, GMLTags.GML_OUTERBOUNDARYIS); |
102 |
|
103 |
boolean endFeature = false; |
104 |
EventType currentTag; |
105 |
|
106 |
QName tag = parser.getElementName();
|
107 |
currentTag = parser.getEventType(); |
108 |
|
109 |
while (!endFeature){
|
110 |
switch(currentTag.getCode()){
|
111 |
case EventType.START_ELEMENT_CODE:
|
112 |
if (CompareUtils.compareWithNamespace(tag,GMLTags.GML_LINEARRING)){
|
113 |
return handler.getProfile().getLinearRingTypeBinding().
|
114 |
parseCoordinates(parser, handler); |
115 |
} |
116 |
break;
|
117 |
case EventType.END_ELEMENT_CODE:
|
118 |
if (CompareUtils.compareWithNamespace(tag,GMLTags.GML_OUTERBOUNDARYIS)){
|
119 |
endFeature = true;
|
120 |
} |
121 |
break;
|
122 |
} |
123 |
if (!endFeature){
|
124 |
currentTag = parser.nextTag(); |
125 |
tag = parser.getElementName(); |
126 |
} |
127 |
} |
128 |
return null; |
129 |
} |
130 |
} |