Revision 1920 branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/WFSAdapter.java
WFSAdapter.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.fmap.layers; |
42 | 42 |
|
43 |
import java.awt.geom.Rectangle2D; |
|
44 |
import java.io.IOException; |
|
45 |
import java.net.URL; |
|
46 |
|
|
47 |
import com.hardcode.driverManager.DriverLoadException; |
|
43 | 48 |
import com.hardcode.gdbms.engine.data.DataSource; |
44 |
|
|
49 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
|
50 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
|
51 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
|
45 | 52 |
import com.iver.cit.gvsig.fmap.DriverException; |
53 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
46 | 54 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
47 | 55 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
56 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
|
57 |
import com.iver.cit.gvsig.fmap.drivers.wfs.IWFSDriver; |
|
48 | 58 |
import com.iver.cit.gvsig.fmap.drivers.wfs.WFSDriver; |
49 |
import com.iver.cit.gvsig.fmap.rendering.indexes.IndexNotExistsException; |
|
50 | 59 |
|
51 |
import java.awt.geom.Rectangle2D; |
|
52 | 60 |
|
53 |
import java.net.URL; |
|
54 |
|
|
55 |
|
|
56 | 61 |
/** |
57 | 62 |
* Adapta un driver de WFS a la interfaz vectorial, manteniendo adem?s el |
58 | 63 |
* estado necesario por una capa vectorial WFS (URL del host, estado del |
... | ... | |
61 | 66 |
public class WFSAdapter extends VectorialAdapter { |
62 | 67 |
private URL host; |
63 | 68 |
private VectorialAdapter tempAdapter; |
69 |
private int numReg=-1; |
|
70 |
private DataSource ds = null; |
|
71 |
/** |
|
72 |
* incrementa el contador de las veces que se ha abierto el fichero. |
|
73 |
* Solamente cuando el contador est? a cero pide al driver que conecte con |
|
74 |
* la base de datos |
|
75 |
*/ |
|
76 |
public void start() { |
|
77 |
try { |
|
78 |
((IWFSDriver)driver).open(); |
|
79 |
} catch (DriverException e) { |
|
80 |
// TODO Auto-generated catch block |
|
81 |
e.printStackTrace(); |
|
82 |
} |
|
83 |
|
|
84 |
} |
|
64 | 85 |
|
65 |
/** |
|
66 |
* incrementa el contador de las veces que se ha abierto el fichero.
|
|
67 |
* Solamente cuando el contador est? a cero pide al driver que conecte con
|
|
68 |
* el servidor WFS
|
|
69 |
*/
|
|
70 |
public void start() {
|
|
71 |
} |
|
86 |
/**
|
|
87 |
* decrementa el contador de n?mero de aperturas y cuando llega a cero pide
|
|
88 |
* al driver que cierre la conexion con el servidor de base de datos
|
|
89 |
*/
|
|
90 |
public void stop() {
|
|
91 |
((IWFSDriver)driver).close();
|
|
92 |
}
|
|
72 | 93 |
|
73 |
/** |
|
74 |
* M?todo ejecutado para finalizar. |
|
75 |
*/ |
|
76 |
public void stop() { |
|
77 |
} |
|
94 |
public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) throws DriverException |
|
95 |
{ |
|
96 |
return ((IWFSDriver)driver).getFeatureIterator(r, strEPSG); |
|
97 |
} |
|
98 |
|
|
99 |
/*public String getFields() |
|
100 |
{ |
|
101 |
return ((IWFSDriver)driver).getFields(); |
|
102 |
} |
|
103 |
public String getWhereClause() |
|
104 |
{ |
|
105 |
return ((VectorialDatabaseDriver)driver).getWhereClause(); |
|
106 |
} |
|
107 |
public String getTableName() |
|
108 |
{ |
|
109 |
return ((VectorialDatabaseDriver)driver).getTableName(); |
|
110 |
} |
|
111 |
|
|
112 |
*/ |
|
113 |
/** |
|
114 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int) |
|
115 |
*/ |
|
116 |
public IGeometry getShape(int index) throws DriverIOException { |
|
117 |
IGeometry geom = null; |
|
118 |
geom = ((IWFSDriver)driver).getShape(index); |
|
119 |
return geom; |
|
120 |
} |
|
78 | 121 |
|
79 |
/** |
|
80 |
* Inserta el driver. |
|
81 |
* |
|
82 |
* @param driver |
|
83 |
*/ |
|
84 |
public void setDriver(WFSDriver driver) { |
|
85 |
} |
|
122 |
/** |
|
123 |
* @throws DriverException |
|
124 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeCount() |
|
125 |
*/ |
|
126 |
public int getShapeCount() throws DriverIOException { |
|
127 |
try { |
|
128 |
return ((IWFSDriver)driver).getShapeCount(); |
|
129 |
} catch (IOException e) { |
|
130 |
e.printStackTrace(); |
|
131 |
} |
|
132 |
return -1; |
|
133 |
} |
|
86 | 134 |
|
87 |
/** |
|
88 |
* Establece el adaptador que se usar? para acceder a los datos temporales |
|
89 |
* obtenidos del servidor |
|
90 |
* |
|
91 |
* @param adapter |
|
92 |
*/ |
|
93 |
private void createTempFile(VectorialFileAdapter adapter) { |
|
94 |
} |
|
135 |
/** |
|
136 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getFullExtent() |
|
137 |
*/ |
|
138 |
public Rectangle2D getFullExtent() { |
|
139 |
return ((IWFSDriver)driver).getFullExtent(); |
|
140 |
} |
|
95 | 141 |
|
96 |
/** |
|
97 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int) |
|
98 |
*/ |
|
99 |
public IGeometry getShape(int index) throws DriverIOException { |
|
100 |
return null; |
|
101 |
} |
|
102 | 142 |
|
103 |
/** |
|
104 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeCount()
|
|
105 |
*/ |
|
106 |
public int getShapeCount() throws DriverIOException {
|
|
107 |
return 0;
|
|
108 |
} |
|
143 |
/**
|
|
144 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeType()
|
|
145 |
*/
|
|
146 |
public int getShapeType() throws DriverIOException {
|
|
147 |
return FShape.MULTI;
|
|
148 |
}
|
|
109 | 149 |
|
110 |
/** |
|
111 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getFullExtent() |
|
112 |
*/ |
|
113 |
public Rectangle2D getFullExtent() throws DriverIOException { |
|
114 |
return null; |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* @see com.iver.cit.gvsig.fmap.rendering.indexes.Index#getRecordIndexes(java.awt.geom.Rectangle2D) |
|
119 |
*/ |
|
120 |
public int[] getRecordIndexes(Rectangle2D rect) |
|
121 |
throws DriverIOException, IndexNotExistsException { |
|
122 |
return null; |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeType() |
|
127 |
*/ |
|
128 |
public int getShapeType() throws DriverIOException { |
|
129 |
return 0; |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* @see com.iver.cit.gvsig.fmap.layers.VectorialAdapter#getRecordset() |
|
134 |
*/ |
|
135 |
public DataSource getRecordset() { |
|
136 |
return null; |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* @see com.iver.cit.gvsig.fmap.layers.VectorialAdapter#changeRecordsetName(java.lang.String) |
|
141 |
*/ |
|
142 |
public void changeRecordsetName(String newName) throws DriverException { |
|
143 |
} |
|
150 |
/** |
|
151 |
* @see com.iver.cit.gvsig.fmap.layers.VectorialAdapter#getRecordset() |
|
152 |
*/ |
|
153 |
public DataSource getRecordset() throws DriverLoadException { |
|
154 |
if (driver instanceof WFSDriver) |
|
155 |
{ |
|
156 |
String name = LayerFactory.getDataSourceFactory().addDataSource((ObjectDriver)driver, null); |
|
157 |
try { |
|
158 |
ds = LayerFactory.getDataSourceFactory().createRandomDataSource(name, DataSourceFactory.AUTOMATIC_MODE); |
|
159 |
} catch (NoSuchTableException e) { |
|
160 |
throw new RuntimeException(e); |
|
161 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) { |
|
162 |
throw new RuntimeException(e); |
|
163 |
} |
|
164 |
} |
|
165 |
return ds; |
|
166 |
} |
|
144 | 167 |
} |
Also available in: Unified diff