Statistics
| Revision:

gvsig-raster / org.gvsig.raster.gdal / tags / pre-remove-jgdal / org.gvsig.raster.gdal / org.gvsig.raster.gdal.io / src / main / java / org / gvsig / jogr / OGRSFDriver.java @ 3497

History | View | Annotate | Download (5.69 KB)

1
/**********************************************************************
2
 * $Id: OGRSFDriver.java 15690 2007-10-31 10:28:41Z nbrodin $
3
 *
4
 * Name:     OGRSFDriver.java
5
 * Project:  JGDAL. Interface java to gdal (Frank Warmerdam).
6
 * Purpose:   
7
 * Author:   Nacho Brodin, brodin_ign@gva.es
8
 *
9
 **********************************************************************/
10
/*Copyright (C) 2004  Nacho Brodin <brodin_ign@gva.es>
11

12
 This program is free software; you can redistribute it and/or
13
 modify it under the terms of the GNU General Public License
14
 as published by the Free Software Foundation; either version 2
15
 of the License, or (at your option) any later version.
16

17
 This program is distributed in the hope that it will be useful,
18
 but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 GNU General Public License for more details.
21

22
 You should have received a copy of the GNU General Public License
23
 along with this program; if not, write to the Free Software
24
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
 */
26

    
27
package org.gvsig.jogr;
28

    
29
import org.gdal.ogr.DataSource;
30
import org.gdal.ogr.Driver;
31

    
32

    
33
/** 
34
 * 
35
 * @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
36
 * @version 0.0
37
 * @link http://www.gvsig.gva.es
38
 */
39

    
40
public class OGRSFDriver extends Driver{
41
        
42
//        public native String getNameNat(long cPtr);
43
//        private native long openNat( long cPtr, String pszName, boolean bUpdate );
44
//        private native int testCapabilityNat( long cPtr,String cap );
45
//        private native long createDataSourceNat( long cPtr, String pszName);                                             
46
//    private native int deleteDataSourceNat( long cPtr,String pszName );//Excepciones
47
//    private native long copyDataSourceNat( long cPtr, 
48
//                                                                                            long poSrcDS,
49
//                                                                                                String pszNewName,
50
//                                                                                                String[] papszOptions);
51
        
52
        public OGRSFDriver(long cPtr){
53
                super(cPtr, true);
54
        }
55

    
56
        /**
57
         * Obtiene el nombre del driver
58
         * @throws OGRException
59
         * @return Nombre del driver
60
         */
61
        
62
        public String getName() {                    
63
//                if(cPtr == 0)
64
//                        throw new OGRException("Fallo al acceder al dato.");
65
                
66
                String name = this.GetName();
67
                
68
//                if(name == null)
69
//                        throw new OGRException("Error en getName(). No se ha podido obtener el nombre del driver.");
70
                return name;
71
        }
72
        
73
        
74
        /**
75
         * 
76
         */
77
        
78
        public OGRDataSource open( String pszName, boolean bUpdate )throws OGRException {
79
//                if(cPtr == 0)
80
//                        throw new OGRException("Fallo al acceder al dato.");
81
                int update= 0;
82
                if(bUpdate){
83
                        update = 1;
84
                }
85
                DataSource ds = this.Open(pszName, update);
86
                
87
                if(ds == null || !(ds instanceof OGRDataSource))
88
                        throw new OGRException("Error en open(). No se ha podido obtener un dataset valido.");
89
                
90
                return ((OGRDataSource)ds);
91
                
92
        }
93

    
94
        /**
95
         * @param capability        Capacidad del driver a testear
96
         * <UL>
97
         *   <LI>"RandomRead"</LI>
98
     *         <LI>"SequentialWrite"</LI>
99
     *   <LI>"RandomWrite"</LI>
100
     *   <LI>"FastSpatialFilter"</LI>
101
     *   <LI>"FastFeatureCount"</LI>
102
     *   <LI>"FastGetExtent"</LI>
103
     *   <LI>"CreateField"</LI>
104
     *   <LI>"Transactions"</LI>
105
     *   <LI>"DeleteFeature"</LI>
106
     *   <LI>"CreateLayer"</LI>
107
     *   <LI>"DeleteLayer"</LI>
108
     *   <LI>"CreateDataSource"</LI>
109
     *   <LI>"DeleteDataSource"</LI>
110
     * </UL>
111
         */
112
        
113
        public boolean testCapability( String capability )throws OGRException {        
114
//                if(cPtr == 0)
115
//                        throw new OGRException("Fallo al acceder al dato.");
116
                
117
                if(capability == null || capability.equals(""))
118
                        throw new OGRException("Error en testCapability(). El par?metro pasado a la funci?n no es valido.");
119
                
120
                boolean res = this.TestCapability(capability);
121
                
122
//                if(res == 0)
123
//                        throw new OGRException("Error en testCapability(). No se ha podido obtener un valor de retorno valido.");
124
                
125
                return res;
126
        }
127

    
128
        /**
129
         * 
130
         */
131
        
132
        public OGRDataSource createDataSource( String pszName )throws OGRException {         
133
//                if(cPtr == 0)
134
//                        throw new OGRException("Fallo al acceder al dato.");
135
                
136
                if(pszName == null || pszName.equals(""))
137
                        throw new OGRException("Error en createDataSource(). El par?metro pasado a la funci?n no es valido.");
138
                                
139
                DataSource ds = this.CreateDataSource(pszName);
140
                
141
                if(ds == null || !(ds instanceof OGRDataSource))
142
                        throw new OGRException("Error en createDataSource(). No se ha podido obtener un dataset valido.");
143
                
144
                return ((OGRDataSource)ds);
145
        }
146

    
147
        /**
148
         * 
149
         */
150
        
151
    public void deleteDataSource( String pszName )throws OGRException {//Excepciones
152
//            if(cPtr == 0)
153
//                        throw new OGRException("Fallo al acceder al dato.");
154
            
155
            if(pszName == null || pszName.equals(""))
156
                        throw new OGRException("Error en deleteDataSource(). El par?metro pasado a la funci?n no es valido.");
157
                
158
            int ogrerr = this.DeleteDataSource(pszName);   
159
//            throwException(ogrerr, "Error en deleteDataSource().");
160
   
161
    }
162

    
163
        /**
164
         * 
165
         */
166
        
167
    public OGRDataSource copyDataSource( OGRDataSource poSrcDS,
168
                                                   String pszNewName,
169
                                                   String[] papszOptions)throws OGRException {
170
            if(poSrcDS == null || pszNewName == null || pszNewName.equals(""))
171
                        throw new OGRException("Error en deleteDataSource().Alg?n par?metro pasado a la funci?n no es valido.");
172
                
173
            if(poSrcDS == null)
174
                        throw new OGRException("Fallo al acceder al dato fuente.");
175
            
176
//            if(cPtr == 0)
177
//                        throw new OGRException("Fallo al acceder al dato.");
178
            
179
            DataSource ds = this.CopyDataSource(poSrcDS, pszNewName, OGRTools.safeStringArrayToVector(papszOptions));
180
                
181
                if(ds == null)
182
                        throw new OGRException("Error en copyDataSource(). No se ha podido obtener un dataset valido.");
183
                
184
                return ((OGRDataSource)ds);
185

    
186
    }
187
    
188

    
189
}