root / branches / Mobile1.0 / org.gvsig.gpe.gml / src / org / gvsig / gpe / gml / parser / v2 / geometries / BoxTypeBinding.java @ 79
History | View | Annotate | Download (4.51 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.parser.v2.coordinates.CoordTypeIterator; |
9 |
import org.gvsig.gpe.gml.parser.v2.coordinates.CoordinatesTypeIterator; |
10 |
import org.gvsig.gpe.gml.utils.GMLTags; |
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:BoxTypeBinding.java 371 2008-01-10 09:30:19Z jpiera $
|
58 |
* $Log$
|
59 |
* Revision 1.5 2007/05/24 07:29:47 csanchez
|
60 |
* A?adidos Alias GML2
|
61 |
*
|
62 |
* Revision 1.4 2007/05/14 11:18:51 jorpiell
|
63 |
* ProjectionFactory updated
|
64 |
*
|
65 |
* Revision 1.3 2007/05/14 09:31:06 jorpiell
|
66 |
* Add the a new class to compare tags
|
67 |
*
|
68 |
* Revision 1.2 2007/05/08 10:24:16 jorpiell
|
69 |
* Add comments to create javadocs
|
70 |
*
|
71 |
* Revision 1.1 2007/05/07 12:58:42 jorpiell
|
72 |
* Add some methods to manage the multigeometries
|
73 |
*
|
74 |
*
|
75 |
*/
|
76 |
/**
|
77 |
* It parses a gml:BoxType object. Example:
|
78 |
* <p>
|
79 |
* <pre>
|
80 |
* <code>
|
81 |
* <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
|
82 |
* <gml:coord><gml:X>0</gml:X><gml:Y>0</gml:Y></gml:coord>
|
83 |
* <gml:coord><gml:X>50</gml:X><gml:Y>50</gml:Y></gml:coord>
|
84 |
* </gml:Box>
|
85 |
* </code>
|
86 |
* </pre>
|
87 |
* </p>
|
88 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
89 |
*/
|
90 |
public class BoxTypeBinding extends GeometryBinding{ |
91 |
|
92 |
/**
|
93 |
* It parses the gml:Box tag
|
94 |
* @param parser
|
95 |
* The XML parser
|
96 |
* @param handler
|
97 |
* The GPE parser that contains the content handler and
|
98 |
* the error handler
|
99 |
* @return
|
100 |
* The Bounding box
|
101 |
* @throws XmlStreamException
|
102 |
* @throws IOException
|
103 |
*/
|
104 |
public Object parse(IXmlStreamReader parser,GPEDefaultGmlParser handler) throws XmlStreamException, IOException { |
105 |
boolean endFeature = false; |
106 |
int currentTag;
|
107 |
Object bbox = null; |
108 |
|
109 |
super.setAtributtes(parser, handler.getErrorHandler());
|
110 |
|
111 |
QName tag = parser.getName();
|
112 |
currentTag = parser.getEventType(); |
113 |
|
114 |
while (!endFeature){
|
115 |
switch(currentTag){
|
116 |
case IXmlStreamReader.START_ELEMENT:
|
117 |
if (CompareUtils.compareWithNamespace(tag,GMLTags.GML_COORDINATES)){
|
118 |
CoordinatesTypeIterator coordinatesIterator = handler.getProfile().getCoordinatesTypeBinding(); |
119 |
coordinatesIterator.initialize(parser, handler,GMLTags.GML_BOX); |
120 |
bbox = handler.getContentHandler().startBbox(id, |
121 |
coordinatesIterator, |
122 |
srsName); |
123 |
//The parser pointer is in the </gml:Box> tag
|
124 |
return bbox;
|
125 |
}else if (CompareUtils.compareWithNamespace(tag,GMLTags.GML_COORD)){ |
126 |
CoordTypeIterator coordinatesIterator = handler.getProfile().getCoordTypeBinding(); |
127 |
coordinatesIterator.initialize(parser, handler,GMLTags.GML_BOX); |
128 |
bbox = handler.getContentHandler().startBbox(id, |
129 |
coordinatesIterator, |
130 |
srsName); |
131 |
//The parser pointer is in the </gml:Box> tag
|
132 |
return bbox;
|
133 |
} |
134 |
break;
|
135 |
case IXmlStreamReader.END_ELEMENT:
|
136 |
if (CompareUtils.compareWithNamespace(tag,GMLTags.GML_BOX)){
|
137 |
endFeature = true;
|
138 |
handler.getContentHandler().endBbox(bbox); |
139 |
} |
140 |
break;
|
141 |
case IXmlStreamReader.CHARACTERS:
|
142 |
|
143 |
break;
|
144 |
} |
145 |
if (!endFeature){
|
146 |
currentTag = parser.next(); |
147 |
tag = parser.getName(); |
148 |
} |
149 |
} |
150 |
return bbox;
|
151 |
} |
152 |
} |