Statistics
| Revision:

gvsig-raster / org.gvsig.jgdal / trunk / org.gvsig.jgdal / src / main / java / org / gvsig / jgdal / JNIBase.java @ 1002

History | View | Annotate | Download (2.95 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22

    
23

    
24
/**
25
 * @author Nacho Brodin <nachobrodin@gmail.com>.<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
26
 * @version 0.0
27
 * @link http://www.gvsig.gva.es
28
 */
29

    
30
package org.gvsig.jgdal;
31

    
32
public class JNIBase{
33
        
34
        protected long cPtr;
35
        
36
        private native int getRasterBandXSizeNat(long cPtr);
37
        private native int getRasterBandYSizeNat(long cPtr);
38
        private native int getOverviewCountNat(long cPtr);
39
        private native int getBlockXSizeNat(long cPtr);
40
        private native int getBlockYSizeNat(long cPtr);
41
        private native int getRasterXSizeNat(long cPtr);
42
        private native int getRasterYSizeNat(long cPtr);
43
        private native int getRasterCountNat(long cPtr);
44
        private native int getGCPCountNat(long cPtr);
45
        private native int getRasterDataTypeNat(long cPtr);
46
        private native int getDriverCountNat(long cPtr);
47
        private native int getLayerCountNat(long cPtr);
48
        
49
        
50
         /**
51
         * Funci?n que sirve como base para funcionalidades de gdal que admiten como par?metro un entero y devuelven un entero.
52
         * 
53
         * @throws GdalException.
54
         * @param msg1        Mensaje de error que se muestra cuando el puntero a objeto pasado es vacio.
55
         * @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.
56
         */
57
         
58
         
59
        protected int baseSimpleFunctions(int n,String msg1,String msg2)throws GdalException{
60
                        
61
                int res = 0;
62
                        
63
                switch(n){
64
                        case 0: res = getRasterBandXSizeNat(cPtr);break;
65
                        case 1: res = getRasterBandYSizeNat(cPtr);break;
66
                        case 2: res = getOverviewCountNat(cPtr);break;
67
                        case 3: res = getBlockXSizeNat(cPtr);break;
68
                        case 4: res = getBlockYSizeNat(cPtr);break;
69
                        case 5: res = getRasterXSizeNat(cPtr);break;
70
                        case 6: res = getRasterYSizeNat(cPtr);break;
71
                        case 7: res = getRasterCountNat(cPtr);break;
72
                        case 8: res = getGCPCountNat(cPtr);break;
73
                        case 9: res = getRasterDataTypeNat(cPtr);break;
74
                }
75

    
76
                if (res < 0)
77
                        throw new GdalException(msg2);
78
                else
79
                        return res;
80
        }
81
        
82
        static {
83
                /*String os = System.getProperty("os.name");
84
                if (os.toLowerCase().startsWith("windows"))
85
                        System.loadLibrary("jgdal201");
86
                else*/
87
                        System.loadLibrary("jgdal2.0.5");
88
        }
89
}