svn-gvsig-desktop / tmp / trunk / cliente / WorkSpace_WPSClient / extWPSCallejero / src / es / logex / gvsig / fmap / drivers / wps / FMapWPSDriver.java @ 26601
History | View | Annotate | Download (5.15 KB)
1 |
package es.logex.gvsig.fmap.drivers.wps; |
---|---|
2 |
|
3 |
|
4 |
import java.awt.geom.Rectangle2D; |
5 |
import java.io.File; |
6 |
import java.io.IOException; |
7 |
import java.net.URL; |
8 |
|
9 |
|
10 |
import org.cresques.cts.IProjection; |
11 |
import org.gvsig.fmap.drivers.gpe.reader.GMLVectorialDriver; |
12 |
|
13 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
14 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
15 |
import com.hardcode.gdbms.engine.data.driver.ObjectDriver; |
16 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
17 |
import com.hardcode.gdbms.engine.values.Value; |
18 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
19 |
import com.iver.cit.gvsig.fmap.drivers.BoundedShapes; |
20 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
21 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver; |
22 |
|
23 |
import es.logex.gvsig.fmap.drivers.WPSDriver; |
24 |
import es.logex.gvsig.fmap.drivers.WPSException; |
25 |
import es.logex.gvsig.wps.client.WPSClient; |
26 |
|
27 |
public class FMapWPSDriver implements WPSDriver, BoundedShapes, ObjectDriver { |
28 |
|
29 |
private WPSClient wpsClient;
|
30 |
private GMLVectorialDriver driver = null; |
31 |
private DriverAttributes attr = null; |
32 |
private int geometryType; |
33 |
|
34 |
public FMapWPSDriver() {
|
35 |
super();
|
36 |
driver = new GMLVectorialDriver();
|
37 |
attr = new DriverAttributes();
|
38 |
} |
39 |
|
40 |
public String getName() { |
41 |
return "WPS-Driver"; |
42 |
} |
43 |
|
44 |
public String getVersion() { |
45 |
return wpsClient.getVersion();
|
46 |
} |
47 |
|
48 |
/**
|
49 |
*/
|
50 |
public boolean connect() { |
51 |
return wpsClient.connect();
|
52 |
} |
53 |
|
54 |
public void createClient(URL host) { |
55 |
wpsClient = new WPSClient(host.toString());
|
56 |
} |
57 |
|
58 |
public void describeProcess(String processName) throws WPSException { |
59 |
// TODO Implementar
|
60 |
throw new WPSException("Not Implemented"); |
61 |
} |
62 |
|
63 |
public void executeProcess(String processName) throws WPSException { |
64 |
// TODO Implementar
|
65 |
throw new WPSException("Not Implemented"); |
66 |
} |
67 |
|
68 |
|
69 |
public void loadGeometries(Rectangle2D extent, IProjection extentProjection, String layerName, |
70 |
String detailLevel) {
|
71 |
|
72 |
try {
|
73 |
|
74 |
File file = wpsClient.executeProcessGetLayer( extent,
|
75 |
extentProjection.getAbrev(), |
76 |
layerName, detailLevel); |
77 |
|
78 |
// Si no se hace el reload, las geometrias son aƱadidas a la capa, con lo cual pueden quedar duplicadas!!!
|
79 |
driver.reload(); //lo pone a cero pero no hace el reload.
|
80 |
// Si aqui hay un error de transmision, no podemos enterarnos, ya
|
81 |
// que la carga del fichero desde el metodo
|
82 |
// org.gvsig.remoteClient.utils.Downloader.run en el cual se delega
|
83 |
// atrapa el error y no lo propaga, simplemente tira un stack trace
|
84 |
driver.open(file); |
85 |
driver.initialize(); |
86 |
|
87 |
} catch (IOException e) { |
88 |
// TODO Auto-generated catch block
|
89 |
e.printStackTrace(); |
90 |
} |
91 |
|
92 |
|
93 |
} |
94 |
|
95 |
|
96 |
//TODO Arreglar este pollo de excepciones
|
97 |
public void getCapabilities(URL server) throws WPSException { |
98 |
try {
|
99 |
if (!getClient(server).connect()) {
|
100 |
throw new WPSException(); |
101 |
} |
102 |
; |
103 |
|
104 |
} catch (Exception e) { |
105 |
throw new WPSException(e); |
106 |
} |
107 |
} |
108 |
|
109 |
public DriverAttributes getDriverAttributes() {
|
110 |
return attr;
|
111 |
} |
112 |
|
113 |
public Rectangle2D getFullExtent() throws IOException { |
114 |
return driver.getFullExtent();
|
115 |
} |
116 |
|
117 |
public IGeometry getShape(int index) throws IOException { |
118 |
return driver.getShape(index);
|
119 |
} |
120 |
|
121 |
public int getShapeCount() throws IOException { |
122 |
return driver.getShapeCount();
|
123 |
} |
124 |
|
125 |
public int getShapeType() { |
126 |
return this.geometryType; |
127 |
} |
128 |
|
129 |
public void setShapeType(int shapeType) |
130 |
{ |
131 |
this.geometryType = shapeType;
|
132 |
} |
133 |
public boolean isWritable() { |
134 |
return driver.isWritable();
|
135 |
} |
136 |
|
137 |
public void reload() throws IOException, DriverException { |
138 |
// TODO Implementar wps reload.
|
139 |
//throw new DriverException("Not Implemented");
|
140 |
//System.out.println("Driver reload llamado");
|
141 |
} |
142 |
|
143 |
public Rectangle2D getShapeBounds(int index) throws IOException { |
144 |
return driver.getShapeBounds(index);
|
145 |
} |
146 |
|
147 |
public int getShapeType(int index) { |
148 |
return driver.getShapeType(index);
|
149 |
} |
150 |
|
151 |
public int[] getPrimaryKeys() throws DriverException { |
152 |
return driver.getPrimaryKeys();
|
153 |
} |
154 |
|
155 |
public void write(DataWare arg0) throws DriverException { |
156 |
driver.write(arg0); |
157 |
} |
158 |
|
159 |
public void setDataSourceFactory(DataSourceFactory arg0) { |
160 |
driver.setDataSourceFactory(arg0); |
161 |
} |
162 |
|
163 |
public int getFieldCount() throws DriverException { |
164 |
return driver.getFieldCount();
|
165 |
} |
166 |
|
167 |
public String getFieldName(int arg0) throws DriverException { |
168 |
return driver.getFieldName(arg0);
|
169 |
} |
170 |
|
171 |
public int getFieldType(int arg0) throws DriverException { |
172 |
return driver.getFieldType(arg0);
|
173 |
} |
174 |
|
175 |
public Value getFieldValue(long arg0, int arg1) throws DriverException { |
176 |
// TODO Auto-generated method stub
|
177 |
return driver.getFieldValue(arg0, arg1);
|
178 |
} |
179 |
|
180 |
public int getFieldWidth(int arg0) throws DriverException { |
181 |
return driver.getFieldWidth(arg0);
|
182 |
} |
183 |
|
184 |
public long getRowCount() throws DriverException { |
185 |
return driver.getRowCount();
|
186 |
} |
187 |
|
188 |
public void close() { |
189 |
// TODO Implementar
|
190 |
|
191 |
} |
192 |
|
193 |
public WPSClient getClient(URL url) { |
194 |
if (wpsClient == null) { |
195 |
wpsClient = new WPSClient(url.toString());
|
196 |
} |
197 |
|
198 |
return wpsClient;
|
199 |
} |
200 |
|
201 |
public String getHost() { |
202 |
return this.wpsClient.getHost(); |
203 |
} |
204 |
|
205 |
public String getServiceAbstract() { |
206 |
return wpsClient.getServiceAbstract();
|
207 |
} |
208 |
|
209 |
public void open() throws com.iver.cit.gvsig.fmap.DriverException { |
210 |
attr.setLoadedInMemory(true);
|
211 |
} |
212 |
|
213 |
public VectorialDriver getInnerDriver()
|
214 |
{ |
215 |
return (VectorialDriver)this.driver; |
216 |
} |
217 |
} |