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