gvsig-raster / org.gvsig.raster.gdal / trunk / org.gvsig.raster.gdal / org.gvsig.raster.gdal.jni / src / main / java / org / gvsig / jogr / JNIBase.java @ 2453
History | View | Annotate | Download (7.04 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 |
* @author Nacho Brodin (nachobrodin@gmail.com).<BR> Equipo de desarrollo gvSIG.<BR> http://www.gvsig.gva.es
|
24 |
* @version 0.0
|
25 |
* @link http://www.gvsig.gva.es
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.jogr; |
29 |
|
30 |
|
31 |
|
32 |
public class JNIBase{ |
33 |
|
34 |
protected long cPtr; |
35 |
|
36 |
|
37 |
private native int getDriverCountNat(long cPtr); |
38 |
private native int getLayerCountNat(long cPtr); |
39 |
private native int getFeatureCountNat(long cPtr); |
40 |
private native int getFieldCountNat(long cPtr); |
41 |
private native int getWidthNat(long cPtr); |
42 |
private native int getPrecisionNat(long cPtr); |
43 |
|
44 |
private native int referenceNat(long cPtr); |
45 |
private native int dereferenceNat(long cPtr); |
46 |
private native int getRefCountNat(long cPtr); |
47 |
private native int getSummaryRefCountNat(long cPtr); |
48 |
|
49 |
private native int referenceFeatureDefnNat(long cPtr); |
50 |
private native int dereferenceFeatureDefnNat(long cPtr); |
51 |
private native int getReferenceCountNat(long cPtr); |
52 |
|
53 |
private native int getFieldCountFeatureNat(long cPtr); |
54 |
|
55 |
//private native int syncToDiskNat(long cPtr);//Excepciones
|
56 |
//private native int startTransactionNat(long cPtr);//Excepciones
|
57 |
//private native int commitTransactionNat(long cPtr);//Excepciones
|
58 |
//private native int rollbackTransactionNat(long cPtr);//Excepciones
|
59 |
private native int referenceLayerNat(long cPtr); |
60 |
private native int dereferenceLayerNat(long cPtr); |
61 |
private native int getRefCountLayerNat(long cPtr); |
62 |
|
63 |
private native int getOpenDSCountNat(long cPtr); |
64 |
|
65 |
//Geometry
|
66 |
private native int getDimensionNat( long cPtr); |
67 |
private native int isSimpleNat( long cPtr ); |
68 |
private native int wkbSizeNat( long cPtr ); |
69 |
|
70 |
//Point
|
71 |
private native int isEmptyPointNat( long cPtr ); //return OGRBoolean |
72 |
private native int getCoordinateDimensionPointNat( long cPtr ); |
73 |
|
74 |
//Line String
|
75 |
private native int isEmptyLineStringNat( long cPtr ); //return OGRBoolean |
76 |
private native int getCoordinateDimensionLineStringNat( long cPtr ); |
77 |
private native int getNumPointsNat( long cPtr ); |
78 |
|
79 |
//Linear Ring
|
80 |
private native int isClockwiseNat(long cPtr); |
81 |
private native int WkbSizeNat(long cPtr); |
82 |
|
83 |
//Polygon
|
84 |
private native int getNumInteriorRingsNat( long cPtr ); |
85 |
private native int wkbSizePolygonNat( long cPtr ); |
86 |
private native int getDimensionPolygonNat( long cPtr ); |
87 |
private native int getCoordinateDimensionNat( long cPtr ); |
88 |
|
89 |
//GeometryCollection
|
90 |
private native int getDimensionGeometryCollectionNat( long cPtr ); |
91 |
private native int getCoordinateDimensionGeometryCollectionNat( long cPtr ); |
92 |
|
93 |
/**
|
94 |
* Funci?n que sirve como base para funcionalidades de ogr que admiten como par?metro un long y devuelven un entero.
|
95 |
*
|
96 |
* @throws OGRException.
|
97 |
* @param msg1 Mensaje de error que se muestra cuando el puntero a objeto pasado es vacio.
|
98 |
* @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.
|
99 |
*/
|
100 |
|
101 |
|
102 |
protected int baseSimpleFunctions(int n,String msg1,String msg2)throws OGRException{ |
103 |
|
104 |
int res = 0; |
105 |
if(cPtr <= 0) |
106 |
throw new OGRException(msg1); |
107 |
|
108 |
switch(n){
|
109 |
case 0: res = getDriverCountNat(cPtr);break; |
110 |
case 1: res = getLayerCountNat(cPtr);break; |
111 |
case 2: res = getFeatureCountNat(cPtr);break; |
112 |
case 3: res = getFieldCountNat(cPtr);break; |
113 |
case 4: res = getWidthNat(cPtr);break; |
114 |
case 5: res = getPrecisionNat(cPtr);break; |
115 |
case 6: res = referenceNat(cPtr);break; |
116 |
case 7: res = dereferenceNat(cPtr);break; |
117 |
case 8: res = getRefCountNat(cPtr);break; |
118 |
case 9: res = getSummaryRefCountNat(cPtr);break; |
119 |
case 10: res = referenceFeatureDefnNat(cPtr);break; |
120 |
case 11: res = dereferenceFeatureDefnNat(cPtr);break; |
121 |
case 12: res = getReferenceCountNat(cPtr);break; |
122 |
case 13: res = getFieldCountFeatureNat(cPtr);break; |
123 |
//case 14: res = syncToDiskNat(cPtr);break;//Excepciones
|
124 |
//case 15: res = startTransactionNat( cPtr);break;//Excepciones
|
125 |
//case 16: res = commitTransactionNat( cPtr);break;//Excepciones
|
126 |
//case 17: res = rollbackTransactionNat( cPtr);break;//Excepciones
|
127 |
case 18: res = referenceLayerNat( cPtr);break; |
128 |
case 19: res = dereferenceLayerNat( cPtr);break; |
129 |
case 20: res = getRefCountLayerNat( cPtr);break; |
130 |
case 21: res = getOpenDSCountNat(cPtr);break; |
131 |
case 22: res = getDimensionNat(cPtr);break; |
132 |
case 23: res = isSimpleNat(cPtr );break; |
133 |
case 24: res = wkbSizeNat(cPtr );break; |
134 |
case 25: res = isEmptyPointNat( cPtr );break; //return OGRBoolean |
135 |
case 26: res = getCoordinateDimensionPointNat( cPtr );break; |
136 |
case 27: res = getNumPointsNat( cPtr );break; |
137 |
case 28: res = isEmptyLineStringNat( cPtr );break; //return OGRBoolean |
138 |
case 29: res = getCoordinateDimensionLineStringNat( cPtr );break; |
139 |
case 30: res = isClockwiseNat(cPtr);break; |
140 |
case 31: res = WkbSizeNat(cPtr);break; |
141 |
case 32: res = getNumInteriorRingsNat( cPtr );break; |
142 |
case 33: res = wkbSizeNat( cPtr );break; |
143 |
case 34: res = getDimensionNat( cPtr );break; |
144 |
case 35: res = getCoordinateDimensionNat( cPtr );break; |
145 |
} |
146 |
|
147 |
if(res<0) |
148 |
throw new OGRException(msg2); |
149 |
else return res; |
150 |
} |
151 |
|
152 |
/**
|
153 |
* Lanza una excepci?n dependiendo del tipo de error pasado
|
154 |
* @param err
|
155 |
* @param mensaje
|
156 |
* @throws OGRCorruptDataException
|
157 |
* @throws OGRFailureException
|
158 |
* @throws OGRNotEnoughDataException
|
159 |
* @throws OGRNotEnoughMemoryException
|
160 |
* @throws OGRUnsupportedGeometryTypeException
|
161 |
* @throws OGRUnsupportedOperationException
|
162 |
* @throws OGRUnsupportedSRSException
|
163 |
*/
|
164 |
protected void throwException(int err, String mensaje) |
165 |
throws OGRCorruptDataException, OGRFailureException, OGRNotEnoughDataException, OGRNotEnoughMemoryException, OGRUnsupportedGeometryTypeException, OGRUnsupportedOperationException, OGRUnsupportedSRSException{
|
166 |
|
167 |
switch(err){
|
168 |
case 1:throw new OGRNotEnoughDataException(mensaje); |
169 |
case 2:throw new OGRNotEnoughMemoryException(mensaje); |
170 |
case 3:throw new OGRUnsupportedGeometryTypeException(mensaje); |
171 |
case 4:throw new OGRUnsupportedOperationException(mensaje); |
172 |
case 5:throw new OGRCorruptDataException(mensaje); |
173 |
case 6:throw new OGRFailureException(mensaje); |
174 |
case 7:throw new OGRUnsupportedSRSException(mensaje); |
175 |
default : return; |
176 |
} |
177 |
} |
178 |
|
179 |
/**
|
180 |
* Obtiene el puntero a C del objeto
|
181 |
* @param cPtr long con la direcci?n de memoria del objeto
|
182 |
*/
|
183 |
public long getPtro() { |
184 |
return cPtr;
|
185 |
} |
186 |
|
187 |
static {
|
188 |
System.loadLibrary("jgdal2.0.4"); |
189 |
} |
190 |
} |