Statistics
| Revision:

svn-gvsig-desktop / tags / Root_piloto3d / extensions / extWFS2 / src / com / iver / cit / gvsig / fmap / layers / WFSAdapter.java @ 9537

History | View | Annotate | Download (3.74 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.engine.data.DataSourceFactory;
47
import com.hardcode.gdbms.engine.data.NoSuchTableException;
48
import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
49
import com.iver.cit.gvsig.fmap.DriverException;
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.DriverIOException;
53
import com.iver.cit.gvsig.fmap.drivers.WFSDriver;
54

    
55

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

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

    
84
        /*
85
         *  (non-Javadoc)
86
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#start()
87
         */
88
        public void start() throws DriverIOException {
89
                try {
90
                        ((WFSDriver)driver).open();
91
                } catch (DriverException e) {
92
                        // TODO Auto-generated catch block
93
                        e.printStackTrace();
94
                }
95

    
96
        }
97

    
98
        /*
99
         *  (non-Javadoc)
100
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#stop()
101
         */
102
        public void stop() throws DriverIOException {
103
                ((WFSDriver)driver).close();
104

    
105
        }
106

    
107
        /*
108
         *  (non-Javadoc)
109
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int)
110
         */
111
        public IGeometry getShape(int index) throws DriverIOException {
112
                IGeometry geom = null;
113
                try {
114
                        geom = ((WFSDriver)driver).getShape(index);
115
                } catch (IOException e) {
116
                        // TODO Auto-generated catch block
117
                        e.printStackTrace();
118
                }
119
                return geom;
120
        }
121

    
122
        /*
123
         *  (non-Javadoc)
124
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeType()
125
         */
126
        public int getShapeType() throws DriverIOException {
127
                return ((WFSDriver)driver).getShapeType();
128
        }
129

    
130
}