Statistics
| Revision:

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

History | View | Annotate | Download (3.16 KB)

1
/**********************************************************************
2
 * $Id: JNIBase.java 915 2005-01-12 08:21:15Z igbrotru $
3
 *
4
 * Name:     JNIBase.java
5
 * Project:  JGDAL. Interfaz java to gdal (Frank Warmerdam).
6
 * Purpose:  Base class for classes that use JNI.
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

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

    
34
package es.gva.cit.jgdal;
35

    
36

    
37

    
38
public class JNIBase{
39
        
40
        protected long cPtr;
41
        
42
        private native int getRasterBandXSizeNat(long cPtr);
43
        private native int getRasterBandYSizeNat(long cPtr);
44
        private native int getOverviewCountNat(long cPtr);
45
        private native int getBlockXSizeNat(long cPtr);
46
        private native int getBlockYSizeNat(long cPtr);
47
        private native int getRasterXSizeNat(long cPtr);
48
        private native int getRasterYSizeNat(long cPtr);
49
        private native int getRasterCountNat(long cPtr);
50
        private native int getGCPCountNat(long cPtr);
51
        private native int getRasterDataTypeNat(long cPtr);
52
        private native int getDriverCountNat(long cPtr);
53
        private native int getLayerCountNat(long cPtr);
54
        
55
        
56
         /**
57
         * Funci?n que sirve como base para funcionalidades de gdal que admiten como par?metro un entero y devuelven un entero.
58
         * 
59
         * @throws GdalException.
60
         * @param msg1        Mensaje de error que se muestra cuando el puntero a objeto pasado es vacio.
61
         * @param msg2        Mensaje de error que se muestra cuando el resultado de la llamada a la funci?n de gdal es menor o igual que 0.
62
         */
63
         
64
         
65
        protected int baseSimpleFunctions(int n,String msg1,String msg2)throws GdalException{
66
                        
67
                int res = 0;
68
                if(cPtr <= 0)
69
                        throw new GdalException(msg1);
70
                        
71
                switch(n){
72
                        case 0: res = getRasterBandXSizeNat(cPtr);break;
73
                        case 1: res = getRasterBandYSizeNat(cPtr);break;
74
                        case 2: res = getOverviewCountNat(cPtr);break;
75
                        case 3: res = getBlockXSizeNat(cPtr);break;
76
                        case 4: res = getBlockYSizeNat(cPtr);break;
77
                        case 5: res = getRasterXSizeNat(cPtr);break;
78
                        case 6: res = getRasterYSizeNat(cPtr);break;
79
                        case 7: res = getRasterCountNat(cPtr);break;
80
                        case 8: res = getGCPCountNat(cPtr);break;
81
                        case 9: res = getRasterDataTypeNat(cPtr);break;
82
                        case 10: res = getDriverCountNat(cPtr);break;                //OGR
83
                        case 11: res = getLayerCountNat(cPtr);break;                //OG
84
                }
85
                        
86
                if(res<0)
87
                         throw new GdalException(msg2);
88
                else return res;
89
        }
90
        
91
        static{
92
                
93
                System.loadLibrary("jgdal");
94
                
95
        }
96
                
97
}