Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / LayerFactory.java @ 3301

History | View | Annotate | Download (19.9 KB)

1 1100 fjp
/* 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 214 fernando
package com.iver.cit.gvsig.fmap.layers;
42
43 2277 vcaballero
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 408 fernando
import com.hardcode.driverManager.Driver;
55
import com.hardcode.driverManager.DriverLoadException;
56
import com.hardcode.driverManager.DriverManager;
57 1828 fernando
import com.hardcode.gdbms.engine.customQuery.QueryManager;
58 2183 fernando
import com.hardcode.gdbms.engine.data.DataSource;
59 408 fernando
import com.hardcode.gdbms.engine.data.DataSourceFactory;
60 2183 fernando
import com.hardcode.gdbms.engine.data.NoSuchTableException;
61
import com.hardcode.gdbms.engine.data.edition.DataWare;
62 470 fjp
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException;
63 2183 fernando
import com.hardcode.gdbms.engine.values.Value;
64
import com.hardcode.gdbms.engine.values.ValueFactory;
65 651 fernando
import com.iver.cit.gvsig.fmap.DriverException;
66 2183 fernando
import com.iver.cit.gvsig.fmap.ProgressListener;
67 2850 nacho
import com.iver.cit.gvsig.fmap.ViewPort;
68 3236 fjp
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition;
69 422 fjp
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
70 303 fernando
import com.iver.cit.gvsig.fmap.drivers.RasterDriver;
71
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver;
72 408 fernando
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
73 438 fernando
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
74 2183 fernando
import com.iver.cit.gvsig.fmap.drivers.VectorialJDBCDriver;
75 714 fjp
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend;
76 1828 fernando
import com.iver.cit.gvsig.fmap.operations.arcview.ArcJoin;
77 458 fjp
import com.iver.cit.gvsig.fmap.rendering.LegendFactory;
78 714 fjp
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
79 303 fernando
80
81 214 fernando
/**
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 732 fernando
        private static Logger logger = Logger.getLogger(LayerFactory.class.getName());
88 439 luisw
        private static String driversPath = "../FMap 03/drivers";
89 732 fernando
        private static DriverManager driverManager;
90 408 fernando
91 1828 fernando
        private static DataSourceFactory dataSourceFactory;
92 1773 fernando
93 732 fernando
        /**
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 214 fernando
103 1828 fernando
        /*
104 732 fernando
         * 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 1034 vcaballero
         * @param layerName Nombre de la capa.
109
         * @param driverName Nombre del driver.
110
         * @param f fichero.
111
         * @param proj Proyecci?n.
112 732 fernando
         *
113 1034 vcaballero
         * @return FLayer.
114 1060 fjp
         * @throws DriverException
115 732 fernando
         *
116
         * @throws DriverException
117 1034 vcaballero
         * @throws DriverIOException
118 2183 fernando
         */
119 732 fernando
        public static FLayer createLayer(String layerName, String driverName,
120 1060 fjp
                File f, IProjection proj) throws DriverException  {
121 732 fernando
                //Se obtiene el driver que lee
122
                DriverManager dm = getDM();
123 438 fernando
124 732 fernando
                try {
125
                        Driver d = dm.getDriver(driverName);
126 438 fernando
127 732 fernando
                        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 1060 fjp
                        throw new DriverException(e);
134 732 fernando
                }
135 438 fernando
136 732 fernando
                return null;
137
        }
138 2183 fernando
139 1034 vcaballero
        /**
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 214 fernando
159 1034 vcaballero
                FLyrVect capa = new FLyrVect();
160
                capa.setName(layerName);
161 214 fernando
162 1034 vcaballero
                //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 1828 fernando
171 470 fjp
                        // 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 1034 vcaballero
                        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 470 fjp
                } catch (FieldNotFoundException e) {
184 651 fernando
                        //Esta no puede saltar
185 714 fjp
                } catch (DriverIOException e) {
186
                        throw new DriverException(e);
187 1034 vcaballero
                }
188 408 fernando
189 1034 vcaballero
                return capa;
190
        }
191 567 luisw
192 3301 fjp
    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 732 fernando
        /**
228 1034 vcaballero
         * 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 732 fernando
         *
232 1034 vcaballero
         * @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 732 fernando
         *
240 1034 vcaballero
         * @return Capa creada.
241 732 fernando
         */
242 3182 ldiaz
        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 1034 vcaballero
253 3182 ldiaz
                return layer;
254
        }
