svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wfs / wfs_1_1_0 / WFSFeature1_1_0.java @ 40559
History | View | Annotate | Download (10.1 KB)
1 |
/**
|
---|---|
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 |
package org.gvsig.remoteclient.wfs.wfs_1_1_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_1_0.java 39768 2013-02-20 14:16:29Z jldominguez $
|
84 |
* $Log$
|
85 |
* Revision 1.1 2007-02-09 14:11:01 jorpiell
|
86 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T
|
87 |
*
|
88 |
*
|
89 |
*/
|
90 |
/**
|
91 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
92 |
*/
|
93 |
public class WFSFeature1_1_0 extends WFSFeature{ |
94 |
|
95 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
96 |
|
97 |
public WFSFeature1_1_0(WFSServiceInformation serviceInformation) {
|
98 |
super(serviceInformation);
|
99 |
} |
100 |
|
101 |
WFSFeature1_1_0(WFSServiceInformation serviceInformation, String name) {
|
102 |
super(serviceInformation, name);
|
103 |
} |
104 |
|
105 |
/**
|
106 |
* <p>Parses the contents of the parser(WMSCapabilities)
|
107 |
* to extract the information about an WMSLayer</p>
|
108 |
* @throws IOException
|
109 |
* @throws XmlPullParserException
|
110 |
*
|
111 |
*/
|
112 |
public void parse(KXmlParser parser) throws XmlPullParserException, IOException{ |
113 |
int currentTag;
|
114 |
boolean end = false; |
115 |
|
116 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPE);
|
117 |
|
118 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
119 |
String[] attName = stringUtils.split(parser.getAttributeName(i), ":"); |
120 |
if (attName.length == 2){ |
121 |
if (attName[0].compareTo(GMLTags.XML_NAMESPACE)==0){ |
122 |
XMLNameSpace nameSpace = new XMLNameSpace(attName[1],parser.getAttributeValue(i)); |
123 |
this.setNamespace(nameSpace);
|
124 |
} |
125 |
} |
126 |
} |
127 |
|
128 |
currentTag = parser.next(); |
129 |
while (!end)
|
130 |
{ |
131 |
switch(currentTag)
|
132 |
{ |
133 |
case KXmlParser.START_TAG:
|
134 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.NAME)==0) |
135 |
{ |
136 |
this.setName(parser.nextText());
|
137 |
}else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.TITLE)==0){ |
138 |
this.setTitle(parser.nextText());
|
139 |
}else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.WFS_KEYWORDS)==0){ |
140 |
parser.nextTag(); |
141 |
while (parser.getName().compareTo(CapabilitiesTags.KEYWORD)==0){ |
142 |
parser.next(); |
143 |
String keyword = parser.getText();
|
144 |
if ((keyword != null) || (!(keyword.equals("")))){ |
145 |
this.addKeyword(keyword);
|
146 |
} |
147 |
//Keyword end tag
|
148 |
parser.nextTag(); |
149 |
//Keyword start tag?
|
150 |
parser.nextTag(); |
151 |
} |
152 |
|
153 |
|
154 |
} else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.KEYWORD)==0){ |
155 |
this.addKeyword(parser.nextText());
|
156 |
} else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SRS)==0 |
157 |
|| parser.getName().compareToIgnoreCase(CapabilitiesTags.OTHERSRS)==0){
|
158 |
String value = parser.nextText();
|
159 |
if (value != null){ |
160 |
String[] mySRSs = stringUtils.split(value, " "); |
161 |
for (int i = 0; i < mySRSs.length; i++) { |
162 |
this.addSRS(mySRSs[i]);
|
163 |
} |
164 |
|
165 |
} |
166 |
} else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.DEAFAULTSRS)==0){ |
167 |
String value = parser.nextText();
|
168 |
setDefaultSRS(value.trim()); |
169 |
} else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.LATLONGBOUNDINGBOX)==0){ |
170 |
BoundaryBox bbox = new BoundaryBox();
|
171 |
bbox.setSrs(CapabilitiesTags.EPSG_4326); |
172 |
String value = parser.getAttributeValue("",CapabilitiesTags.MINX); |
173 |
if ((value != null) && (Utilities.isNumber(value))) |
174 |
bbox.setXmin(Double.parseDouble(value));
|
175 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY);
|
176 |
if ((value != null) && (Utilities.isNumber(value))) |
177 |
bbox.setYmin(Double.parseDouble(value));
|
178 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
|
179 |
if ((value != null) && (Utilities.isNumber(value))) |
180 |
bbox.setXmax(Double.parseDouble(value));
|
181 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
|
182 |
if ((value != null) && (Utilities.isNumber(value))) |
183 |
bbox.setYmax(Double.parseDouble(value));
|
184 |
this.addBBox(bbox);
|
185 |
this.setLatLonBbox(bbox);
|
186 |
} else if (parser.getName().compareTo(CapabilitiesTags.BOUNDINGBOX)==0){ |
187 |
BoundaryBox bbox = new BoundaryBox();
|
188 |
String value = parser.getAttributeValue("",CapabilitiesTags.SRS); |
189 |
if (value != null) |
190 |
bbox.setSrs(value); |
191 |
value = parser.getAttributeValue("",CapabilitiesTags.MINX);
|
192 |
if ((value != null) && (Utilities.isNumber(value))) |
193 |
bbox.setXmin(Double.parseDouble(value));
|
194 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY);
|
195 |
if ((value != null) && (Utilities.isNumber(value))) |
196 |
bbox.setYmin(Double.parseDouble(value));
|
197 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX);
|
198 |
if ((value != null) && (Utilities.isNumber(value))) |
199 |
bbox.setXmax(Double.parseDouble(value));
|
200 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY);
|
201 |
if ((value != null) && (Utilities.isNumber(value))) |
202 |
bbox.setYmax(Double.parseDouble(value));
|
203 |
if (bbox.getSrs() != null){ |
204 |
this.addBBox(bbox);
|
205 |
this.addSRS(bbox.getSrs());
|
206 |
} |
207 |
} else if (CapabilitiesTags.WGS84BOUNDINGBOX.equals(parser.getName())){ |
208 |
String lowerCorner = null; |
209 |
String upperCorner = null; |
210 |
parser.next(); |
211 |
String tagName = parser.getName();
|
212 |
while(!CapabilitiesTags.WGS84BOUNDINGBOX.equals(tagName)){
|
213 |
if ((CapabilitiesTags.LOWERCORNER.equals(tagName)) && (KXmlParser.START_TAG == currentTag)){
|
214 |
parser.next(); |
215 |
lowerCorner = parser.getText(); |
216 |
}else if ((CapabilitiesTags.UPPERCORNER.equals(tagName)) && (KXmlParser.START_TAG == currentTag)){ |
217 |
parser.next(); |
218 |
upperCorner = parser.getText(); |
219 |
} |
220 |
currentTag = parser.next(); |
221 |
tagName = parser.getName(); |
222 |
} |
223 |
if ((lowerCorner != null) && (upperCorner != null)){ |
224 |
BoundaryBox bbox = new BoundaryBox();
|
225 |
bbox.setSrs("EPSG:4326");
|
226 |
String[] lowerCoordinates = stringUtils.split(lowerCorner, "[! \t\r\n]"); |
227 |
if (lowerCoordinates.length >= 2){ |
228 |
try{
|
229 |
bbox.setXmin(Double.valueOf(lowerCoordinates[0]).doubleValue()); |
230 |
bbox.setYmin(Double.valueOf(lowerCoordinates[1]).doubleValue()); |
231 |
}catch(NumberFormatException e){ |
232 |
//Is not a number
|
233 |
} |
234 |
} |
235 |
String[] upperCoordinates = stringUtils.split(upperCorner, "[! \t\r\n]"); |
236 |
if (upperCoordinates.length >= 2){ |
237 |
try{
|
238 |
bbox.setXmax(Double.valueOf(upperCoordinates[0]).doubleValue()); |
239 |
bbox.setYmax(Double.valueOf(upperCoordinates[1]).doubleValue()); |
240 |
}catch(NumberFormatException e){ |
241 |
//Is not a number
|
242 |
} |
243 |
} |
244 |
bbox = BoundaryBox.clipGeodeticBBox(bbox); |
245 |
this.addBBox(bbox);
|
246 |
this.setLatLonBbox(bbox);
|
247 |
} |
248 |
} |
249 |
|
250 |
break;
|
251 |
case KXmlParser.END_TAG:
|
252 |
if (parser.getName().compareTo(CapabilitiesTags.WFS_FEATURETYPE) == 0) |
253 |
end = true;
|
254 |
break;
|
255 |
case KXmlParser.TEXT:
|
256 |
break;
|
257 |
} |
258 |
if (!end){
|
259 |
currentTag = parser.next(); |
260 |
} |
261 |
} |
262 |
} |
263 |
} |