Statistics
| Revision:

root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / fmap / layers / WFSAdapter.java @ 10760

History | View | Annotate | Download (3.46 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.io.IOException;
44

    
45
import com.hardcode.driverManager.DriverLoadException;
46
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
47
import com.hardcode.gdbms.engine.data.DataSourceFactory;
48
import com.hardcode.gdbms.engine.data.NoSuchTableException;
49
import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
50
import com.iver.cit.gvsig.fmap.core.FShape;
51
import com.iver.cit.gvsig.fmap.core.IGeometry;
52
import com.iver.cit.gvsig.fmap.drivers.WFSDriver;
53

    
54

    
55
/**
56
 * Adapta un driver de WFS a la interfaz vectorial, manteniendo adem?s el
57
 * estado necesario por una capa vectorial WFS (URL del host, estado del
58
 * protocolo)
59
 */
60
public class WFSAdapter extends VectorialAdapter {
61
        private SelectableDataSource ds = null;
62

    
63
        /*
64
         *  (non-Javadoc)
65
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getRecordset()
66
         */
67
        public SelectableDataSource getRecordset() throws ReadDriverException {
68
                if (driver instanceof WFSDriver)
69
                {
70
                        String name = LayerFactory.getDataSourceFactory().addDataSource((ObjectDriver)driver);
71
                        try {
72
                                // ds = LayerFactory.getDataSourceFactory().createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING);
73
                                ds = new SelectableDataSource(LayerFactory.getDataSourceFactory().createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING));
74
                        } catch (NoSuchTableException e) {
75
                                throw new RuntimeException(e);
76
                        } catch (DriverLoadException e) {
77
                                throw new RuntimeException(e);
78
                        }
79
                }
80
                return ds;
81
        }
82

    
83
        /*
84
         *  (non-Javadoc)
85
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#start()
86
         */
87
        public void start() throws ReadDriverException {
88
                ((WFSDriver)driver).open();
89
        }
90

    
91
        /*
92
         *  (non-Javadoc)
93
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#stop()
94
         */
95
        public void stop() throws ReadDriverException {
96
                ((WFSDriver)driver).close();
97

    
98
        }
99

    
100
        /*
101
         *  (non-Javadoc)
102
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int)
103
         */
104
        public IGeometry getShape(int index) throws ReadDriverException {
105
                IGeometry geom = null;
106
                geom = ((WFSDriver)driver).getShape(index);
107
                return geom;
108
        }
109

    
110
        /*
111
         *  (non-Javadoc)
112
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeType()
113
         */
114
        public int getShapeType() throws ReadDriverException {
115
                return ((WFSDriver)driver).getShapeType();
116
        }
117

    
118
}