255
256 1034 vcaballero
        /**
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 732 fernando
        public static FLyrRaster createLayer(String layerName, RasterDriver d,
269 1046 fernando
                File f, IProjection proj) throws DriverException {
270 732 fernando
                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 1046 fernando
                        try {
282
                                capa.load();
283
                        } catch (DriverIOException e) {
284
                                throw new DriverException(e);
285
                        }
286 732 fernando
                }
287
288 567 luisw
                return capa;
289 732 fernando
        }
290 567 luisw
291 732 fernando
        /**
292 2850 nacho
         * 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 3084 nacho
                        //capa.setTempExtent(vp);
321 2850 nacho
                        try {
322
                                capa.load();
323
                        } catch (DriverIOException e) {
324
                                throw new DriverException(e);
325
                        }
326
                }
327
328
                return capa;
329
        }
330
331
        /**
332 732 fernando
         * 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 1034 vcaballero
         * @param driver Driver WFS.
336
         * @param host URL.
337
         * @param proj Proyecci?n.
338 732 fernando
         *
339 1034 vcaballero
         * @return Capa creada.
340 732 fernando
         *
341 1034 vcaballero
         * @throws UnsupportedOperationException
342 732 fernando
         */
343 2277 vcaballero
        public static FLayer createWFSLayer(String layerName,VectorialDriver driver, URL host,
344 732 fernando
                IProjection proj) {
345 2183 fernando
                //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 732 fernando
        }
366 2277 vcaballero
    public static FLayer createArcSDELayer(String layerName,VectorialDatabaseDriver driver, IProjection proj) {
367 2183 fernando
            //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 214 fernando
405 732 fernando
        /**
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 1034 vcaballero
         * @param driver
410
         * @param host
411
         * @param port
412
         * @param user
413
         * @param password
414
         * @param dbName
415
         * @param tableName
416
         * @param proj
417 732 fernando
         *
418 1034 vcaballero
         * @return Capa creada.
419 732 fernando
         *
420 1034 vcaballero
         * @throws UnsupportedOperationException
421 732 fernando
         */
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 1691 fjp
        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 303 fernando
455 1691 fjp
                return capa;
456
457
458
459
                }
460
461 2183 fernando
        /**
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 3236 fjp
        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 2217 fernando
            dataSourceFactory.addDBDataSourceByTable(dsName, null, 0, "sa", "", database, dsName, "GDBMS HSQLDB Transactional driver");
500 2667 fernando
            DataSource local = dataSourceFactory.createRandomDataSource(dsName, DataSourceFactory.MANUAL_OPENING);
501 2183 fernando
            local.start();
502 2217 fernando
            DataWare dw = local.getDataWare(DataSourceFactory.DATA_WARE_COHERENT_ROW_ORDER);
503 2183 fernando
            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 3236 fjp
            cacheDriver.setData(java.sql.DriverManager.getConnection("jdbc:hsqldb:file:" + database, "sa", ""), lyrDef);
543 2183 fernando
            cacheDriver.setWorkingArea(driver.getWorkingArea());
544
        return createDBLayer(cacheDriver, layerName, proj);
545
        }
546 1691 fjp
547 2183 fernando
548 732 fernando
        /**
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 1034 vcaballero
         * @param source Adaptador.
553 732 fernando
         */
554
        private static void getAdapter(Source source) {
555
        }
556 303 fernando
557 732 fernando
        /**
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 1034 vcaballero
         * @param s Adaptador
563
         * @param a VectorialAdapter.
564 732 fernando
         */
565
        private static void saveSourceAdapter(Source s, VectorialAdapter a) {
566
        }
567 303 fernando
568 732 fernando
        /**
569
         * Crea una FLyrComplexRaster que ataca al driver que se pasa como
570
         * par?metro.
571
         *
572 1034 vcaballero
         * @param driver
573
         * @param f
574
         * @param proj
575 732 fernando
         *
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 408 fernando
583 732 fernando
        /**
584 1034 vcaballero
         * Devuelve el DriverManager.
585 732 fernando
         *
586 1034 vcaballero
         * @return DriverManager.
587 732 fernando
         */
588
        public static DriverManager getDM() {
589 1839 fernando
                initializeDriverManager();
590 732 fernando
591
                return driverManager;
592
        }
593
594
        /**
595 1034 vcaballero
         * Inicializa el DriverManager.
596 732 fernando
         */
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 2183 fernando
                                logger.error("", failures[i]);
606 626 fernando
                        }
607
608 1828 fernando
                        getDataSourceFactory().setDriverManager(driverManager);
609 2183 fernando
                        getDataSourceFactory().initialize();
610 1836 fernando
                        QueryManager.registerQuery(new ArcJoin());
611 732 fernando
                }
612
        }
613 408 fernando
614 732 fernando
        /**
615
         * sets drivers Directory
616
         *
617
         * @param path
618
         */
619
        public static void setDriversPath(String path) {
620
                LayerFactory.driversPath = path;
621
                initializeDriverManager();
622
        }
623 1773 fernando
624 2183 fernando
625 1773 fernando
        /**
626
         * @return Returns the dataSourceFactory.
627
         */
628
        public static DataSourceFactory getDataSourceFactory() {
629 1828 fernando
                if (dataSourceFactory == null){
630
                        dataSourceFactory = new DataSourceFactory();
631
                }
632 1773 fernando
                return dataSourceFactory;
633
        }
634 214 fernando
}