root / branches / Mobile1.0 / org.gvsig.gpe.gml / src / org / gvsig / gpe / gml / parser / v2 / geometries / BoundedByTypeBinding.java @ 79
History | View | Annotate | Download (3.81 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.xml.stream.IXmlStreamReader; |
10 |
import org.gvsig.gpe.xml.stream.XmlStreamException; |
11 |
import org.gvsig.gpe.xml.utils.CompareUtils; |
12 |
|
13 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
14 |
*
|
15 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
16 |
*
|
17 |
* This program is free software; you can redistribute it and/or
|
18 |
* modify it under the terms of the GNU General Public License
|
19 |
* as published by the Free Software Foundation; either version 2
|
20 |
* of the License, or (at your option) any later version.
|
21 |
*
|
22 |
* This program is distributed in the hope that it will be useful,
|
23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
25 |
* GNU General Public License for more details.
|
26 |
*
|
27 |
* You should have received a copy of the GNU General Public License
|
28 |
* along with this program; if not, write to the Free Software
|
29 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
30 |
*
|
31 |
* For more information, contact:
|
32 |
*
|
33 |
* Generalitat Valenciana
|
34 |
* Conselleria d'Infraestructures i Transport
|
35 |
* Av. Blasco Ib??ez, 50
|
36 |
* 46010 VALENCIA
|
37 |
* SPAIN
|
38 |
*
|
39 |
* +34 963862235
|
40 |
* gvsig@gva.es
|
41 |
* www.gvsig.gva.es
|
42 |
*
|
43 |
* or
|
44 |
*
|
45 |
* IVER T.I. S.A
|
46 |
* Salamanca 50
|
47 |
* 46005 Valencia
|
48 |
* Spain
|
49 |
*
|
50 |
* +34 963163400
|
51 |
* dac@iver.es
|
52 |
*/
|
53 |
/* CVS MESSAGES:
|
54 |
*
|
55 |
* $Id:BoundedByTypeBinding.java 371 2008-01-10 09:30:19Z jpiera $
|
56 |
* $Log$
|
57 |
* Revision 1.1 2007/05/14 09:31:06 jorpiell
|
58 |
* Add the a new class to compare tags
|
59 |
*
|
60 |
* Revision 1.1 2007/05/07 12:58:42 jorpiell
|
61 |
* Add some methods to manage the multigeometries
|
62 |
*
|
63 |
*
|
64 |
*/
|
65 |
/**
|
66 |
* It parses a gml:BoundingShapeType object. Example:
|
67 |
* <p>
|
68 |
* <pre>
|
69 |
* <code>
|
70 |
* <gml:boundedBy>
|
71 |
* <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
|
72 |
* <gml:coord><gml:X>0</gml:X><gml:Y>0</gml:Y></gml:coord>
|
73 |
* <gml:coord><gml:X>50</gml:X><gml:Y>50</gml:Y></gml:coord>
|
74 |
* </gml:Box>
|
75 |
* </gml:boundedBy>
|
76 |
* </code>
|
77 |
* </pre>
|
78 |
* </p>
|
79 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
80 |
*/
|
81 |
public class BoundedByTypeBinding { |
82 |
|
83 |
/**
|
84 |
* It parses the gml:shapeType 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 |
* The Bounding box
|
92 |
* @throws XmlStreamException
|
93 |
* @throws IOException
|
94 |
*/
|
95 |
public Object parse(IXmlStreamReader parser,GPEDefaultGmlParser handler) throws XmlStreamException, IOException { |
96 |
boolean endFeature = false; |
97 |
int currentTag;
|
98 |
Object bbox = null; |
99 |
|
100 |
QName tag = parser.getName();
|
101 |
currentTag = parser.getEventType(); |
102 |
|
103 |
while (!endFeature){
|
104 |
switch(currentTag){
|
105 |
case IXmlStreamReader.START_ELEMENT:
|
106 |
bbox = parseTag(parser, handler, tag); |
107 |
break;
|
108 |
case IXmlStreamReader.END_ELEMENT:
|
109 |
if (CompareUtils.compareWithNamespace(tag,GMLTags.GML_BOUNDEDBY)){
|
110 |
endFeature = true;
|
111 |
} |
112 |
break;
|
113 |
case IXmlStreamReader.CHARACTERS:
|
114 |
|
115 |
break;
|
116 |
} |
117 |
if (!endFeature){
|
118 |
currentTag = parser.next(); |
119 |
tag = parser.getName(); |
120 |
} |
121 |
} |
122 |
return bbox;
|
123 |
} |
124 |
|
125 |
/**
|
126 |
* Parses the tag
|
127 |
* @param parser
|
128 |
* @param handler
|
129 |
* @param tag
|
130 |
* @return
|
131 |
* @throws XmlStreamException
|
132 |
* @throws IOException
|
133 |
*/
|
134 |
protected Object parseTag(IXmlStreamReader parser,GPEDefaultGmlParser handler, QName tag) throws XmlStreamException, IOException{ |
135 |
Object bbox = null; |
136 |
if (CompareUtils.compareWithNamespace(tag,GMLTags.GML_BOX)){
|
137 |
bbox = handler.getProfile().getBoxTypeBinding().parse(parser, handler); |
138 |
} |
139 |
return bbox;
|
140 |
} |
141 |
} |