svn-gvsig-desktop / tmp / trunk / cliente / WorkSpace_WPSClient / extWPSCallejero / src / es / logex / gvsig / fmap / layers / WPSAdapter.java @ 26604
History | View | Annotate | Download (4.4 KB)
1 | 26604 | kike | /* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2008 Logica Extrema, S.L. 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 | * Logica Extrema, S.L.
|
||
34 | * Edif. Sorolla Center
|
||
35 | * Avgda. De les Corts Valencianes, 158 Of.1007
|
||
36 | * 46015 Valencia
|
||
37 | * Spain
|
||
38 | *
|
||
39 | * +34 963462375
|
||
40 | * info@logex.es
|
||
41 | */
|
||
42 | 26482 | kike | package es.logex.gvsig.fmap.layers; |
43 | |||
44 | import java.io.IOException; |
||
45 | |||
46 | import com.hardcode.driverManager.DriverLoadException; |
||
47 | 26601 | kike | |
48 | 26482 | kike | import com.hardcode.gdbms.engine.data.DataSourceFactory; |
49 | import com.hardcode.gdbms.engine.data.NoSuchTableException; |
||
50 | import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
||
51 | 26601 | kike | |
52 | 26482 | kike | import com.iver.cit.gvsig.fmap.DriverException; |
53 | 26601 | kike | |
54 | 26482 | kike | import com.iver.cit.gvsig.fmap.core.IGeometry; |
55 | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
||
56 | import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
||
57 | import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
||
58 | import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
||
59 | 26523 | kike | |
60 | 26601 | kike | |
61 | 26482 | kike | import es.logex.gvsig.fmap.drivers.WPSDriver; |
62 | |||
63 | |||
64 | /**
|
||
65 | 26488 | kike | * Adapta un driver de WPS a la interfaz vectorial, manteniendo adem�s el
|
66 | * estado necesario por una capa vectorial WPS (URL del host, estado del
|
||
67 | 26604 | kike | * protocolo).
|
68 | 26482 | kike | */
|
69 | public class WPSAdapter extends VectorialAdapter { |
||
70 | 26604 | kike | |
71 | /** The datasource. */
|
||
72 | 26482 | kike | private SelectableDataSource ds = null; |
73 | |||
74 | 26523 | kike | |
75 | 26604 | kike | /**
|
76 | * Gets the recordset.
|
||
77 | *
|
||
78 | * @return the recordset
|
||
79 | *
|
||
80 | * @throws DriverLoadException the driver load exception
|
||
81 | *
|
||
82 | * @see com.iver.cit.gvsig.fmap.layers.VectorialAdapter#getRecordset()
|
||
83 | */
|
||
84 | 26482 | kike | public SelectableDataSource getRecordset() throws DriverLoadException { |
85 | if (ds==null && driver instanceof WPSDriver) |
||
86 | { |
||
87 | String name = LayerFactory.getDataSourceFactory().addDataSource((ObjectDriver)driver);
|
||
88 | try {
|
||
89 | ds = new SelectableDataSource(LayerFactory.getDataSourceFactory().createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING));
|
||
90 | 26523 | kike | |
91 | |||
92 | 26482 | kike | } catch (NoSuchTableException e) {
|
93 | throw new RuntimeException(e); |
||
94 | } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
||
95 | throw new RuntimeException(e); |
||
96 | } |
||
97 | 26523 | kike | |
98 | 26482 | kike | } |
99 | 26523 | kike | //System.out.println("Tipo ds = " + ds.getClass().toString());
|
100 | 26482 | kike | return ds;
|
101 | } |
||
102 | |||
103 | |||
104 | 26604 | kike | /**
|
105 | * Start.
|
||
106 | *
|
||
107 | * @throws DriverIOException the driver io exception
|
||
108 | *
|
||
109 | * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#start()
|
||
110 | */
|
||
111 | 26482 | kike | public void start() throws DriverIOException { |
112 | |||
113 | try {
|
||
114 | ((WPSDriver)driver).open(); |
||
115 | 26523 | kike | |
116 | 26482 | kike | } catch (DriverException e) {
|
117 | // TODO Auto-generated catch block
|
||
118 | e.printStackTrace(); |
||
119 | } |
||
120 | } |
||
121 | |||
122 | 26604 | kike | /**
|
123 | * Stop.
|
||
124 | *
|
||
125 | * @throws DriverIOException the driver io exception
|
||
126 | *
|
||
127 | * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#stop()
|
||
128 | */
|
||
129 | 26482 | kike | public void stop() throws DriverIOException { |
130 | ((WPSDriver)driver).close(); |
||
131 | |||
132 | } |
||
133 | |||
134 | 26604 | kike | /**
|
135 | * Gets the shape.
|
||
136 | *
|
||
137 | * @param index the index
|
||
138 | *
|
||
139 | * @return the shape
|
||
140 | *
|
||
141 | * @throws DriverIOException the driver io exception
|
||
142 | *
|
||
143 | * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int)
|
||
144 | */
|
||
145 | 26482 | kike | public IGeometry getShape(int index) throws DriverIOException { |
146 | IGeometry geom = null;
|
||
147 | try {
|
||
148 | geom = ((WPSDriver)driver).getShape(index); |
||
149 | } catch (IOException e) { |
||
150 | // TODO Auto-generated catch block
|
||
151 | e.printStackTrace(); |
||
152 | } |
||
153 | return geom;
|
||
154 | } |
||
155 | |||
156 | 26604 | kike | /**
|
157 | * Gets the shape type.
|
||
158 | *
|
||
159 | * @return the shape type
|
||
160 | *
|
||
161 | * @throws DriverIOException the driver io exception
|
||
162 | *
|
||
163 | * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeType()
|
||
164 | */
|
||
165 | 26482 | kike | public int getShapeType() throws DriverIOException { |
166 | 26591 | kike | |
167 | 26482 | kike | return ((WPSDriver)driver).getShapeType();
|
168 | } |
||
169 | 26523 | kike | |
170 | 26482 | kike | } |