svn-gvsig-desktop / tmp / trunk / cliente / WorkSpace_WPSClient / extWPSCallejero / src / es / logex / gvsig / fmap / layers / WPSAdapter.java @ 26601
History | View | Annotate | Download (2.19 KB)
1 |
package es.logex.gvsig.fmap.layers; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import com.hardcode.driverManager.DriverLoadException; |
6 |
|
7 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
8 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
9 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
10 |
|
11 |
import com.iver.cit.gvsig.fmap.DriverException; |
12 |
|
13 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
14 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
15 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
16 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
17 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
18 |
|
19 |
|
20 |
import es.logex.gvsig.fmap.drivers.WPSDriver; |
21 |
|
22 |
|
23 |
/**
|
24 |
* Adapta un driver de WPS a la interfaz vectorial, manteniendo adem�s el
|
25 |
* estado necesario por una capa vectorial WPS (URL del host, estado del
|
26 |
* protocolo)
|
27 |
*/
|
28 |
public class WPSAdapter extends VectorialAdapter { |
29 |
private SelectableDataSource ds = null; |
30 |
|
31 |
|
32 |
public SelectableDataSource getRecordset() throws DriverLoadException { |
33 |
if (ds==null && driver instanceof WPSDriver) |
34 |
{ |
35 |
String name = LayerFactory.getDataSourceFactory().addDataSource((ObjectDriver)driver);
|
36 |
try {
|
37 |
ds = new SelectableDataSource(LayerFactory.getDataSourceFactory().createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING));
|
38 |
|
39 |
|
40 |
} catch (NoSuchTableException e) {
|
41 |
throw new RuntimeException(e); |
42 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
43 |
throw new RuntimeException(e); |
44 |
} |
45 |
|
46 |
} |
47 |
//System.out.println("Tipo ds = " + ds.getClass().toString());
|
48 |
return ds;
|
49 |
} |
50 |
|
51 |
|
52 |
public void start() throws DriverIOException { |
53 |
|
54 |
try {
|
55 |
((WPSDriver)driver).open(); |
56 |
|
57 |
} catch (DriverException e) {
|
58 |
// TODO Auto-generated catch block
|
59 |
e.printStackTrace(); |
60 |
} |
61 |
} |
62 |
|
63 |
public void stop() throws DriverIOException { |
64 |
((WPSDriver)driver).close(); |
65 |
|
66 |
} |
67 |
|
68 |
public IGeometry getShape(int index) throws DriverIOException { |
69 |
IGeometry geom = null;
|
70 |
try {
|
71 |
geom = ((WPSDriver)driver).getShape(index); |
72 |
} catch (IOException e) { |
73 |
// TODO Auto-generated catch block
|
74 |
e.printStackTrace(); |
75 |
} |
76 |
return geom;
|
77 |
} |
78 |
|
79 |
public int getShapeType() throws DriverIOException { |
80 |
|
81 |
return ((WPSDriver)driver).getShapeType();
|
82 |
} |
83 |
|
84 |
} |