Statistics
| Revision:

root / trunk / libraries / libjni-gdal / src / es / gva / cit / jogr / OGRLayer.java @ 970

History | View | Annotate | Download (3.6 KB)

1
/**********************************************************************
2
 * $Id: OGRLayer.java 970 2005-01-13 12:52:33Z igbrotru $
3
 *
4
 * Name:     OGRLayer.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.jogr;
28

    
29

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

    
37
public class OGRLayer extends JNIBase{
38
        
39
        public native long getLayerDefnNat(long cPtr);
40
        public native void resetReadingNat(long cPtr);
41
        public native int getExtentNat(long cPtr, OGREnvelope extent, boolean bForce);
42
        private native void FreeOGRLayerNat(long cPtr);
43
        private native long getNextFeatureNat(long cPtr);
44
        
45
        /**
46
         * Constructor
47
         * @param cPtr        direcci?n de memoria al objeto OGRLayer de C. 
48
         */
49
        
50
        public OGRLayer(long cPtr){
51
                this.cPtr=cPtr;
52
        }
53
        
54
         /**
55
         * 
56
         * @throws OGRException
57
         * @return 
58
         */
59
                        
60
         public OGRFeatureDefn getLayerDefn()throws OGRException{
61
                                
62
                 if(cPtr <= 0)
63
                        throw new OGRException("Error en getLayerDefn(). El constructor no tuvo exito");
64
                            
65
                long layer = getLayerDefnNat(cPtr);
66
                
67
                if(layer<=0)
68
                        throw new OGRException("Error en getLayerDefn(). No se ha podido obtener el objeto OGRFeatureDefn.");
69
                                                
70
                return new OGRFeatureDefn(layer);
71
                        
72
         }
73
         
74
         /**
75
          * 
76
          */
77
         public void resetReading()throws OGRException{
78
                 
79
                 if(cPtr <= 0)
80
                        throw new OGRException("Error en resetReading(). El constructor no tuvo exito");
81
                 
82
                 resetReadingNat(cPtr);
83
         }
84
         
85
         /**
86
         * Obtiene el n?mero de caracteristicas
87
         * @throws OGRException
88
         * @return N?mero de caracteristicas
89
         */
90
                
91
         public int getFeatureCount()throws OGRException{
92
                                
93
                String msg1="Error en getFeatureCount. El constructor no tuvo exito.";
94
                String msg2="Error en el conteo de caracteristicas.";
95
                return baseSimpleFunctions(2,msg1,msg2);
96
         }
97
         
98
         /**
99
          * Obtiene el extent de la capa
100
          * @throws OGRException
101
          * @return objeto conteniendo el extent 
102
          */
103
         
104
         public OGREnvelope getExtent(boolean bForce)throws OGRException{
105
                 
106
                 if(cPtr <= 0)
107
                        throw new OGRException("Error en getExtent(). El constructor no tuvo exito");
108
                 
109
                 OGREnvelope extent = new OGREnvelope();
110
                 
111
                 int err;
112
                 err = getExtentNat(cPtr, extent, bForce);
113
                                  
114
                 if(err!=0)
115
                         lanzarExcepcion(err,"Error em getFeatureCount()");
116
                 
117
                 return extent;
118
                 
119
         }
120
         
121
         /**
122
          * 
123
          */
124
         
125
         public OGRFeature getNextFeature()throws OGRException{
126
                 
127
                 OGRFeature feature = null;
128
                 if(cPtr <= 0)
129
                        throw new OGRException("Error en getNextFeature(). El constructor no tuvo exito");
130
                 
131
                 long ptro_feat = getNextFeatureNat(cPtr);
132
                 if(ptro_feat >=0)
133
                         feature = new OGRFeature(ptro_feat);
134
                 return feature;
135
         }
136
         
137
         /**
138
         * Destructor 
139
         */
140
                
141
         protected void finalize(){
142
                if(cPtr > 0)
143
                        FreeOGRLayerNat(cPtr);
144
         }
145
}