root / org.gvsig.gpe / library / trunk / org.gvsig.gpe / org.gvsig.gpe.prov / org.gvsig.gpe.prov.gml / src / main / java / org / gvsig / gpe / prov / gml / parser / v2 / geometries / MultiLineStringTypeBinding.java @ 264
History | View | Annotate | Download (4.47 KB)
1 |
package org.gvsig.gpe.prov.gml.parser.v2.geometries; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import org.gvsig.gpe.prov.gml.parser.GPEDefaultGmlParser; |
6 |
import org.gvsig.gpe.prov.gml.utils.GmlTags; |
7 |
import org.gvsig.xmlpull.lib.api.stream.IQName; |
8 |
import org.gvsig.xmlpull.lib.api.stream.IXmlStreamReader; |
9 |
import org.gvsig.xmlpull.lib.api.stream.XmlStreamException; |
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:MultiLineStringTypeBinding.java 371 2008-01-10 09:30:19Z jpiera $
|
54 |
* $Log$
|
55 |
* Revision 1.1 2007/05/15 07:30:38 jorpiell
|
56 |
* Add the geometryProperties tags
|
57 |
*
|
58 |
* Revision 1.5 2007/05/14 11:18:51 jorpiell
|
59 |
* ProjectionFactory updated
|
60 |
*
|
61 |
* Revision 1.4 2007/05/14 09:52:53 jorpiell
|
62 |
* Nullpointer exception fixed
|
63 |
*
|
64 |
* Revision 1.3 2007/05/14 09:31:06 jorpiell
|
65 |
* Add the a new class to compare tags
|
66 |
*
|
67 |
* Revision 1.2 2007/05/08 10:24:16 jorpiell
|
68 |
* Add comments to create javadocs
|
69 |
*
|
70 |
* Revision 1.1 2007/05/07 12:58:42 jorpiell
|
71 |
* Add some methods to manage the multigeometries
|
72 |
*
|
73 |
*
|
74 |
*/
|
75 |
/**
|
76 |
* It parses a gml:MultiLineStringType object. Example:
|
77 |
* <p>
|
78 |
* <pre>
|
79 |
* <code>
|
80 |
* <MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
|
81 |
* <lineStringMember>
|
82 |
* <LineString>
|
83 |
* <coord><X>56.1</X><Y>0.45</Y></coord>
|
84 |
* <coord><X>67.23</X><Y>0.98</Y></coord>
|
85 |
* </LineString>
|
86 |
* </lineStringMember>
|
87 |
* <lineStringMember>
|
88 |
* <LineString>
|
89 |
* <coord><X>46.71</X><Y>9.25</Y></coord>
|
90 |
* <coord><X>56.88</X><Y>10.44</Y></coord>
|
91 |
* </LineString>
|
92 |
* </lineStringMember>
|
93 |
* </MultiLineString>
|
94 |
* </code>
|
95 |
* </pre>
|
96 |
* </p>
|
97 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
98 |
*/
|
99 |
public class MultiLineStringTypeBinding extends GeometryBinding{ |
100 |
|
101 |
/**
|
102 |
* It parses the gml:MultiLineQName tag
|
103 |
* @param parser
|
104 |
* The XML parser
|
105 |
* @param handler
|
106 |
* The GPE parser that contains the content handler and
|
107 |
* the error handler
|
108 |
* @return
|
109 |
* A multilinestring
|
110 |
* @throws XmlStreamException
|
111 |
*/
|
112 |
public Object parse(IXmlStreamReader parser,GPEDefaultGmlParser handler) throws XmlStreamException, IOException { |
113 |
boolean endFeature = false; |
114 |
int currentTag;
|
115 |
Object multiLineString = null; |
116 |
|
117 |
super.setAtributtes(parser, handler);
|
118 |
|
119 |
multiLineString = |
120 |
handler.getContentHandler().startMultiLineString(id, srsName); |
121 |
|
122 |
IQName tag = parser.getName(); |
123 |
currentTag = parser.getEventType(); |
124 |
|
125 |
while (!endFeature){
|
126 |
switch(currentTag){
|
127 |
case IXmlStreamReader.START_ELEMENT:
|
128 |
if (handler.getQNameComparator().equals(tag,GmlTags.GML_LINESTRINGMEMBER)){
|
129 |
Object lineString = handler.getProfile().getLineStringMemberTypeBinding().
|
130 |
parse(parser, handler); |
131 |
handler.getContentHandler().addLineStringToMultiLineString(lineString, multiLineString); |
132 |
} |
133 |
break;
|
134 |
case IXmlStreamReader.END_ELEMENT:
|
135 |
if (handler.getQNameComparator().equals(tag,GmlTags.GML_MULTILINESTRING)){
|
136 |
endFeature = true;
|
137 |
multiLineString = handler.getContentHandler().endMultiLineString(multiLineString); |
138 |
} |
139 |
break;
|
140 |
case IXmlStreamReader.CHARACTERS:
|
141 |
|
142 |
break;
|
143 |
} |
144 |
if (!endFeature){
|
145 |
currentTag = parser.next(); |
146 |
tag = parser.getName(); |
147 |
} |
148 |
} |
149 |
return multiLineString;
|
150 |
} |
151 |
} |