svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / fmap / layers / WFSAdapter.java @ 10626
History | View | Annotate | Download (3.42 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package com.iver.cit.gvsig.fmap.layers; |
42 |
|
43 |
import java.io.IOException; |
44 |
|
45 |
import com.hardcode.driverManager.DriverLoadException; |
46 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
47 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
48 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
49 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
50 |
import com.iver.cit.gvsig.fmap.core.FShape; |
51 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
52 |
import com.iver.cit.gvsig.fmap.drivers.WFSDriver; |
53 |
|
54 |
|
55 |
/**
|
56 |
* Adapta un driver de WFS a la interfaz vectorial, manteniendo adem?s el
|
57 |
* estado necesario por una capa vectorial WFS (URL del host, estado del
|
58 |
* protocolo)
|
59 |
*/
|
60 |
public class WFSAdapter extends VectorialAdapter { |
61 |
private SelectableDataSource ds = null; |
62 |
|
63 |
/*
|
64 |
* (non-Javadoc)
|
65 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getRecordset()
|
66 |
*/
|
67 |
public SelectableDataSource getRecordset() throws ReadDriverException, DriverLoadException { |
68 |
if (driver instanceof WFSDriver) |
69 |
{ |
70 |
String name = LayerFactory.getDataSourceFactory().addDataSource((ObjectDriver)driver);
|
71 |
try {
|
72 |
// ds = LayerFactory.getDataSourceFactory().createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING);
|
73 |
ds = new SelectableDataSource(LayerFactory.getDataSourceFactory().createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING));
|
74 |
} catch (NoSuchTableException e) {
|
75 |
throw new RuntimeException(e); |
76 |
} |
77 |
} |
78 |
return ds;
|
79 |
} |
80 |
|
81 |
/*
|
82 |
* (non-Javadoc)
|
83 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#start()
|
84 |
*/
|
85 |
public void start() throws ReadDriverException { |
86 |
((WFSDriver)driver).open(); |
87 |
} |
88 |
|
89 |
/*
|
90 |
* (non-Javadoc)
|
91 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#stop()
|
92 |
*/
|
93 |
public void stop() throws ReadDriverException { |
94 |
((WFSDriver)driver).close(); |
95 |
|
96 |
} |
97 |
|
98 |
/*
|
99 |
* (non-Javadoc)
|
100 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int)
|
101 |
*/
|
102 |
public IGeometry getShape(int index) throws ReadDriverException { |
103 |
IGeometry geom = null;
|
104 |
geom = ((WFSDriver)driver).getShape(index); |
105 |
return geom;
|
106 |
} |
107 |
|
108 |
/*
|
109 |
* (non-Javadoc)
|
110 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeType()
|
111 |
*/
|
112 |
public int getShapeType() throws ReadDriverException { |
113 |
return ((WFSDriver)driver).getShapeType();
|
114 |
} |
115 |
|
116 |
} |