Statistics
| Revision:

svn-gvsig-desktop / tmp / trunk / cliente / WorkSpace_WPSClient / extWPSCallejero / src / es / logex / gvsig / fmap / layers / WPSAdapter.java @ 26604

History | View | Annotate | Download (4.4 KB)

1
/* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2008 Logica Extrema, S.L. 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
 *   Logica Extrema, S.L.
34
 *   Edif. Sorolla Center
35
 *   Avgda. De les Corts Valencianes, 158 Of.1007
36
 *   46015 Valencia
37
 *   Spain
38
 *
39
 *   +34 963462375
40
 *   info@logex.es
41
 */
42
package es.logex.gvsig.fmap.layers;
43

    
44
import java.io.IOException;
45

    
46
import com.hardcode.driverManager.DriverLoadException;
47

    
48
import com.hardcode.gdbms.engine.data.DataSourceFactory;
49
import com.hardcode.gdbms.engine.data.NoSuchTableException;
50
import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
51

    
52
import com.iver.cit.gvsig.fmap.DriverException;
53

    
54
import com.iver.cit.gvsig.fmap.core.IGeometry;
55
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
56
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
57
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
58
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter;
59

    
60

    
61
import es.logex.gvsig.fmap.drivers.WPSDriver;
62

    
63

    
64
/**
65
 * Adapta un driver de WPS a la interfaz vectorial, manteniendo adem�s el
66
 * estado necesario por una capa vectorial WPS (URL del host, estado del
67
 * protocolo).
68
 */
69
public class WPSAdapter extends VectorialAdapter {
70
        
71
        /** The datasource. */
72
        private SelectableDataSource ds = null;
73

    
74
        
75
        /**
76
         * Gets the recordset.
77
         * 
78
         * @return the recordset
79
         * 
80
         * @throws DriverLoadException the driver load exception
81
         * 
82
         * @see com.iver.cit.gvsig.fmap.layers.VectorialAdapter#getRecordset()
83
         */
84
        public SelectableDataSource getRecordset() throws DriverLoadException {
85
                if (ds==null && driver instanceof WPSDriver)
86
                {
87
                        String name = LayerFactory.getDataSourceFactory().addDataSource((ObjectDriver)driver);
88
                        try {
89
                                ds = new SelectableDataSource(LayerFactory.getDataSourceFactory().createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING));
90
                                
91
                                
92
                        } catch (NoSuchTableException e) {
93
                                throw new RuntimeException(e);
94
                        } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
95
                                throw new RuntimeException(e);
96
                        }
97
                        
98
                }
99
                //System.out.println("Tipo ds = " + ds.getClass().toString());
100
                return ds;
101
        }
102

    
103
        
104
        /**
105
         * Start.
106
         * 
107
         * @throws DriverIOException the driver io exception
108
         * 
109
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#start()
110
         */
111
        public void start() throws DriverIOException {
112
                
113
                                try {
114
                                        ((WPSDriver)driver).open();
115
                                        
116
                                } catch (DriverException e) {
117
                                        // TODO Auto-generated catch block
118
                                        e.printStackTrace();
119
                                }
120
        }
121

    
122
        /**
123
         * Stop.
124
         * 
125
         * @throws DriverIOException the driver io exception
126
         * 
127
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#stop()
128
         */
129
        public void stop() throws DriverIOException {
130
                ((WPSDriver)driver).close();
131

    
132
        }
133

    
134
        /**
135
         * Gets the shape.
136
         * 
137
         * @param index the index
138
         * 
139
         * @return the shape
140
         * 
141
         * @throws DriverIOException the driver io exception
142
         * 
143
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int)
144
         */
145
        public IGeometry getShape(int index) throws DriverIOException {
146
                IGeometry geom = null;
147
                try {
148
                        geom = ((WPSDriver)driver).getShape(index);
149
                } catch (IOException e) {
150
                        // TODO Auto-generated catch block
151
                        e.printStackTrace();
152
                }
153
                return geom;
154
        }
155

    
156
        /**
157
         * Gets the shape type.
158
         * 
159
         * @return the shape type
160
         * 
161
         * @throws DriverIOException the driver io exception
162
         * 
163
         * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShapeType()
164
         */
165
        public int getShapeType() throws DriverIOException {
166
                
167
                return ((WPSDriver)driver).getShapeType();
168
        }
169
        
170
}