root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / LayerFactory.java @ 3301
History | View | Annotate | Download (19.9 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.awt.geom.Rectangle2D; |
44 |
import java.io.File; |
45 |
import java.io.IOException; |
46 |
import java.net.URL; |
47 |
import java.sql.SQLException; |
48 |
import java.sql.Types; |
49 |
import java.util.TreeMap; |
50 |
|
51 |
import org.apache.log4j.Logger; |
52 |
import org.cresques.cts.IProjection; |
53 |
|
54 |
import com.hardcode.driverManager.Driver; |
55 |
import com.hardcode.driverManager.DriverLoadException; |
56 |
import com.hardcode.driverManager.DriverManager; |
57 |
import com.hardcode.gdbms.engine.customQuery.QueryManager; |
58 |
import com.hardcode.gdbms.engine.data.DataSource; |
59 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
60 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
61 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
62 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
63 |
import com.hardcode.gdbms.engine.values.Value; |
64 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
65 |
import com.iver.cit.gvsig.fmap.DriverException; |
66 |
import com.iver.cit.gvsig.fmap.ProgressListener; |
67 |
import com.iver.cit.gvsig.fmap.ViewPort; |
68 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
69 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
70 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
71 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver; |
72 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver; |
73 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
74 |
import com.iver.cit.gvsig.fmap.drivers.VectorialJDBCDriver; |
75 |
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend; |
76 |
import com.iver.cit.gvsig.fmap.operations.arcview.ArcJoin; |
77 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
78 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
79 |
|
80 |
|
81 |
/**
|
82 |
* Crea un adaptador del driver que se le pasa como par?metro en los m?todos
|
83 |
* createLayer. Si hay memoria suficiente se crea un FLyrMemory que pasa todas
|
84 |
* las features del driver a memoria
|
85 |
*/
|
86 |
public class LayerFactory { |
87 |
private static Logger logger = Logger.getLogger(LayerFactory.class.getName()); |
88 |
private static String driversPath = "../FMap 03/drivers"; |
89 |
private static DriverManager driverManager; |
90 |
|
91 |
private static DataSourceFactory dataSourceFactory; |
92 |
|
93 |
/**
|
94 |
* Map en el que se guarda para cada fuente de datos a?adida al sistema, el
|
95 |
* adaptador que la maneja. Ha de ser un TreeMap ya que esta clase define
|
96 |
* la igualdad entre las claves a traves del m?todo equals de las mismas.
|
97 |
* Los objetos FileSource, DBSource y WFSSource tienen definido el m?todo
|
98 |
* equals de forma que devuelven true cuando dos objetos apuntan a la
|
99 |
* misma fuente de datos
|
100 |
*/
|
101 |
private static TreeMap sourceAdapter; |
102 |
|
103 |
/*
|
104 |
* Crea un RandomVectorialFile con el driver que se le pasa como par?metro
|
105 |
* y guard?ndose el nombre del fichero para realizar los accesos, la capa
|
106 |
* tendr? asociada la proyecci?n que se pasa como parametro tambi?n
|
107 |
*
|
108 |
* @param layerName Nombre de la capa.
|
109 |
* @param driverName Nombre del driver.
|
110 |
* @param f fichero.
|
111 |
* @param proj Proyecci?n.
|
112 |
*
|
113 |
* @return FLayer.
|
114 |
* @throws DriverException
|
115 |
*
|
116 |
* @throws DriverException
|
117 |
* @throws DriverIOException
|
118 |
*/
|
119 |
public static FLayer createLayer(String layerName, String driverName, |
120 |
File f, IProjection proj) throws DriverException { |
121 |
//Se obtiene el driver que lee
|
122 |
DriverManager dm = getDM();
|
123 |
|
124 |
try {
|
125 |
Driver d = dm.getDriver(driverName);
|
126 |
|
127 |
if (d instanceof VectorialFileDriver) { |
128 |
return createLayer(layerName, (VectorialFileDriver) d, f, proj);
|
129 |
} else if (d instanceof RasterDriver) { |
130 |
return createLayer(layerName, (RasterDriver) d, f, proj);
|
131 |
} |
132 |
} catch (DriverLoadException e) {
|
133 |
throw new DriverException(e); |
134 |
} |
135 |
|
136 |
return null; |
137 |
} |
138 |
|
139 |
/**
|
140 |
* Crea un RandomVectorialFile con el driver que se le pasa como par?metro
|
141 |
* y guard?ndose el nombre del fichero para realizar los accesos, la capa
|
142 |
* tendr? asociada la proyecci?n que se pasa como parametro tambi?n
|
143 |
*
|
144 |
* @param layerName Nombre del Layer.
|
145 |
* @param d VectorialAdapter.
|
146 |
* @param f Fichero.
|
147 |
* @param proj Proyecci?n.
|
148 |
*
|
149 |
* @return FLayer creado.
|
150 |
*
|
151 |
* @throws DriverException
|
152 |
*/
|
153 |
public static FLayer createLayer(String layerName, VectorialFileDriver d, |
154 |
File f, IProjection proj) throws DriverException { |
155 |
//TODO Comprobar si hay un adaptador ya
|
156 |
VectorialFileAdapter adapter = new VectorialFileAdapter(f);
|
157 |
adapter.setDriver((VectorialDriver) d); |
158 |
|
159 |
FLyrVect capa = new FLyrVect();
|
160 |
capa.setName(layerName); |
161 |
|
162 |
//TODO Meter esto dentro de la comprobaci?n de si hay memoria
|
163 |
if (false) { |
164 |
} else {
|
165 |
capa.setSource(adapter); |
166 |
capa.setProjection(proj); |
167 |
} |
168 |
|
169 |
try {
|
170 |
|
171 |
// Le asignamos tambi?n una legenda por defecto acorde con
|
172 |
// el tipo de shape que tenga. Tampoco s? si es aqu? el
|
173 |
// sitio adecuado, pero en fin....
|
174 |
if (d instanceof WithDefaultLegend) { |
175 |
WithDefaultLegend aux = (WithDefaultLegend) d; |
176 |
adapter.start(); |
177 |
capa.setLegend((VectorialLegend) aux.getDefaultLegend()); |
178 |
adapter.stop(); |
179 |
} else {
|
180 |
capa.setLegend(LegendFactory.createSingleSymbolLegend( |
181 |
capa.getShapeType())); |
182 |
} |
183 |
} catch (FieldNotFoundException e) {
|
184 |
//Esta no puede saltar
|
185 |
} catch (DriverIOException e) {
|
186 |
throw new DriverException(e); |
187 |
} |
188 |
|
189 |
return capa;
|
190 |
} |
191 |
|
192 |
public static FLayer createLayer(String layerName, VectorialDriver d, |
193 |
IProjection proj) throws DriverException {
|
194 |
//TODO Comprobar si hay un adaptador ya
|
195 |
VectorialDefaultAdapter adapter = new VectorialDefaultAdapter();
|
196 |
adapter.setDriver((VectorialDriver) d); |
197 |
|
198 |
FLyrVect capa = new FLyrVect();
|
199 |
capa.setName(layerName); |
200 |
|
201 |
capa.setSource(adapter); |
202 |
capa.setProjection(proj); |
203 |
|
204 |
try {
|
205 |
|
206 |
// Le asignamos tambi?n una legenda por defecto acorde con
|
207 |
// el tipo de shape que tenga. Tampoco s? si es aqu? el
|
208 |
// sitio adecuado, pero en fin....
|
209 |
if (d instanceof WithDefaultLegend) { |
210 |
WithDefaultLegend aux = (WithDefaultLegend) d; |
211 |
adapter.start(); |
212 |
capa.setLegend((VectorialLegend) aux.getDefaultLegend()); |
213 |
adapter.stop(); |
214 |
} else {
|
215 |
capa.setLegend(LegendFactory.createSingleSymbolLegend( |
216 |
capa.getShapeType())); |
217 |
} |
218 |
} catch (FieldNotFoundException e) {
|
219 |
//Esta no puede saltar
|
220 |
} catch (DriverIOException e) {
|
221 |
throw new DriverException(e); |
222 |
} |
223 |
|
224 |
return capa;
|
225 |
} |
226 |
|
227 |
/**
|
228 |
* Crea una capa WMS con el driver que se le pasa como par?metro y
|
229 |
* guard?ndose el nombre del fichero para realizar los accesos, la capa
|
230 |
* tendr? asociada la proyecci?n que se pasa como parametro tambi?n
|
231 |
*
|
232 |
* @param layerName Nombre de la capa.
|
233 |
* @param rect extent
|
234 |
* @param host URL.
|
235 |
* @param format Formato
|
236 |
* @param query Consulta.
|
237 |
* @param infoQuery inforamci?n de la consulta.
|
238 |
* @param srs SRS.
|
239 |
*
|
240 |
* @return Capa creada.
|
241 |
*/
|
242 |
public static FLayer createLayer(String layerName, Rectangle2D rect, |
243 |
URL host, String format, String query, String infoQuery, String srs) { |
244 |
FLyrWMS layer = new FLyrWMS();
|
245 |
layer.setHost(host); |
246 |
layer.setFullExtent(rect); |
247 |
layer.setFormat(format); |
248 |
layer.setLayerQuery(query); |
249 |
layer.setInfoLayerQuery(infoQuery); |
250 |
layer.setSRS(srs); |
251 |
layer.setName(layerName); |
252 |
|
253 |
return layer;
|
254 |
} |
255 |
|
256 |
/**
|
257 |
* Crea una capa Raster a partir del nombre driver, fichero y proyecci?n.
|
258 |
*
|
259 |
* @param layerName Nombre de la capa.
|
260 |
* @param d RasterDriver.
|
261 |
* @param f Fichero.
|
262 |
* @param proj Proyecci?n.
|
263 |
*
|
264 |
* @return Nueva capa de tipo raster.
|
265 |
*
|
266 |
* @throws DriverIOException
|
267 |
*/
|
268 |
public static FLyrRaster createLayer(String layerName, RasterDriver d, |
269 |
File f, IProjection proj) throws DriverException { |
270 |
RasterAdapter adapter = new RasterFileAdapter(f);
|
271 |
adapter.setDriver(d); |
272 |
|
273 |
FLyrRaster capa = new FLyrRaster();
|
274 |
capa.setName(layerName); |
275 |
|
276 |
//TODO Meter esto dentro de la comprobaci?n de si hay memoria
|
277 |
if (false) { |
278 |
} else {
|
279 |
capa.setSource(adapter); |
280 |
capa.setProjection(proj); |
281 |
try {
|
282 |
capa.load(); |
283 |
} catch (DriverIOException e) {
|
284 |
throw new DriverException(e); |
285 |
} |
286 |
} |
287 |
|
288 |
return capa;
|
289 |
} |
290 |
|
291 |
/**
|
292 |
* Crea una capa Raster a partir del nombre driver, fichero y proyecci?n y
|
293 |
* coordenadas de georeferenciaci?n. Esta funci?n es para georeferenciar
|
294 |
* capas raster. Para imagenes que no tienen georeferenciaci?n hay que asignarle
|
295 |
* una temporal, normalmente a partir de la vista activa.
|
296 |
*
|
297 |
* @param layerName Nombre de la capa.
|
298 |
* @param d RasterDriver.
|
299 |
* @param f Fichero.
|
300 |
* @param proj Proyecci?n.
|
301 |
* @param extent Extent de la vista activa
|
302 |
*
|
303 |
* @return Nueva capa de tipo raster.
|
304 |
*
|
305 |
* @throws DriverIOException
|
306 |
*/
|
307 |
public static FLyrRaster createLayer(String layerName, RasterDriver d, |
308 |
File f, IProjection proj, ViewPort vp) throws DriverException { |
309 |
RasterAdapter adapter = new RasterFileAdapter(f);
|
310 |
adapter.setDriver(d); |
311 |
|
312 |
FLyrRaster capa = new FLyrRaster();
|
313 |
capa.setName(layerName); |
314 |
|
315 |
//TODO Meter esto dentro de la comprobaci?n de si hay memoria
|
316 |
if (false) { |
317 |
} else {
|
318 |
capa.setSource(adapter); |
319 |
capa.setProjection(proj); |
320 |
//capa.setTempExtent(vp);
|
321 |
try {
|
322 |
capa.load(); |
323 |
} catch (DriverIOException e) {
|
324 |
throw new DriverException(e); |
325 |
} |
326 |
} |
327 |
|
328 |
return capa;
|
329 |
} |
330 |
|
331 |
/**
|
332 |
* Crea un RandomVectorialWFS con el driver que se le pasa como par?metro y
|
333 |
* guard?ndose la URL del servidor que se pasa como par?metro
|
334 |
*
|
335 |
* @param driver Driver WFS.
|
336 |
* @param host URL.
|
337 |
* @param proj Proyecci?n.
|
338 |
*
|
339 |
* @return Capa creada.
|
340 |
*
|
341 |
* @throws UnsupportedOperationException
|
342 |
*/
|
343 |
public static FLayer createWFSLayer(String layerName,VectorialDriver driver, URL host, |
344 |
IProjection proj) { |
345 |
//throw new UnsupportedOperationException();
|
346 |
FLyrVect layer=new FLyrVect();
|
347 |
//layer.setName(name);
|
348 |
VectorialAdapter adapter=new WFSAdapter();
|
349 |
adapter.setDriver(driver); |
350 |
//WithDefaultLegend aux=(WithDefaultLegend)driver;
|
351 |
|
352 |
layer.setName(layerName); |
353 |
layer.setSource(adapter); |
354 |
layer.setProjection(proj); |
355 |
try {
|
356 |
layer.setLegend(LegendFactory.createSingleSymbolLegend( |
357 |
layer.getShapeType())); |
358 |
} catch (FieldNotFoundException e) {
|
359 |
e.printStackTrace(); |
360 |
} catch (DriverException e) {
|
361 |
e.printStackTrace(); |
362 |
} |
363 |
//layer.setHost(host);
|
364 |
return layer;
|
365 |
} |
366 |
public static FLayer createArcSDELayer(String layerName,VectorialDatabaseDriver driver, IProjection proj) { |
367 |
//throw new UnsupportedOperationException();
|
368 |
FLyrVect layer=new FLyrVect();
|
369 |
VectorialAdapter adapter=new VectorialDBAdapter();
|
370 |
adapter.setDriver(driver); |
371 |
|
372 |
layer.setName(layerName); |
373 |
layer.setSource(adapter); |
374 |
layer.setProjection(proj); |
375 |
try {
|
376 |
if (driver instanceof WithDefaultLegend) { |
377 |
WithDefaultLegend aux = (WithDefaultLegend) driver; |
378 |
adapter.start(); |
379 |
layer.setLegend((VectorialLegend) aux.getDefaultLegend()); |
380 |
adapter.stop(); |
381 |
} else {
|
382 |
layer.setLegend(LegendFactory.createSingleSymbolLegend( |
383 |
layer.getShapeType())); |
384 |
} |
385 |
} catch (FieldNotFoundException e) {
|
386 |
throw new UnsupportedOperationException(e.getMessage()); |
387 |
} catch (DriverIOException e) {
|
388 |
throw new UnsupportedOperationException(e.getMessage()); |
389 |
} catch (DriverException e) {
|
390 |
// TODO Auto-generated catch block
|
391 |
e.printStackTrace(); |
392 |
} |
393 |
|
394 |
try {
|
395 |
layer.setLegend(LegendFactory.createSingleSymbolLegend( |
396 |
layer.getShapeType())); |
397 |
} catch (FieldNotFoundException e) {
|
398 |
e.printStackTrace(); |
399 |
} catch (DriverException e) {
|
400 |
e.printStackTrace(); |
401 |
} |
402 |
return layer;
|
403 |
} |
404 |
|
405 |
/**
|
406 |
* Crea un RandomVectorialWFS con el driver que se le pasa como par?metro y
|
407 |
* guard?ndose la URL del servidor que se pasa como par?metro
|
408 |
*
|
409 |
* @param driver
|
410 |
* @param host
|
411 |
* @param port
|
412 |
* @param user
|
413 |
* @param password
|
414 |
* @param dbName
|
415 |
* @param tableName
|
416 |
* @param proj
|
417 |
*
|
418 |
* @return Capa creada.
|
419 |
*
|
420 |
* @throws UnsupportedOperationException
|
421 |
*/
|
422 |
public static FLayer createLayer(VectorialDatabaseDriver driver, |
423 |
String host, int port, String user, String password, String dbName, |
424 |
String tableName, IProjection proj) {
|
425 |
throw new UnsupportedOperationException(); |
426 |
} |
427 |
public static FLayer createDBLayer(VectorialDatabaseDriver driver,String layerName, IProjection proj) |
428 |
{ |
429 |
|
430 |
|
431 |
FLyrVect capa = new FLyrVect();
|
432 |
|
433 |
capa.setName(layerName); |
434 |
VectorialDBAdapter dbAdapter = new VectorialDBAdapter();
|
435 |
dbAdapter.setDriver(driver); |
436 |
|
437 |
capa.setSource(dbAdapter); |
438 |
capa.setProjection(proj); |
439 |
try {
|
440 |
if (driver instanceof WithDefaultLegend) { |
441 |
WithDefaultLegend aux = (WithDefaultLegend) driver; |
442 |
dbAdapter.start(); |
443 |
capa.setLegend((VectorialLegend) aux.getDefaultLegend()); |
444 |
dbAdapter.stop(); |
445 |
} else {
|
446 |
capa.setLegend(LegendFactory.createSingleSymbolLegend( |
447 |
capa.getShapeType())); |
448 |
} |
449 |
} catch (FieldNotFoundException e) {
|
450 |
throw new UnsupportedOperationException(e.getMessage()); |
451 |
} catch (DriverException e) {
|
452 |
throw new UnsupportedOperationException(e.getMessage()); |
453 |
} |
454 |
|
455 |
return capa;
|
456 |
|
457 |
|
458 |
|
459 |
} |
460 |
|
461 |
/**
|
462 |
* @param driver
|
463 |
* @param layerName
|
464 |
* @param object
|
465 |
* @return
|
466 |
* @throws SQLException
|
467 |
* @throws DriverIOException
|
468 |
* @throws IOException
|
469 |
* @throws DriverLoadException
|
470 |
* @throws com.hardcode.gdbms.engine.data.driver.DriverException
|
471 |
* @throws NoSuchTableException
|
472 |
* @throws ClassNotFoundException
|
473 |
* @throws
|
474 |
*/
|
475 |
public static FLayer createDisconnectedDBLayer(VectorialJDBCDriver driver, String layerName, IProjection proj, ProgressListener listener) throws SQLException, IOException, DriverIOException, DriverLoadException, NoSuchTableException, com.hardcode.gdbms.engine.data.driver.DriverException, ClassNotFoundException { |
476 |
VectorialDisconnectedDBAdapter dbAdapter = new VectorialDisconnectedDBAdapter();
|
477 |
dbAdapter.setDriver(driver); |
478 |
DataSource ds = dbAdapter.getRecordset();
|
479 |
ds.start(); |
480 |
String database = dataSourceFactory.getTempFile();
|
481 |
String[] fieldNames = new String[ds.getFieldCount() + 1]; |
482 |
System.arraycopy(ds.getFieldNames(), 0, fieldNames, 1, ds.getFieldCount()); |
483 |
fieldNames[0] = "the_geom"; |
484 |
int[] types = new int[fieldNames.length]; |
485 |
types[0] = Types.BINARY; |
486 |
for (int i = 1; i < types.length; i++) { |
487 |
types[i] = ds.getFieldType(i-1);
|
488 |
} |
489 |
String dsName = dataSourceFactory.createTable(database, ds.getPKNames(), fieldNames, types);
|
490 |
|
491 |
DBLayerDefinition lyrDef = new DBLayerDefinition();
|
492 |
lyrDef.setTableName(dsName); |
493 |
lyrDef.setLayerName(layerName); |
494 |
lyrDef.setFieldNames(ds.getFieldNames()); |
495 |
lyrDef.setFieldGeometry("the_geom");
|
496 |
lyrDef.setFieldID(ds.getPKNames()[0]);
|
497 |
lyrDef.setClassToInstantiate("org.hsqldb.jdbcDriver");
|
498 |
|
499 |
dataSourceFactory.addDBDataSourceByTable(dsName, null, 0, "sa", "", database, dsName, "GDBMS HSQLDB Transactional driver"); |
500 |
DataSource local = dataSourceFactory.createRandomDataSource(dsName, DataSourceFactory.MANUAL_OPENING);
|
501 |
local.start(); |
502 |
DataWare dw = local.getDataWare(DataSourceFactory.DATA_WARE_COHERENT_ROW_ORDER); |
503 |
dw.start(); |
504 |
long t1 = System.currentTimeMillis(); |
505 |
dw.beginTrans(); |
506 |
|
507 |
if (listener == null){ |
508 |
listener = new ProgressListener() {
|
509 |
/**
|
510 |
* @see com.iver.cit.gvsig.fmap.ProgressListener#progress(int)
|
511 |
*/
|
512 |
public void progress(int n) { |
513 |
//do nothing
|
514 |
} |
515 |
}; |
516 |
} |
517 |
|
518 |
for (int i = 0; i < dbAdapter.getShapeCount(); i++) { |
519 |
Value[] row = new Value[ds.getFieldCount() + 1]; |
520 |
|
521 |
byte[] bytes = dbAdapter.getShape(i).toWKB(); |
522 |
row[0] = ValueFactory.createValue(bytes);
|
523 |
|
524 |
for (int j = 0; j < ds.getFieldCount(); j++) { |
525 |
row[j+1] = ds.getFieldValue(i, j);
|
526 |
} |
527 |
|
528 |
dw.insertFilledRow(row); |
529 |
listener.progress(100 * i / dbAdapter.getShapeCount());
|
530 |
} |
531 |
|
532 |
long t2 = System.currentTimeMillis(); |
533 |
dw.commitTrans(); |
534 |
long t3 = System.currentTimeMillis(); |
535 |
System.out.println((t2 - t1) + " - " + (t3 - t2)); |
536 |
dw.stop(); |
537 |
local.stop(); |
538 |
ds.stop(); |
539 |
VectorialJDBCDriver cacheDriver = (VectorialJDBCDriver) LayerFactory.getDM().getDriver("HSQLDB Driver");
|
540 |
Class.forName("org.hsqldb.jdbcDriver"); |
541 |
|
542 |
cacheDriver.setData(java.sql.DriverManager.getConnection("jdbc:hsqldb:file:" + database, "sa", ""), lyrDef); |
543 |
cacheDriver.setWorkingArea(driver.getWorkingArea()); |
544 |
return createDBLayer(cacheDriver, layerName, proj);
|
545 |
} |
546 |
|
547 |
|
548 |
/**
|
549 |
* Obtiene el adaptador de un driver si ya se ha a?adido el origen de datos
|
550 |
* o null si es un origen de datos nuevo
|
551 |
*
|
552 |
* @param source Adaptador.
|
553 |
*/
|
554 |
private static void getAdapter(Source source) { |
555 |
} |
556 |
|
557 |
/**
|
558 |
* Registra la asociaci?n entre la fuente de datos que se pasa como
|
559 |
* par?metro y el VectorialAdapter que se pasa como par?metro, para
|
560 |
* satisfacer futuras llamadas a getAdapter
|
561 |
*
|
562 |
* @param s Adaptador
|
563 |
* @param a VectorialAdapter.
|
564 |
*/
|
565 |
private static void saveSourceAdapter(Source s, VectorialAdapter a) { |
566 |
} |
567 |
|
568 |
/**
|
569 |
* Crea una FLyrComplexRaster que ataca al driver que se pasa como
|
570 |
* par?metro.
|
571 |
*
|
572 |
* @param driver
|
573 |
* @param f
|
574 |
* @param proj
|
575 |
*
|
576 |
* @throws IllegalArgumentException Si se pasa un driver que no implementa
|
577 |
* GeorreferencedRasterDriver o NotGeorreferencedRasterDriver
|
578 |
*/
|
579 |
public static void createLayer(RasterDriver driver, File f, IProjection proj) |
580 |
throws IllegalArgumentException { |
581 |
} |
582 |
|
583 |
/**
|
584 |
* Devuelve el DriverManager.
|
585 |
*
|
586 |
* @return DriverManager.
|
587 |
*/
|
588 |
public static DriverManager getDM() { |
589 |
initializeDriverManager(); |
590 |
|
591 |
return driverManager;
|
592 |
} |
593 |
|
594 |
/**
|
595 |
* Inicializa el DriverManager.
|
596 |
*/
|
597 |
private static void initializeDriverManager() { |
598 |
if (driverManager == null) { |
599 |
driverManager = new DriverManager(); |
600 |
driverManager.loadDrivers(new File(LayerFactory.driversPath)); |
601 |
|
602 |
Throwable[] failures = driverManager.getLoadFailures(); |
603 |
|
604 |
for (int i = 0; i < failures.length; i++) { |
605 |
logger.error("", failures[i]);
|
606 |
} |
607 |
|
608 |
getDataSourceFactory().setDriverManager(driverManager); |
609 |
getDataSourceFactory().initialize(); |
610 |
QueryManager.registerQuery(new ArcJoin());
|
611 |
} |
612 |
} |
613 |
|
614 |
/**
|
615 |
* sets drivers Directory
|
616 |
*
|
617 |
* @param path
|
618 |
*/
|
619 |
public static void setDriversPath(String path) { |
620 |
LayerFactory.driversPath = path; |
621 |
initializeDriverManager(); |
622 |
} |
623 |
|
624 |
|
625 |
/**
|
626 |
* @return Returns the dataSourceFactory.
|
627 |
*/
|
628 |
public static DataSourceFactory getDataSourceFactory() { |
629 |
if (dataSourceFactory == null){ |
630 |
dataSourceFactory = new DataSourceFactory();
|
631 |
} |
632 |
return dataSourceFactory;
|
633 |
} |
634 |
} |