svn-gvsig-desktop / branches / v10 / libraries / libRemoteServices / src / org / gvsig / remoteClient / wfs / wfs_1_0_0 / WFSFeature1_0_0.java @ 18302
History | View | Annotate | Download (7.21 KB)
1 |
package org.gvsig.remoteClient.wfs.wfs_1_0_0; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import org.gvsig.remoteClient.gml.GMLTags; |
6 |
import org.gvsig.remoteClient.gml.schemas.XMLNameSpace; |
7 |
import org.gvsig.remoteClient.utils.BoundaryBox; |
8 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
9 |
import org.gvsig.remoteClient.utils.Utilities; |
10 |
import org.gvsig.remoteClient.wfs.WFSFeature; |
11 |
import org.kxml2.io.KXmlParser; |
12 |
import org.xmlpull.v1.XmlPullParserException; |
13 |
|
14 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
15 |
*
|
16 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
17 |
*
|
18 |
* This program is free software; you can redistribute it and/or
|
19 |
* modify it under the terms of the GNU General Public License
|
20 |
* as published by the Free Software Foundation; either version 2
|
21 |
* of the License, or (at your option) any later version.
|
22 |
*
|
23 |
* This program is distributed in the hope that it will be useful,
|
24 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
26 |
* GNU General Public License for more details.
|
27 |
*
|
28 |
* You should have received a copy of the GNU General Public License
|
29 |
* along with this program; if not, write to the Free Software
|
30 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
31 |
*
|
32 |
* For more information, contact:
|
33 |
*
|
34 |
* Generalitat Valenciana
|
35 |
* Conselleria d'Infraestructures i Transport
|
36 |
* Av. Blasco Ib??ez, 50
|
37 |
* 46010 VALENCIA
|
38 |
* SPAIN
|
39 |
*
|
40 |
* +34 963862235
|
41 |
* gvsig@gva.es
|
42 |
* www.gvsig.gva.es
|
43 |
*
|
44 |
* or
|
45 |
*
|
46 |
* IVER T.I. S.A
|
47 |
* Salamanca 50
|
48 |
* 46005 Valencia
|
49 |
* Spain
|
50 |
*
|
51 |
* +34 963163400
|
52 |
* dac@iver.es
|
53 |
*/
|
54 |
/* CVS MESSAGES:
|
55 |
*
|
56 |
* $Id: WFSFeature1_0_0.java 13912 2007-09-20 09:33:50Z jaume $
|
57 |
* $Log$
|
58 |
* Revision 1.8 2007-09-20 09:30:12 jaume
|
59 |
* removed unnecessary imports
|
60 |
*
|
61 |
* Revision 1.7 2007/02/09 14:11:01 jorpiell
|
62 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T
|
63 |
*
|
64 |
* Revision 1.6 2006/07/12 06:23:31 jorpiell
|
65 |
* Soportados tipos m?s complejos
|
66 |
*
|
67 |
* Revision 1.5 2006/06/15 09:05:06 jorpiell
|
68 |
* Actualizados los WFS
|
69 |
*
|
70 |
* Revision 1.4 2006/05/23 13:23:22 jorpiell
|
71 |
* Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource
|
72 |
*
|
73 |
* Revision 1.2 2006/04/20 16:39:16 jorpiell
|
74 |
* A?adida la operacion de describeFeatureType y el parser correspondiente.
|
75 |
*
|
76 |
* Revision 1.1 2006/04/19 12:51:35 jorpiell
|
77 |
* A?adidas algunas de las clases del servicio WFS
|
78 |
*
|
79 |
*
|
80 |
*/
|
81 |
/**
|
82 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
83 |
*/
|
84 |
public class WFSFeature1_0_0 extends WFSFeature{ |
85 |
|
86 |
public WFSFeature1_0_0() {
|
87 |
|
88 |
} |
89 |
|
90 |
public WFSFeature1_0_0(String name) { |
91 |
super(name);
|
92 |
} |
93 |
|
94 |
/**
|
95 |
* <p>Parses the contents of the parser(WMSCapabilities)
|
96 |
* to extract the information about an WMSLayer</p>
|
97 |
* @throws IOException
|
98 |
* @throws XmlPullParserException
|
99 |
*
|
100 |
*/
|
101 |
public void parse(KXmlParser parser) throws XmlPullParserException, IOException{ |
102 |
int currentTag;
|
103 |
boolean end = false; |
104 |
|
105 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPE);
|
106 |
|
107 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
108 |
String[] attName = parser.getAttributeName(i).split(":"); |
109 |
if (attName.length == 2){ |
110 |
if (attName[0].compareTo(GMLTags.XML_NAMESPACE)==0){ |
111 |
XMLNameSpace nameSpace = new XMLNameSpace(attName[1],parser.getAttributeValue(i)); |
112 |
this.setNamespace(nameSpace);
|
113 |
} |
114 |
} |
115 |
} |
116 |
|
117 |
currentTag = parser.next(); |
118 |
while (!end)
|
119 |
{ |
120 |
switch(currentTag)
|
121 |
{ |
122 |
case KXmlParser.START_TAG:
|
123 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.NAME)==0) |
124 |
{ |
125 |
this.setName(parser.nextText());
|
126 |
} |
127 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.TITLE)==0) |
128 |
{ |
129 |
this.setTitle(parser.nextText());
|
130 |
} |
131 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.WFS_KEYWORDS)==0) |
132 |
{ |
133 |
String keyword = parser.nextText();
|
134 |
if ((keyword != null) || (!(keyword.equals("")))){ |
135 |
this.addKeyword(keyword);
|
136 |
} |
137 |
} |
138 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.KEYWORD)==0) |
139 |
{ |
140 |
this.addKeyword(parser.nextText());
|
141 |
} |
142 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SRS)==0) |
143 |
{ |
144 |
String value = parser.nextText();
|
145 |
if (value != null){ |
146 |
String[] mySRSs = value.split(" "); |
147 |
for (int i = 0; i < mySRSs.length; i++) { |
148 |
this.addSRS(mySRSs[i]);
|
149 |
} |
150 |
|
151 |
} |
152 |
} |
153 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.LATLONGBOUNDINGBOX)==0) |
154 |
{ |
155 |
BoundaryBox bbox = new BoundaryBox();
|
156 |
bbox.setSrs(CapabilitiesTags.EPSG_4326); |
157 |
String value = parser.getAttributeValue("",CapabilitiesTags.MINX); |
158 |
if ((value != null) && (Utilities.isNumber(value))) |
159 |
bbox.setXmin(Double.parseDouble(value));
|
160 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY);
|
161 |
if ((value != null) && (Utilities.isNumber(value))) |
162 |
bbox.setYmin(Double.parseDouble(value));
|
163 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
|
164 |
if ((value != null) && (Utilities.isNumber(value))) |
165 |
bbox.setXmax(Double.parseDouble(value));
|
166 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
|
167 |
if ((value != null) && (Utilities.isNumber(value))) |
168 |
bbox.setYmax(Double.parseDouble(value));
|
169 |
this.addBBox(bbox);
|
170 |
this.setLatLonBbox(bbox);
|
171 |
} |
172 |
if (parser.getName().compareTo(CapabilitiesTags.BOUNDINGBOX)==0) |
173 |
{ |
174 |
BoundaryBox bbox = new BoundaryBox();
|
175 |
String value = parser.getAttributeValue("",CapabilitiesTags.SRS); |
176 |
if (value != null) |
177 |
bbox.setSrs(value); |
178 |
value = parser.getAttributeValue("",CapabilitiesTags.MINX);
|
179 |
if ((value != null) && (Utilities.isNumber(value))) |
180 |
bbox.setXmin(Double.parseDouble(value));
|
181 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY);
|
182 |
if ((value != null) && (Utilities.isNumber(value))) |
183 |
bbox.setYmin(Double.parseDouble(value));
|
184 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
|
185 |
if ((value != null) && (Utilities.isNumber(value))) |
186 |
bbox.setXmax(Double.parseDouble(value));
|
187 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
|
188 |
if ((value != null) && (Utilities.isNumber(value))) |
189 |
bbox.setYmax(Double.parseDouble(value));
|
190 |
if (bbox.getSrs() != null){ |
191 |
this.addBBox(bbox);
|
192 |
this.addSRS(bbox.getSrs());
|
193 |
} |
194 |
} |
195 |
|
196 |
break;
|
197 |
case KXmlParser.END_TAG:
|
198 |
if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPE) == 0) |
199 |
end = true;
|
200 |
break;
|
201 |
case KXmlParser.TEXT:
|
202 |
break;
|
203 |
} |
204 |
if (!end){
|
205 |
currentTag = parser.next(); |
206 |
} |
207 |
} |
208 |
} |
209 |
} |