root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / fmap / layers / FLyrWFS.java @ 8812
History | View | Annotate | Download (18.7 KB)
1 |
package com.iver.cit.gvsig.fmap.layers; |
---|---|
2 |
|
3 |
import java.awt.geom.Rectangle2D; |
4 |
import java.io.IOException; |
5 |
import java.net.ConnectException; |
6 |
import java.net.MalformedURLException; |
7 |
import java.net.URL; |
8 |
import java.util.ArrayList; |
9 |
import java.util.HashMap; |
10 |
import java.util.Map; |
11 |
import java.util.Vector; |
12 |
|
13 |
import javax.swing.ImageIcon; |
14 |
|
15 |
import org.gvsig.remoteClient.gml.schemas.IXMLType; |
16 |
import org.gvsig.remoteClient.gml.schemas.XMLComplexType; |
17 |
import org.gvsig.remoteClient.gml.schemas.XMLElement; |
18 |
import org.gvsig.remoteClient.wfs.WFSStatus; |
19 |
import org.gvsig.remoteClient.wfs.filters.FilterEncoding; |
20 |
|
21 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
22 |
import com.iver.andami.PluginServices; |
23 |
import com.iver.cit.gvsig.fmap.DriverException; |
24 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
25 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
26 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver; |
27 |
import com.iver.cit.gvsig.fmap.drivers.WFSException; |
28 |
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver; |
29 |
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriverFactory; |
30 |
import com.iver.cit.gvsig.fmap.drivers.wfs.WFSUtils; |
31 |
import com.iver.cit.gvsig.fmap.drivers.wfs.filters.SQLExpressionFormat; |
32 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
33 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
34 |
import com.iver.utiles.StringUtilities; |
35 |
import com.iver.utiles.XMLEntity; |
36 |
|
37 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
38 |
*
|
39 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
40 |
*
|
41 |
* This program is free software; you can redistribute it and/or
|
42 |
* modify it under the terms of the GNU General Public License
|
43 |
* as published by the Free Software Foundation; either version 2
|
44 |
* of the License, or (at your option) any later version.
|
45 |
*
|
46 |
* This program is distributed in the hope that it will be useful,
|
47 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
48 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
49 |
* GNU General Public License for more details.
|
50 |
*
|
51 |
* You should have received a copy of the GNU General Public License
|
52 |
* along with this program; if not, write to the Free Software
|
53 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
54 |
*
|
55 |
* For more information, contact:
|
56 |
*
|
57 |
* Generalitat Valenciana
|
58 |
* Conselleria d'Infraestructures i Transport
|
59 |
* Av. Blasco Ib??ez, 50
|
60 |
* 46010 VALENCIA
|
61 |
* SPAIN
|
62 |
*
|
63 |
* +34 963862235
|
64 |
* gvsig@gva.es
|
65 |
* www.gvsig.gva.es
|
66 |
*
|
67 |
* or
|
68 |
*
|
69 |
* IVER T.I. S.A
|
70 |
* Salamanca 50
|
71 |
* 46005 Valencia
|
72 |
* Spain
|
73 |
*
|
74 |
* +34 963163400
|
75 |
* dac@iver.es
|
76 |
*/
|
77 |
/* CVS MESSAGES:
|
78 |
*
|
79 |
* $Id: FLyrWFS.java 8812 2006-11-16 13:29:47Z jorpiell $
|
80 |
* $Log$
|
81 |
* Revision 1.20 2006-11-16 13:29:47 jorpiell
|
82 |
* Se ha reescrito losl m?todo para guardar y recuperar gvps
|
83 |
*
|
84 |
* Revision 1.19 2006/11/15 17:38:08 jorpiell
|
85 |
* Ya se puede guardar una capa en WFS.
|
86 |
*
|
87 |
* Revision 1.18 2006/10/31 12:24:04 jorpiell
|
88 |
* Comprobado el caso en el que los atributos no tienen tipo
|
89 |
*
|
90 |
* Revision 1.17 2006/10/31 09:55:28 jorpiell
|
91 |
* Se ha modificado el constructor del WFS desde cat?logo
|
92 |
*
|
93 |
* Revision 1.16 2006/10/31 09:38:15 jorpiell
|
94 |
* Se ha creado una factoria para crear la capa. De ese modo no se repite c?digo desde le panel de propiedades y desde el panel de la capa
|
95 |
*
|
96 |
* Revision 1.15 2006/10/23 07:37:04 jorpiell
|
97 |
* Ya funciona el filterEncoding
|
98 |
*
|
99 |
* Revision 1.14 2006/10/10 12:55:06 jorpiell
|
100 |
* Se ha a?adido el soporte de features complejas
|
101 |
*
|
102 |
* Revision 1.13 2006/10/02 12:54:35 jorpiell
|
103 |
* No se pod?a crear un mapa que tubiera la opci?n enlace vivo habilitada
|
104 |
*
|
105 |
* Revision 1.12 2006/10/02 09:09:45 jorpiell
|
106 |
* Cambios del 10 copiados al head
|
107 |
*
|
108 |
* Revision 1.10.2.3 2006/09/29 14:12:53 luisw2
|
109 |
* CRSFactory.getCRS substitutes ProjectionPool.get
|
110 |
*
|
111 |
* Revision 1.10.2.2 2006/09/28 08:54:01 jorpiell
|
112 |
* Ya se puede reproyectar
|
113 |
*
|
114 |
* Revision 1.10.2.1 2006/09/26 07:36:24 jorpiell
|
115 |
* El WFS no reproyectaba porque no se le asignaba a la capa un sistema de referencia. Ahora ya se hace.
|
116 |
*
|
117 |
* Revision 1.10 2006/09/05 15:41:52 jorpiell
|
118 |
* A?adida la funcionalidad de cargar WFS desde el cat?logo
|
119 |
*
|
120 |
* Revision 1.9 2006/07/05 12:05:41 jorpiell
|
121 |
* Se ha modificado para que avise si se han recuperado las mismas features que marca el campo buffer
|
122 |
*
|
123 |
* Revision 1.8 2006/06/21 12:52:10 jorpiell
|
124 |
* A?adido un icono para la capa WFS
|
125 |
*
|
126 |
* Revision 1.7 2006/06/21 12:35:45 jorpiell
|
127 |
* Se ha a?adido la ventana de propiedades. Esto implica a?adir listeners por todos los paneles. Adem?s no se muestra la geomatr?a en la lista de atributos y se muestran ?nicamnete los que se van a descargar
|
128 |
*
|
129 |
* Revision 1.6 2006/06/15 11:17:06 jorpiell
|
130 |
* Se ha encontrado la forma de comprobar cuando se prodicia un error de parseo al hacer un hasnext (en la feature). Se atrapa y se lanza la excepci?n hacia arriba
|
131 |
*
|
132 |
* Revision 1.5 2006/06/14 07:57:19 jorpiell
|
133 |
* Ya no se usa la estrategia ni se usa geotools para hacer el getFeature. Ahora se usa ?nicamente para el parseo de GML
|
134 |
*
|
135 |
* Revision 1.4 2006/06/05 16:49:31 caballero
|
136 |
* poder editar y exportar
|
137 |
*
|
138 |
* Revision 1.3 2006/05/25 10:31:55 jorpiell
|
139 |
* Se ha renombrado la clase WFSFields por WFSAttributes porque era algo confusa
|
140 |
*
|
141 |
* Revision 1.2 2006/05/23 13:21:59 jorpiell
|
142 |
* Si hay alg?n problema en la carga se muestra un mensaje de error
|
143 |
*
|
144 |
* Revision 1.1 2006/05/19 12:54:11 jorpiell
|
145 |
* Creada la capa WFS
|
146 |
*
|
147 |
*
|
148 |
*/
|
149 |
/**
|
150 |
* FMap's WFS Layer class.
|
151 |
*
|
152 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
153 |
*/
|
154 |
public class FLyrWFS extends FLyrVect{ |
155 |
private URL host = null; |
156 |
private String onlineResource = null; |
157 |
private String name = null; |
158 |
private String layerName = null; |
159 |
private String userName = null; |
160 |
private String password = null; |
161 |
private String AttributesQuery = null; |
162 |
private String CoordinatesQuery = null; |
163 |
private XMLElement[] fields = null; |
164 |
private int numfeatures = 100; |
165 |
private int timeout = 10000; |
166 |
private String srs = null; |
167 |
private FMapWFSDriver wfsDriver = null; |
168 |
private WFSLayerNode wfsLayerNode = null; |
169 |
|
170 |
/**
|
171 |
* Constructor
|
172 |
*/
|
173 |
public FLyrWFS(){
|
174 |
super();
|
175 |
} |
176 |
|
177 |
/**
|
178 |
* Constructor to load a new layer from a catalog
|
179 |
* search
|
180 |
* @param args
|
181 |
* Params to load a new layer
|
182 |
* @throws WFSException
|
183 |
* @throws IOException
|
184 |
* @throws MalformedURLException
|
185 |
* @throws ConnectException
|
186 |
* @throws DriverIOException
|
187 |
*/
|
188 |
public FLyrWFS(Map args) throws WFSException, ConnectException, MalformedURLException, IOException, DriverIOException{ |
189 |
String[] sLayer = (String[])args.get("layer"); |
190 |
String user = (String)args.get("user"); |
191 |
String pwd = (String)args.get("pwd"); |
192 |
String host = (String)args.get("host"); |
193 |
String projection = (String)args.get("projection"); |
194 |
|
195 |
FMapWFSDriver driver = FMapWFSDriverFactory.getFMapDriverForURL(new URL(host)); |
196 |
WFSLayerNode[] layers = driver.getLayerList();
|
197 |
WFSLayerNode layer = driver.getLayerInfo(sLayer[0]);
|
198 |
|
199 |
layer.setSelectedFields(layer.getFields()); |
200 |
|
201 |
Vector vAtts = new Vector(); |
202 |
if (layer.getFields().size() == 1){ |
203 |
XMLElement element = (XMLElement)layer.getFields().get(0);
|
204 |
if (element.getEntityType().getType() != IXMLType.COMPLEX){
|
205 |
vAtts.add(element); |
206 |
}else{
|
207 |
vAtts = ((XMLComplexType)element.getEntityType()).getAttributes(); |
208 |
} |
209 |
} |
210 |
for (int i=0 ; i<layer.getFields().size() ; i++){ |
211 |
XMLElement element = (XMLElement)layer.getFields().get(i); |
212 |
if (element.getEntityType().getType() != IXMLType.COMPLEX){
|
213 |
vAtts.add((XMLElement)layer.getFields().get(i)); |
214 |
}else{
|
215 |
|
216 |
} |
217 |
} |
218 |
|
219 |
XMLElement[] atts = new XMLElement[vAtts.size()]; |
220 |
for (int i=0 ; i<vAtts.size() ; i++){ |
221 |
atts[i] = (XMLElement)vAtts.get(i); |
222 |
} |
223 |
|
224 |
setHost(host); |
225 |
setName(sLayer[0]);
|
226 |
setLayerName(sLayer[0]);
|
227 |
setWfsLayerNode(layer); |
228 |
setFields(atts); |
229 |
setUserName(user); |
230 |
setPassword(pwd); |
231 |
setNumfeatures(10000);
|
232 |
setTimeout(10000);
|
233 |
setWfsDriver(driver); |
234 |
setProjection(CRSFactory.getCRS(projection)); |
235 |
|
236 |
load(); |
237 |
} |
238 |
|
239 |
|
240 |
/**
|
241 |
* Loads the features from the server
|
242 |
*/
|
243 |
public void load() throws DriverIOException{ |
244 |
WFSAdapter adapter = new WFSAdapter();
|
245 |
try {
|
246 |
wfsDriver.getFeature(getWFSStatus()); |
247 |
|
248 |
adapter.setDriver((VectorialDriver) wfsDriver); |
249 |
setSource(adapter); |
250 |
|
251 |
if (getLegend() == null){ |
252 |
setLegend(LegendFactory.createSingleSymbolLegend( |
253 |
getShapeType())); |
254 |
} |
255 |
} catch (Exception e){ |
256 |
e.printStackTrace(); |
257 |
throw new DriverIOException(e.getMessage()); |
258 |
} |
259 |
} |
260 |
|
261 |
/**
|
262 |
* Gets the WFS Status
|
263 |
* @return
|
264 |
*/
|
265 |
private WFSStatus getWFSStatus(){
|
266 |
WFSStatus status = new WFSStatus(getLayerName());
|
267 |
status.setUserName(getUserName()); |
268 |
status.setPassword(getPassword()); |
269 |
status.setBuffer(getNumfeatures()); |
270 |
status.setTimeout(getTimeout()); |
271 |
status.setFields(getFieldNames()); |
272 |
status.setOnlineResource(getOnlineResource()); |
273 |
status.setSrs(getSrs()); |
274 |
//Filter Encoding transformation
|
275 |
FilterEncoding fe = SQLExpressionFormat.createFilter(); |
276 |
fe.setQuery(getAttributesQuery()); |
277 |
status.setFilterQuery(fe.toString()); |
278 |
return status;
|
279 |
} |
280 |
|
281 |
/**
|
282 |
* @return Returns the layerName.
|
283 |
*/
|
284 |
public String getLayerName() { |
285 |
return layerName;
|
286 |
} |
287 |
/**
|
288 |
* @param layerName The layerName to set.
|
289 |
*/
|
290 |
public void setLayerName(String layerName) { |
291 |
this.layerName = layerName;
|
292 |
} |
293 |
/**
|
294 |
* @return Returns the numfeatures.
|
295 |
*/
|
296 |
public int getNumfeatures() { |
297 |
return numfeatures;
|
298 |
} |
299 |
/**
|
300 |
* @param numfeatures The numfeatures to set.
|
301 |
*/
|
302 |
public void setNumfeatures(int numfeatures) { |
303 |
this.numfeatures = numfeatures;
|
304 |
} |
305 |
|
306 |
/**
|
307 |
* @return Returns the pwd.
|
308 |
*/
|
309 |
public String getPassword() { |
310 |
return password;
|
311 |
} |
312 |
/**
|
313 |
* @param pwd The pwd to set.
|
314 |
*/
|
315 |
public void setPassword(String password) { |
316 |
this.password = password;
|
317 |
} |
318 |
/**
|
319 |
* @return Returns the timeout.
|
320 |
*/
|
321 |
public int getTimeout() { |
322 |
return timeout;
|
323 |
} |
324 |
/**
|
325 |
* @param timeout The timeout to set.
|
326 |
*/
|
327 |
public void setTimeout(int timeout) { |
328 |
this.timeout = timeout;
|
329 |
} |
330 |
/**
|
331 |
* @return Returns the user.
|
332 |
*/
|
333 |
public String getUserName() { |
334 |
return userName;
|
335 |
} |
336 |
/**
|
337 |
* @param user The user to set.
|
338 |
*/
|
339 |
public void setUserName(String userName) { |
340 |
this.userName = userName;
|
341 |
} |
342 |
/**
|
343 |
* @return Returns the fields.
|
344 |
*/
|
345 |
public XMLElement[] getFields() { |
346 |
if (fields == null){ |
347 |
return new XMLElement[0]; |
348 |
} |
349 |
return fields;
|
350 |
} |
351 |
|
352 |
/**
|
353 |
* Return the attributes name
|
354 |
* @return
|
355 |
*/
|
356 |
public String[] getFieldNames(){ |
357 |
Vector vAttributes = new Vector(); |
358 |
for (int i=0 ; i<getFields().length ; i++){ |
359 |
if ((getFields()[i].getEntityType() == null) || |
360 |
(getFields()[i].getEntityType().getType() != IXMLType.COMPLEX)){ |
361 |
vAttributes.add(getFields()[i].getName()); |
362 |
} |
363 |
} |
364 |
String[] attributes = new String[vAttributes.size()]; |
365 |
for (int i=0 ; i<vAttributes.size() ; i++){ |
366 |
attributes[i] = (String)vAttributes.get(i);
|
367 |
} |
368 |
return attributes;
|
369 |
} |
370 |
|
371 |
/**
|
372 |
* @param fields The fields to set.
|
373 |
*/
|
374 |
public void setFields(XMLElement[] fields) { |
375 |
this.fields = fields;
|
376 |
} |
377 |
/**
|
378 |
* @return Returns the name.
|
379 |
*/
|
380 |
public String getName() { |
381 |
return name;
|
382 |
} |
383 |
/**
|
384 |
* @param name The name to set.
|
385 |
*/
|
386 |
public void setName(String name) { |
387 |
this.name = name;
|
388 |
} |
389 |
/**
|
390 |
* @return Returns the host.
|
391 |
*/
|
392 |
public URL getHost() { |
393 |
return host;
|
394 |
} |
395 |
/**
|
396 |
* @param host The host to set.
|
397 |
*/
|
398 |
public void setHost(URL host) { |
399 |
this.host = host;
|
400 |
} |
401 |
|
402 |
/**
|
403 |
* @return Returns the wfs.
|
404 |
*/
|
405 |
public FMapWFSDriver getWfsDriver() {
|
406 |
return wfsDriver;
|
407 |
} |
408 |
|
409 |
/**
|
410 |
* @param wfs The wfs to set.
|
411 |
*/
|
412 |
public void setWfsDriver(FMapWFSDriver wfs) { |
413 |
this.wfsDriver = wfs;
|
414 |
} |
415 |
|
416 |
|
417 |
/*
|
418 |
* (non-Javadoc)
|
419 |
* @see com.iver.cit.gvsig.fmap.layers.FLyrDefault#getStrategy()
|
420 |
*/
|
421 |
// public Strategy getStrategy() {
|
422 |
// if (wfsStrategy == null){
|
423 |
// wfsStrategy = new WFSStrategy(this);
|
424 |
// }
|
425 |
// return wfsStrategy;
|
426 |
// }
|
427 |
|
428 |
/*
|
429 |
* (non-Javadoc)
|
430 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent()
|
431 |
*/
|
432 |
public Rectangle2D getFullExtent() throws DriverException { |
433 |
try {
|
434 |
Rectangle2D extent = wfsDriver.getFullExtent();
|
435 |
if (getCoordTrans() != null){ |
436 |
return getCoordTrans().convert(extent);
|
437 |
} |
438 |
return extent;
|
439 |
} catch (IOException e) { |
440 |
throw new DriverException(e.toString()); |
441 |
} |
442 |
} |
443 |
|
444 |
/**
|
445 |
* @return Returns the onlineResource.
|
446 |
*/
|
447 |
public String getOnlineResource() { |
448 |
return onlineResource;
|
449 |
} |
450 |
|
451 |
/**
|
452 |
* @param onlineResource The onlineResource to set.
|
453 |
*/
|
454 |
public void setOnlineResource(String onlineResource) { |
455 |
this.onlineResource = onlineResource;
|
456 |
} |
457 |
|
458 |
public HashMap getProperties() { |
459 |
HashMap info = new HashMap(); |
460 |
info.put("name", getName());
|
461 |
info.put("layerName", getLayerName());
|
462 |
info.put("layerText", getLayerText());
|
463 |
info.put("attributes", getFields());
|
464 |
info.put("host", getHost());
|
465 |
info.put("wfsLayerNode", getWfsLayerNode());
|
466 |
WFSStatus status = new WFSStatus(getLayerName());
|
467 |
status.setBuffer(getNumfeatures()); |
468 |
status.setTimeout(getTimeout()); |
469 |
status.setUserName(getUserName()); |
470 |
status.setPassword(getPassword()); |
471 |
info.put("status",status);
|
472 |
return info;
|
473 |
|
474 |
} |
475 |
|
476 |
/**
|
477 |
* @return Returns the wfsLayerNode.
|
478 |
*/
|
479 |
public WFSLayerNode getWfsLayerNode() {
|
480 |
return wfsLayerNode;
|
481 |
} |
482 |
|
483 |
/**
|
484 |
* @param wfsLayerNode The wfsLayerNode to set.
|
485 |
*/
|
486 |
public void setWfsLayerNode(WFSLayerNode wfsLayerNode) { |
487 |
this.wfsLayerNode = wfsLayerNode;
|
488 |
} |
489 |
|
490 |
public void setHost(String host2) { |
491 |
try {
|
492 |
setHost(new URL(host2)); |
493 |
} catch (MalformedURLException e) { |
494 |
// TODO Auto-generated catch block
|
495 |
e.printStackTrace(); |
496 |
} |
497 |
} |
498 |
|
499 |
public ImageIcon getTocImageIcon() { |
500 |
return new ImageIcon(PluginServices.getPluginServices("com.iver.cit.gvsig.wfs2").getClassLoader().getResource("images/icoLayer.png")); |
501 |
} |
502 |
|
503 |
/*
|
504 |
* (non-Javadoc)
|
505 |
* @see com.iver.cit.gvsig.fmap.layers.FLyrVect#isPropertiesMenuVisible()
|
506 |
*/
|
507 |
public boolean isPropertiesMenuVisible(){ |
508 |
return false; |
509 |
} |
510 |
|
511 |
public String getSrs() { |
512 |
return srs;
|
513 |
} |
514 |
|
515 |
public void setSrs(String srs) { |
516 |
this.srs = srs;
|
517 |
} |
518 |
|
519 |
/**
|
520 |
* @return XMLEntity.
|
521 |
* @throws XMLException
|
522 |
*/
|
523 |
public XMLEntity getXMLEntity() throws XMLException { |
524 |
XMLEntity xml = super.getXMLEntity();
|
525 |
|
526 |
// Full extent
|
527 |
try {
|
528 |
xml.putProperty("fullExtent", StringUtilities.rect2String(getFullExtent()));
|
529 |
} catch (DriverException e) {
|
530 |
// TODO Auto-generated catch block
|
531 |
e.printStackTrace(); |
532 |
} |
533 |
|
534 |
// Host
|
535 |
xml.putProperty("host", host.toExternalForm());
|
536 |
|
537 |
// Layer name
|
538 |
xml.putProperty("layerName", getLayerName());
|
539 |
xml.putProperty("name", getName());
|
540 |
|
541 |
//Layer fields
|
542 |
XMLElement[] fields = getFields();
|
543 |
String strFields = ""; |
544 |
for (int i=0 ; i<fields.length ; i++){ |
545 |
//If is not the root node
|
546 |
if (fields[i].getParentElement() != null){ |
547 |
strFields = strFields + fields[i].getFullName(); |
548 |
if (i < fields.length - 1){ |
549 |
strFields = strFields + "~##SEP1##~";
|
550 |
} |
551 |
}else{
|
552 |
xml.putProperty("rootNode", true); |
553 |
} |
554 |
} |
555 |
xml.putProperty("fields", strFields);
|
556 |
|
557 |
// User name
|
558 |
xml.putProperty("user", getUserName());
|
559 |
|
560 |
// SRS
|
561 |
xml.putProperty("srs", getSrs());
|
562 |
|
563 |
// OnlineResources
|
564 |
xml.putProperty("onlineResource", getOnlineResource());
|
565 |
|
566 |
// TimeOut
|
567 |
xml.putProperty("timeout", getTimeout());
|
568 |
|
569 |
// Buffer
|
570 |
xml.putProperty("buffer", getNumfeatures());
|
571 |
|
572 |
//Projection
|
573 |
xml.putProperty("projection",getProjection().getAbrev());
|
574 |
|
575 |
return xml;
|
576 |
} |
577 |
|
578 |
/**
|
579 |
* @param xml XMLEntity
|
580 |
*
|
581 |
* @throws XMLException
|
582 |
* @throws DriverException
|
583 |
* @throws DriverI OException
|
584 |
*/
|
585 |
public void setXMLEntity(XMLEntity xml)throws XMLException { |
586 |
|
587 |
// Host
|
588 |
try {
|
589 |
host = new URL(xml.getStringProperty("host")); |
590 |
} catch (MalformedURLException e) { |
591 |
throw new XMLException(e); |
592 |
} |
593 |
|
594 |
// Layer name
|
595 |
setLayerName(xml.getStringProperty("layerName"));
|
596 |
setName(xml.getStringProperty("name"));
|
597 |
|
598 |
// User name
|
599 |
if (xml.contains("user")){ |
600 |
setUserName(xml.getStringProperty("user"));
|
601 |
} |
602 |
|
603 |
// SRS
|
604 |
if (xml.contains("srs")){ |
605 |
setSrs(xml.getStringProperty("srs"));
|
606 |
} |
607 |
|
608 |
// OnlineResources
|
609 |
if (xml.contains("onlineResource")){ |
610 |
setOnlineResource(xml.getStringProperty("onlineResource"));
|
611 |
} |
612 |
|
613 |
// TimeOut
|
614 |
if (xml.contains("timeout")){ |
615 |
setTimeout(xml.getIntProperty("timeout"));
|
616 |
} |
617 |
|
618 |
// Buffer
|
619 |
if (xml.contains("buffer")){ |
620 |
setNumfeatures(xml.getIntProperty("buffer"));
|
621 |
} |
622 |
|
623 |
//Projection
|
624 |
if (xml.contains("projection")){ |
625 |
setProjection(CRSFactory.getCRS(xml.getStringProperty("projection")));
|
626 |
} |
627 |
|
628 |
// Layer fields
|
629 |
FMapWFSDriver driver; |
630 |
try {
|
631 |
driver = FMapWFSDriverFactory.getFMapDriverForURL(host); |
632 |
setWfsDriver(driver); |
633 |
WFSAdapter adapter = new WFSAdapter();
|
634 |
adapter.setDriver((VectorialDriver) wfsDriver); |
635 |
setSource(adapter); |
636 |
super.setXMLEntity(xml);
|
637 |
setLegend(LegendFactory.createFromXML(xml.getChild(0)));
|
638 |
} catch (Exception e) { |
639 |
throw new XMLException(e); |
640 |
} |
641 |
driver.getLayerList(); |
642 |
WFSLayerNode layer = driver.getLayerInfo(getLayerName()); |
643 |
XMLElement[] atts = null; |
644 |
|
645 |
// The root element always exists
|
646 |
XMLElement rootElement = (XMLElement)layer.getFields().get(0);
|
647 |
|
648 |
if (xml.contains("fields")) { |
649 |
String[] fields = xml.getStringProperty("fields").split("~##SEP1##~"); |
650 |
if ((fields.length == 1) && (fields[0].equals(""))){ |
651 |
fields = new String[0]; |
652 |
} |
653 |
//The root element always is a complex type
|
654 |
Vector allFields = ((XMLComplexType)rootElement.getEntityType()).getAttributes();
|
655 |
//If the root node has been selected
|
656 |
if (xml.contains("rootNode")){ |
657 |
if (xml.getBooleanProperty("rootNode")==true){ |
658 |
atts = new XMLElement[fields.length + 1]; |
659 |
atts[fields.length] = rootElement; |
660 |
}else{
|
661 |
atts = new XMLElement[fields.length];
|
662 |
} |
663 |
}else{
|
664 |
atts = new XMLElement[fields.length];
|
665 |
} |
666 |
//Adding the other fields
|
667 |
for (int i=0 ; i<fields.length ; i++){ |
668 |
for (int j=0 ; j<allFields.size() ; j++){ |
669 |
XMLElement attribute = (XMLElement)allFields.get(j); |
670 |
if (attribute != null){ |
671 |
XMLElement found = attribute.searchAttribute(fields[i]); |
672 |
if (found != null){ |
673 |
atts[i] = found; |
674 |
break;
|
675 |
} |
676 |
} |
677 |
} |
678 |
} |
679 |
}else{
|
680 |
if (xml.contains("rootNode")){ |
681 |
if (xml.getBooleanProperty("rootNode")==true){ |
682 |
atts = new XMLElement[1]; |
683 |
atts[0] = rootElement;
|
684 |
} |
685 |
} |
686 |
} |
687 |
layer.setSelectedFields(atts); |
688 |
setWfsLayerNode(layer); |
689 |
setFields(atts); |
690 |
setAvailable(true);
|
691 |
} |
692 |
|
693 |
/**
|
694 |
* @return Returns the attributesQuery.
|
695 |
*/
|
696 |
public String getAttributesQuery() { |
697 |
return AttributesQuery;
|
698 |
} |
699 |
|
700 |
/**
|
701 |
* @param attributesQuery The attributesQuery to set.
|
702 |
*/
|
703 |
public void setAttributesQuery(String attributesQuery) { |
704 |
AttributesQuery = attributesQuery; |
705 |
} |
706 |
|
707 |
/**
|
708 |
* @return Returns the coordinatesQuery.
|
709 |
*/
|
710 |
public String getCoordinatesQuery() { |
711 |
return CoordinatesQuery;
|
712 |
} |
713 |
|
714 |
/**
|
715 |
* @param coordinatesQuery The coordinatesQuery to set.
|
716 |
*/
|
717 |
public void setCoordinatesQuery(String coordinatesQuery) { |
718 |
CoordinatesQuery = coordinatesQuery; |
719 |
} |
720 |
} |