Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-gdal / src / es / gva / cit / jgdal / OGRDataSource.java @ 915

History | View | Annotate | Download (2.76 KB)

1
/**********************************************************************
2
 * $Id: OGRDataSource.java 915 2005-01-12 08:21:15Z igbrotru $
3
 *
4
 * Name:     OGRDataSource.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 es.gva.cit.jgdal;
28

    
29

    
30
/** 
31
 * Esta clase representa a una fuente de datos
32
 * 
33
 * @author Nacho Brodin <brodin_ign@gva.es>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
34
 * @version 0.0
35
 * @link http://www.gvsig.gva.es
36
 */
37

    
38
public class OGRDataSource extends JNIBase{
39
        
40
        public native String getNameNat(long cPtr);
41
        public native long getLayerNat(long cPtr, int i);
42
        
43
        /**
44
         * Constructor
45
         * @param cPtr        direcci?n de memoria al objeto OGRDataSource de C. 
46
         */
47
        
48
        public OGRDataSource(long cPtr){
49
                this.cPtr=cPtr;
50
        }
51
                
52
        /**
53
         * Obtiene el nombre del datasource
54
         * @throws GdalException
55
         * @return Nombre del datasource
56
         */
57
        
58
        public String getName()throws GdalException{
59
                
60
                if(cPtr <= 0)
61
                        throw new GdalException("Error en getName(). El constructor ha fallado.");
62
                    
63
                String name = getNameNat(cPtr);
64
                
65
                if(name==null)
66
                        throw new GdalException("Error en getName(). No se ha podido obtener el nombre del datasource.");
67
                return name;
68
        }
69
        
70
        /**
71
         * Obtiene el n?mero de capas
72
         * @throws GdalException
73
         * @return N?mero de capas
74
         */
75
        
76
         public int getLayerCount()throws GdalException{
77
                        
78
                String msg1="Error en getLayerCount. El constructor no tuvo exito.";
79
                String msg2="Error en el conteo de capas.";
80
                return baseSimpleFunctions(11,msg1,msg2);
81
         }
82
         
83
         /**
84
         * Obtiene la capa indicada por el ?ndice
85
         * @throws GdalException
86
         * @return una capa
87
         */
88
                        
89
         public OGRLayer getLayer(int i)throws GdalException{
90
                                
91
                 if(cPtr <= 0)
92
                        throw new GdalException("Error en getLayer(). El constructor no tuvo exito");
93
                            
94
                long layer = getLayerNat(cPtr, i);
95
                
96
                if(layer<=0)
97
                        throw new GdalException("Error en getLayer(). No se ha podido obtener la capa indicada.");
98
                                                
99
                return new OGRLayer(layer);
100
                        
101
         }
102
}