Revision 10988
branches/v10/libraries/libjni-gdal/.project | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<projectDescription> |
3 |
<name>jgdal-src-0.0.0</name>
|
|
3 |
<name>libjni-gdal</name>
|
|
4 | 4 |
<comment></comment> |
5 | 5 |
<projects> |
6 | 6 |
</projects> |
branches/v10/libraries/libjni-gdal/src/rasterband_interfaz.c | ||
---|---|---|
730 | 730 |
|
731 | 731 |
return (jint)interp; |
732 | 732 |
} |
733 |
|
|
733 |
|
branches/v10/libraries/libjni-gdal/src/gdal_interfaz.c | ||
---|---|---|
56 | 56 |
#include "es_gva_cit_jgdal_JNIBase.h" |
57 | 57 |
#include "gdal.h" |
58 | 58 |
#include "cpl_string.h" |
59 |
#include "signal.h" |
|
59 | 60 |
|
60 | 61 |
|
61 | 62 |
|
... | ... | |
71 | 72 |
GDALDatasetH *dataset; |
72 | 73 |
jlong jresult = 0 ; |
73 | 74 |
FILE *fich; |
74 |
|
|
75 |
|
|
75 | 76 |
pszFilename = (*env)->GetStringUTFChars(env, pszF, 0); |
76 | 77 |
|
77 | 78 |
fich=fopen( pszFilename, "r" ); |
... | ... | |
99 | 100 |
/******************************************************************************/ |
100 | 101 |
// OpenArray |
101 | 102 |
/******************************************************************************/ |
103 |
void handler(int n) { |
|
104 |
raise(SIGALRM); |
|
105 |
} |
|
102 | 106 |
|
103 |
|
|
104 | 107 |
JNIEXPORT jlong JNICALL Java_es_gva_cit_jgdal_Gdal_openArrayNat |
105 | 108 |
(JNIEnv *env, jobject obj, jbyteArray pszF, jint acc){ |
106 | 109 |
|
... | ... | |
110 | 113 |
jlong jresult = 0 ; |
111 | 114 |
FILE *fich; |
112 | 115 |
jsize longitud = 0, i; |
113 |
char *p;
|
|
114 |
|
|
116 |
signal(SIGSEGV, handler);
|
|
117 |
|
|
115 | 118 |
longitud = (*env)->GetArrayLength(env, pszF); |
116 | 119 |
pszFilename = (*env)->GetByteArrayElements(env, pszF, 0); |
117 | 120 |
|
... | ... | |
157 | 160 |
|
158 | 161 |
int res=-1; |
159 | 162 |
GDALDatasetH *dt = (GDALDatasetH *) 0 ; |
160 |
|
|
161 |
dt = *(GDALDatasetH **)&cPtr;
|
|
163 |
|
|
164 |
dt = *(GDALDatasetH **)&cPtr; |
|
162 | 165 |
if(dt!=NULL) |
163 | 166 |
res = GDALGetRasterXSize(dt); |
164 | 167 |
|
... | ... | |
501 | 504 |
return typeName; |
502 | 505 |
} |
503 | 506 |
|
504 |
|
|
507 |
|
branches/v10/libraries/libjni-gdal/src/es/gva/cit/jgdal/DiagSignalHandler.java | ||
---|---|---|
1 |
package es.gva.cit.jgdal; |
|
2 |
import sun.misc.Signal; |
|
3 |
import sun.misc.SignalHandler; |
|
4 |
import java.lang.reflect.*; |
|
5 |
import java.awt.event.ActionEvent; |
|
6 |
import java.awt.event.ActionListener; |
|
7 |
import java.io.IOException; |
|
8 |
import javax.swing.JFrame; |
|
9 |
import javax.swing.JPanel; |
|
10 |
import javax.swing.JButton; |
|
11 |
import java.awt.BorderLayout; |
|
12 |
import javax.swing.JLabel; |
|
13 |
|
|
14 |
class DiagSignalHandler implements SignalHandler { |
|
15 |
|
|
16 |
private SignalHandler oldHandler; |
|
17 |
private static boolean active = false; |
|
18 |
|
|
19 |
//Static method to install the signal handler |
|
20 |
public static DiagSignalHandler install(String signalName) { |
|
21 |
Signal diagSignal = new Signal(signalName); |
|
22 |
DiagSignalHandler diagHandler = new DiagSignalHandler(); |
|
23 |
diagHandler.oldHandler = Signal.handle(diagSignal,diagHandler); |
|
24 |
return diagHandler; |
|
25 |
} |
|
26 |
// Signal handler method |
|
27 |
public void handle(Signal sig) { |
|
28 |
if(active) |
|
29 |
return; |
|
30 |
active = true; |
|
31 |
JFrame frame = new JFrame(); |
|
32 |
frame.setSize(400, 150); |
|
33 |
JPanel p = new JPanel(); |
|
34 |
JLabel l = new JLabel("SIGSEGV signal handler. Signal: " + sig); |
|
35 |
p.setLayout(new BorderLayout()); |
|
36 |
JButton b = new JButton("Close"); |
|
37 |
b.addActionListener(new ActionListener() { |
|
38 |
public void actionPerformed(ActionEvent e) { |
|
39 |
System.out.println("Handler test"); |
|
40 |
} |
|
41 |
}); |
|
42 |
p.add(l, BorderLayout.NORTH); |
|
43 |
p.add(b, BorderLayout.SOUTH); |
|
44 |
|
|
45 |
frame.getContentPane().add(p); |
|
46 |
frame.show(); |
|
47 |
} |
|
48 |
} |
|
0 | 49 |
branches/v10/libraries/libjni-gdal/src/es/gva/cit/jgdal/GdalDriver.java | ||
---|---|---|
129 | 129 |
|
130 | 130 |
public Gdal createCopy( String file, Gdal src, boolean bstrict )throws GdalException{ |
131 | 131 |
|
132 |
if(cPtr <= 0) |
|
133 |
throw new GdalException("Error en createCopy(). La llamada Open no tuvo exito"); |
|
134 |
|
|
135 | 132 |
long ptr; |
136 | 133 |
if(bstrict) |
137 | 134 |
ptr = createCopyNat(cPtr,file,src.getPtro(),1); |
138 | 135 |
else |
139 | 136 |
ptr = createCopyNat(cPtr,file,src.getPtro(),0); |
140 | 137 |
|
141 |
if (ptr<0) |
|
142 |
throw new GdalException("Error en createCopy(). No se ha podido obtener el dataset."); |
|
143 |
else |
|
144 |
return (new Gdal(ptr)); |
|
138 |
return (new Gdal(ptr)); |
|
145 | 139 |
} |
146 | 140 |
|
147 | 141 |
|
... | ... | |
183 | 177 |
|
184 | 178 |
long papszOptions=-1; |
185 | 179 |
|
186 |
if(cPtr <= 0) |
|
187 |
throw new GdalException("Error en createCopy(). La llamada Open no tuvo exito"); |
|
188 |
|
|
189 | 180 |
long ptr; |
190 | 181 |
if(bstrict) |
191 | 182 |
ptr = createCopyParamsNat(cPtr, file, src.getPtro(), 1, selectOptions(params)); |
192 | 183 |
else |
193 | 184 |
ptr = createCopyParamsNat(cPtr, file, src.getPtro(), 0, selectOptions(params)); |
194 | 185 |
|
195 |
if (ptr<0) |
|
196 |
throw new GdalException("Error en createCopy(). No se ha podido obtener el dataset."); |
|
197 |
else |
|
198 |
return (new Gdal(ptr)); |
|
186 |
return (new Gdal(ptr)); |
|
199 | 187 |
} |
200 | 188 |
|
201 | 189 |
|
... | ... | |
213 | 201 |
public Gdal create(String filename, int nXSize, int nYSize, int nBands, int nType, String[] params)throws GdalException{ |
214 | 202 |
|
215 | 203 |
long papszOptions=-1; |
216 |
|
|
217 |
if(cPtr <= 0) |
|
218 |
throw new GdalException("Error en create. La llamada Open no tuvo exito"); |
|
219 |
|
|
204 |
|
|
220 | 205 |
long ptr = createNat(cPtr, filename, nXSize, nYSize, nBands, nType, selectOptions(params)); |
221 | 206 |
|
222 |
if (ptr<0) |
|
223 |
throw new GdalException("Error en createCopy(). No se ha podido obtener el dataset."); |
|
224 |
else |
|
225 |
return (new Gdal(ptr)); |
|
207 |
return (new Gdal(ptr)); |
|
226 | 208 |
|
227 | 209 |
} |
228 | 210 |
|
branches/v10/libraries/libjni-gdal/src/es/gva/cit/jgdal/Gdal.java | ||
---|---|---|
55 | 55 |
|
56 | 56 |
import java.io.*; |
57 | 57 |
import java.util.Date; |
58 |
import sun.misc.Signal; |
|
59 |
import sun.misc.SignalHandler; |
|
60 |
import java.lang.reflect.*; |
|
58 | 61 |
|
59 | 62 |
//import es.gva.cit.jgdal.GdalException; |
60 | 63 |
|
... | ... | |
68 | 71 |
*/ |
69 | 72 |
|
70 | 73 |
public class Gdal extends JNIBase{ |
71 |
|
|
72 |
|
|
73 | 74 |
//CONSTANTES |
74 | 75 |
|
75 | 76 |
//GDALAccess |
... | ... | |
111 | 112 |
/** |
112 | 113 |
*Constructor a partir de la direcci?n de memoria |
113 | 114 |
*/ |
114 |
|
|
115 | 115 |
public Gdal(long cPtr){ |
116 | 116 |
this.cPtr=cPtr; |
117 | 117 |
} |
... | ... | |
119 | 119 |
/** |
120 | 120 |
*Constructor generico |
121 | 121 |
*/ |
122 |
|
|
123 | 122 |
public Gdal(){} |
124 | 123 |
|
125 | 124 |
/** |
126 | 125 |
* Devuelve la direcci?n de memoria del objeto dataset en C. |
127 | 126 |
*/ |
128 |
|
|
129 | 127 |
public long getPtro(){return cPtr;} |
130 | 128 |
|
131 | 129 |
/** |
... | ... | |
135 | 133 |
* @param access Apertura en solo lectura o escritura. |
136 | 134 |
* @throws GdalException |
137 | 135 |
*/ |
138 |
|
|
139 |
public void open(String pszFilename, int access)throws GdalException, IOException{ |
|
140 |
|
|
136 |
public void open(String pszFilename, int access)throws GdalException, IOException { |
|
141 | 137 |
File f = new File( pszFilename ); |
142 | 138 |
if(!f.exists()) |
143 |
throw new IOException("El archivo "+pszFilename+" no existe");
|
|
139 |
throw new GdalException("El archivo "+pszFilename+" no existe");
|
|
144 | 140 |
|
145 | 141 |
if(!f.canRead()) |
146 |
throw new IOException("El archivo no puede leerse"); |
|
142 |
throw new GdalException("El archivo no puede leerse"); |
|
143 |
|
|
144 |
/*String os = System.getProperty("os.name"); |
|
145 |
if(os.toLowerCase().startsWith("windows")) |
|
146 |
DiagSignalHandler.install("ABRT"); |
|
147 |
else |
|
148 |
DiagSignalHandler.install("ALRM");*/ |
|
149 |
//DiagSignalHandler.install("ALRM"); |
|
147 | 150 |
|
148 | 151 |
cPtr=openArrayNat(pszFilename.getBytes(), access); |
149 | 152 |
//cPtr=openNat(pszFilename, access); |
150 |
|
|
151 |
if(cPtr<=0) |
|
152 |
throw new GdalException("Error en Open de GDAL"); |
|
153 |
|
|
154 | 153 |
} |
155 | 154 |
|
156 | 155 |
/** |
... | ... | |
159 | 158 |
* @throws GdalException |
160 | 159 |
* @return Array de Strings que corresponden a los metadatos que ofrece la im?gen |
161 | 160 |
*/ |
162 |
|
|
163 |
public String[] getMetadata()throws GdalException{ |
|
164 |
|
|
165 |
|
|
166 |
if(cPtr <= 0) |
|
167 |
throw new GdalException("Error en GDALGetMetadata(). La llamada GDALOpen no tuvo exito"); |
|
161 |
public String[] getMetadata()throws GdalException { |
|
168 | 162 |
String[] res = getMetadataNat(cPtr,null); |
169 | 163 |
if(res == null) |
170 | 164 |
return new String[0]; |
... | ... | |
180 | 174 |
* @return Objeto GdalRasterBand que representa la banda recuperada |
181 | 175 |
*/ |
182 | 176 |
|
183 |
public GdalRasterBand getRasterBand(int hBand)throws GdalException{ |
|
184 |
|
|
177 |
public GdalRasterBand getRasterBand(int hBand)throws GdalException { |
|
185 | 178 |
long cPtr_rb; |
186 |
|
|
187 |
if(cPtr <= 0) |
|
188 |
throw new GdalException("Error en GDALGetRasterBand(). La llamada GDALOpen no tuvo exito"); |
|
189 |
|
|
179 |
|
|
190 | 180 |
cPtr_rb = getRasterBandNat(cPtr,hBand); |
191 | 181 |
|
192 |
if(cPtr_rb < 0) |
|
193 |
throw new GdalException("Error en GetRasterBand(). No ha podido obtenerse una banda"); |
|
194 |
else return new GdalRasterBand(cPtr_rb); |
|
195 |
|
|
182 |
return new GdalRasterBand(cPtr_rb); |
|
196 | 183 |
} |
197 | 184 |
|
198 | 185 |
|
... | ... | |
203 | 190 |
* @return Devuelve un entero con la longitud de la im?gen en el eje X en pixels. |
204 | 191 |
* @throws GdalException |
205 | 192 |
*/ |
206 |
|
|
207 |
public int getRasterXSize()throws GdalException{ |
|
208 |
|
|
193 |
public int getRasterXSize()throws GdalException { |
|
209 | 194 |
String msg1="Error en GDALGetRasterXSize. La llamada GDALOpen no tuvo ?xito"; |
210 | 195 |
String msg2="Error en tama?o X"; |
211 | 196 |
return baseSimpleFunctions(5,msg1,msg2); |
212 |
|
|
213 | 197 |
} |
214 | 198 |
|
215 | 199 |
|
... | ... | |
219 | 203 |
* @return Devuelve un entero con la longitud de la im?gen en el eje Y en pixels. |
220 | 204 |
* @throws GdalException |
221 | 205 |
*/ |
222 |
|
|
223 |
public int getRasterYSize()throws GdalException{ |
|
224 |
|
|
206 |
public int getRasterYSize()throws GdalException { |
|
225 | 207 |
String msg1="Error en GDALGetRasterYSize. La llamada GDALOpen no tuvo ?xito"; |
226 | 208 |
String msg2="Error en tama?o Y"; |
227 | 209 |
return baseSimpleFunctions(6,msg1,msg2); |
228 |
|
|
229 | 210 |
} |
230 | 211 |
|
231 | 212 |
|
... | ... | |
235 | 216 |
* @return Devuelve un entero con el n?mero de bandas que contiene la im?gen. |
236 | 217 |
* @throws GdalException |
237 | 218 |
*/ |
238 |
|
|
239 |
public int getRasterCount()throws GdalException{ |
|
240 |
|
|
219 |
public int getRasterCount()throws GdalException { |
|
241 | 220 |
String msg1="Error en GDALGetRasterCount. . La llamada GDALOpen no tuvo ?xito"; |
242 | 221 |
String msg2="Error en el conteo de n?mero de bandas"; |
243 | 222 |
return baseSimpleFunctions(7,msg1,msg2); |
244 |
|
|
245 | 223 |
} |
246 | 224 |
|
247 | 225 |
|
... | ... | |
251 | 229 |
* @return Devuelve un vector de doubles que contiene los valores de coordenadas de origen y pixelSize. |
252 | 230 |
* @throws GdalException |
253 | 231 |
*/ |
254 |
|
|
255 |
public GeoTransform getGeoTransform()throws GdalException{ |
|
256 |
|
|
257 |
|
|
258 |
if(cPtr <= 0) |
|
259 |
throw new GdalException("Error en getGeoTransform(). La llamada Open no tuvo exito"); |
|
260 |
|
|
232 |
public GeoTransform getGeoTransform()throws GdalException { |
|
261 | 233 |
GeoTransform gt=new GeoTransform(); |
262 | 234 |
|
263 |
if(getGeoTransformNat(cPtr,gt)<0)
|
|
235 |
if(getGeoTransformNat(cPtr,gt) < 0)
|
|
264 | 236 |
throw new GdalException("Error en getGeoTransform(). No se han obtenido valores para geoTransform."); |
265 | 237 |
else{ |
266 | 238 |
|
... | ... | |
274 | 246 |
* @return Cadena con el nombre del driver |
275 | 247 |
* @throws GdalException |
276 | 248 |
*/ |
277 |
|
|
278 |
public String getDriverShortName()throws GdalException{ |
|
279 |
|
|
280 |
|
|
281 |
if(cPtr <= 0) |
|
282 |
throw new GdalException("Error en getDriverShortName(). La llamada Open no tuvo exito"); |
|
249 |
public String getDriverShortName()throws GdalException { |
|
283 | 250 |
String shortName = getDriverShortNameNat(cPtr); |
284 | 251 |
|
285 | 252 |
if(shortName == null) |
286 | 253 |
throw new GdalException("Error en getDriverShortName(). No ha podido obtenerse el driver"); |
287 | 254 |
else |
288 | 255 |
return shortName; |
289 |
|
|
290 | 256 |
} |
291 | 257 |
|
292 | 258 |
/** |
... | ... | |
295 | 261 |
* @return Devuelve un vector de doubles que contiene los valores de coordenadas de origen y pixelSize. |
296 | 262 |
* @throws GdalException |
297 | 263 |
*/ |
298 |
|
|
299 |
public void setGeoTransform(GeoTransform gt)throws GdalException{ |
|
300 |
|
|
301 |
|
|
302 |
if(cPtr <= 0) |
|
303 |
throw new GdalException("Error en setGeoTransform(). La llamada Open no tuvo exito"); |
|
304 |
|
|
264 |
public void setGeoTransform(GeoTransform gt)throws GdalException { |
|
305 | 265 |
int res = setGeoTransformNat(cPtr,gt); |
306 |
|
|
307 |
if(res<0) |
|
308 |
throw new GdalException("Error en getGeoTransform(). No se ha podido a?adir valores para geoTransform. Es posible que el formato no lo soporte."); |
|
309 |
|
|
310 | 266 |
} |
311 | 267 |
|
312 | 268 |
/** |
... | ... | |
315 | 271 |
* @return Devuelve un String con los datos del sistema de coordenadas de referencia. |
316 | 272 |
* @throws GdalException |
317 | 273 |
*/ |
318 |
|
|
319 |
public String getProjectionRef()throws GdalException{ |
|
320 |
|
|
321 |
if(cPtr <= 0) |
|
322 |
throw new GdalException("Error en getGetProjectionRef(). La llamada Open no tuvo exito"); |
|
323 |
|
|
324 |
|
|
274 |
public String getProjectionRef()throws GdalException { |
|
325 | 275 |
String res = getProjectionRefNat(cPtr); |
326 | 276 |
|
327 | 277 |
if(res == null)return new String(""); |
328 | 278 |
else return res; |
329 |
|
|
330 | 279 |
} |
331 | 280 |
|
332 | 281 |
/** |
... | ... | |
334 | 283 |
* |
335 | 284 |
* @throws GdalException |
336 | 285 |
*/ |
337 |
|
|
338 |
public void close()throws GdalException{ |
|
339 |
|
|
340 |
if(cPtr <= 0) |
|
341 |
throw new GdalException("Error en Close(). La llamada Open no tuvo exito"); |
|
286 |
public void close()throws GdalException { |
|
342 | 287 |
closeNat(cPtr); |
343 |
|
|
344 | 288 |
} |
345 | 289 |
|
346 | 290 |
/** |
... | ... | |
348 | 292 |
* |
349 | 293 |
* @param name Nombre del driver |
350 | 294 |
*/ |
351 |
|
|
352 |
public static GdalDriver getDriverByName(String name)throws GdalException{
|
|
295 |
public static GdalDriver getDriverByName(String name)throws GdalException { |
|
296 |
long ptrdrv = -1;
|
|
353 | 297 |
|
354 |
long ptrdrv=-1; |
|
355 |
|
|
356 |
ptrdrv=getDriverByNameNat(name); |
|
298 |
ptrdrv = getDriverByNameNat(name); |
|
357 | 299 |
//System.out.println("ptrdrv="+ptrdrv); |
358 |
if(ptrdrv > 0) |
|
359 |
return (new GdalDriver(ptrdrv)); |
|
360 |
else |
|
361 |
throw new GdalException("Error en getDriverByName(). No se ha podido obtener el driver."); |
|
362 | 300 |
|
301 |
return (new GdalDriver(ptrdrv)); |
|
363 | 302 |
} |
364 | 303 |
|
365 | 304 |
|
... | ... | |
369 | 308 |
* @return Devuelve un entero con el n?mero de bandas que contiene la im?gen. |
370 | 309 |
* @throws GdalException |
371 | 310 |
*/ |
372 |
|
|
373 |
public int getGCPCount()throws GdalException{ |
|
374 |
|
|
311 |
public int getGCPCount()throws GdalException { |
|
375 | 312 |
String msg1="Error en GDALGetRasterCount. . La llamada GDALOpen no tuvo ?xito"; |
376 | 313 |
String msg2="Error en el conteo de n?mero de bandas"; |
377 | 314 |
return baseSimpleFunctions(8,msg1,msg2); |
378 |
|
|
379 | 315 |
} |
380 | 316 |
|
381 | 317 |
/** |
... | ... | |
383 | 319 |
*@param proj proyecci?n |
384 | 320 |
*@throws GdalException |
385 | 321 |
*/ |
386 |
|
|
387 |
public void setProjection(String proj)throws GdalException{ |
|
388 |
|
|
389 |
if(cPtr <= 0) |
|
390 |
throw new GdalException("Error en setProjection(). La llamada Open no tuvo exito"); |
|
391 |
|
|
322 |
public void setProjection(String proj)throws GdalException { |
|
392 | 323 |
int res = setProjectionNat(cPtr, proj); |
393 | 324 |
|
394 |
if(res<0)
|
|
325 |
if(res < 0)
|
|
395 | 326 |
throw new GdalException("Error en setProjection(). No se ha podido asignar la proyecci?n."); |
396 | 327 |
} |
397 | 328 |
|
... | ... | |
419 | 350 |
* @return Cadena con el nombre del tipo de banda de color |
420 | 351 |
* @throws GdalException |
421 | 352 |
*/ |
422 |
|
|
423 |
public String getColorInterpretationName(int colorInterp)throws GdalException{ |
|
424 |
|
|
425 |
if(cPtr <= 0) |
|
426 |
throw new GdalException("Error en getColorInterpretationName(). La llamada Open no tuvo exito"); |
|
353 |
public String getColorInterpretationName(int colorInterp)throws GdalException { |
|
427 | 354 |
String bandTypeName = getColorInterpretationNameNat(cPtr, colorInterp); |
428 | 355 |
|
429 | 356 |
if(bandTypeName == null) |
430 | 357 |
throw new GdalException("Error en getColorInterpretationName(). No ha podido obtenerse el tipo de banda de color"); |
431 | 358 |
else |
432 | 359 |
return bandTypeName; |
433 |
|
|
434 | 360 |
} |
435 | 361 |
|
436 |
} |
|
362 |
} |
branches/v10/libraries/libjni-gdal/src/es/gva/cit/jgdal/JNIBase.java | ||
---|---|---|
89 | 89 |
protected int baseSimpleFunctions(int n,String msg1,String msg2)throws GdalException{ |
90 | 90 |
|
91 | 91 |
int res = 0; |
92 |
if(cPtr <= 0) |
|
93 |
throw new GdalException(msg1); |
|
94 | 92 |
|
95 | 93 |
switch(n){ |
96 | 94 |
case 0: res = getRasterBandXSizeNat(cPtr);break; |
... | ... | |
115 | 113 |
static{ |
116 | 114 |
String os = System.getProperty("os.name"); |
117 | 115 |
if(os.toLowerCase().startsWith("windows")) |
118 |
System.loadLibrary("jgdal060");
|
|
116 |
System.loadLibrary("jgdal061");
|
|
119 | 117 |
else |
120 | 118 |
System.loadLibrary("jgdal"); |
121 | 119 |
|
branches/v10/libraries/libjni-gdal/src/es/gva/cit/jgdal/GdalRasterBand.java | ||
---|---|---|
84 | 84 |
* Asigna el identificador de la banda |
85 | 85 |
*/ |
86 | 86 |
|
87 |
public GdalRasterBand(long cPtr){ |
|
88 |
|
|
87 |
public GdalRasterBand(long cPtr) { |
|
89 | 88 |
this.cPtr=cPtr; |
90 |
|
|
91 | 89 |
} |
92 | 90 |
|
93 | 91 |
|
... | ... | |
108 | 106 |
|
109 | 107 |
public GdalBuffer readRaster(int nXOff, int nYOff, int nXSize, int nYSize, |
110 | 108 |
int BufXSize, int BufYSize, |
111 |
int eBufType)throws GdalException{ |
|
112 |
|
|
113 |
if(cPtr <= 0) |
|
114 |
throw new GdalException("Error en GDALGetRasterBand(). La llamada GDALOpen no tuvo exito"); |
|
115 |
|
|
116 |
|
|
109 |
int eBufType)throws GdalException { |
|
117 | 110 |
GdalBuffer buffer = readRasterNat(cPtr, nXOff, nYOff, nXSize, nYSize, BufXSize, BufYSize, eBufType); |
118 | 111 |
|
119 | 112 |
if(buffer!=null) |
120 | 113 |
return buffer; |
121 | 114 |
else |
122 | 115 |
return null; |
123 |
|
|
124 | 116 |
} |
125 | 117 |
|
126 | 118 |
/** |
... | ... | |
138 | 130 |
*/ |
139 | 131 |
|
140 | 132 |
public void writeRaster(int nXOff, int nYOff, int nXSize, int nYSize, GdalBuffer buf, int eBufType)throws GdalException{ |
141 |
|
|
142 |
if(cPtr <= 0) |
|
143 |
throw new GdalException("Error en GDALGetRasterBand(). La llamada GDALOpen no tuvo exito"); |
|
144 |
|
|
145 | 133 |
GdalBuffer buffer=new GdalBuffer(); |
146 | 134 |
switch(eBufType){ |
147 | 135 |
case 0: |
... | ... | |
171 | 159 |
return; |
172 | 160 |
} |
173 | 161 |
|
174 |
writeRasterNat(cPtr, nXOff, nYOff, nXSize, nYSize, buffer, eBufType); |
|
175 |
|
|
162 |
writeRasterNat(cPtr, nXOff, nYOff, nXSize, nYSize, buffer, eBufType); |
|
176 | 163 |
} |
177 | 164 |
|
178 | 165 |
/** |
... | ... | |
181 | 168 |
*@throws GdalException |
182 | 169 |
*/ |
183 | 170 |
|
184 |
public int getRasterBandXSize()throws GdalException{ |
|
185 |
|
|
171 |
public int getRasterBandXSize()throws GdalException { |
|
186 | 172 |
String msg1="Error en getRasterBandXSize(). La llamada getRasterBand no tuvo exito"; |
187 | 173 |
String msg2="Tama?o de banda erroneo devuelto por GetRasterBandXSize"; |
188 | 174 |
|
... | ... | |
195 | 181 |
*@throws GdalException |
196 | 182 |
*/ |
197 | 183 |
|
198 |
public int getRasterBandYSize()throws GdalException{ |
|
199 |
|
|
184 |
public int getRasterBandYSize()throws GdalException { |
|
200 | 185 |
String msg1="Error en getRasterBandYSize(). La llamada getRasterBand no tuvo exito"; |
201 | 186 |
String msg2="Tama?o de banda erroneo devuelto por GetRasterBandYSize"; |
202 | 187 |
|
... | ... | |
210 | 195 |
* @throws GdalException |
211 | 196 |
*/ |
212 | 197 |
|
213 |
public int getOverviewCount()throws GdalException{ |
|
214 |
|
|
198 |
public int getOverviewCount()throws GdalException { |
|
215 | 199 |
String msg1="Error en getOverviewCount(). La llamada getRasterBand no tuvo exito"; |
216 | 200 |
String msg2="Error al obtener el n?mero de overviews"; |
217 | 201 |
|
... | ... | |
227 | 211 |
* @throws GdalException |
228 | 212 |
*/ |
229 | 213 |
|
230 |
public GdalRasterBand getOverview(int i)throws GdalException{ |
|
231 |
|
|
214 |
public GdalRasterBand getOverview(int i)throws GdalException { |
|
232 | 215 |
long cPtr_ov; |
233 |
|
|
234 |
if(cPtr <= 0) |
|
235 |
throw new GdalException("Error en getOverview(). La llamada GDALOpen no tuvo exito"); |
|
236 | 216 |
|
237 | 217 |
if(i<0 && i>=this.getOverviewCount()) |
238 | 218 |
throw new GdalException("El overview seleccionado no existe"); |
239 | 219 |
|
240 | 220 |
cPtr_ov = getOverviewNat(cPtr,i); |
241 | 221 |
|
242 |
if(cPtr_ov < 0) |
|
243 |
throw new GdalException("No ha podido obtenerse el overview seleccionado"); |
|
244 |
|
|
245 | 222 |
return new GdalRasterBand(cPtr_ov); |
246 | 223 |
} |
247 | 224 |
|
... | ... | |
252 | 229 |
* @throws GdalException |
253 | 230 |
*/ |
254 | 231 |
|
255 |
public int getBlockXSize()throws GdalException{ |
|
256 |
|
|
232 |
public int getBlockXSize()throws GdalException { |
|
257 | 233 |
String msg1="Error en getBlockXSize(). La llamada getRasterBand no tuvo exito"; |
258 | 234 |
String msg2="Tama?o de bloque erroneo devuelto por GetBlockXSize"; |
259 | 235 |
|
... | ... | |
267 | 243 |
* @throws GdalException |
268 | 244 |
*/ |
269 | 245 |
|
270 |
public int getBlockYSize()throws GdalException{ |
|
271 |
|
|
246 |
public int getBlockYSize()throws GdalException { |
|
272 | 247 |
String msg1="Error en getBlockXSize(). La llamada getRasterBand no tuvo exito"; |
273 | 248 |
String msg2="Tama?o de bloque erroneo devuelto por GetBlockYSize"; |
274 | 249 |
|
... | ... | |
281 | 256 |
* @throws GdalException |
282 | 257 |
*/ |
283 | 258 |
|
284 |
public int getRasterDataType()throws GdalException{ |
|
285 |
|
|
259 |
public int getRasterDataType()throws GdalException { |
|
286 | 260 |
String msg1="Error en getRasterDataType(). La llamada getRasterBand no tuvo exito"; |
287 | 261 |
String msg2="Tipo de dato devuelto por GetRasterDataType erroneo"; |
288 | 262 |
|
... | ... | |
292 | 266 |
/** |
293 | 267 |
* Obtiene la tabla de color asociada a la imagen |
294 | 268 |
*/ |
295 |
public GdalColorTable getRasterColorTable()throws GdalException{ |
|
296 |
if(cPtr <= 0) |
|
297 |
throw new GdalException("Error en getRasterColorTable(). La llamada GDALOpen no tuvo exito"); |
|
298 |
|
|
269 |
public GdalColorTable getRasterColorTable()throws GdalException { |
|
299 | 270 |
GdalColorTable gct = null; |
300 | 271 |
long l = getRasterColorTableNat(cPtr); |
301 |
if( l>0 )
|
|
272 |
if(l > 0)
|
|
302 | 273 |
gct = new GdalColorTable(l); |
303 | 274 |
else |
304 | 275 |
return null; |
... | ... | |
323 | 294 |
|
324 | 295 |
public GdalBuffer readRasterWithPalette(int nXOff, int nYOff, int nXSize, int nYSize, |
325 | 296 |
int BufXSize, int BufYSize, |
326 |
int eBufType)throws GdalException{ |
|
327 |
|
|
328 |
if(cPtr <= 0) |
|
329 |
throw new GdalException("Error en GDALGetRasterBand(). La llamada GDALOpen no tuvo exito"); |
|
330 |
|
|
331 |
|
|
297 |
int eBufType)throws GdalException { |
|
332 | 298 |
GdalBuffer buffer = readRasterWithPaletteNat(cPtr, nXOff, nYOff, nXSize, nYSize, BufXSize, BufYSize, eBufType); |
333 | 299 |
|
334 | 300 |
if(buffer!=null) |
335 | 301 |
return buffer; |
336 | 302 |
else |
337 | 303 |
return null; |
338 |
|
|
339 | 304 |
} |
340 | 305 |
|
341 | 306 |
/** |
342 | 307 |
*Devuelve el valor de NoData |
343 | 308 |
*/ |
344 | 309 |
|
345 |
public double getRasterNoDataValue()throws GdalException{ |
|
346 |
if(cPtr <= 0) |
|
347 |
throw new GdalException("Error en GDALGetRasterBand(). La llamada GDALOpen no tuvo exito"); |
|
310 |
public double getRasterNoDataValue()throws GdalException { |
|
348 | 311 |
return getRasterNoDataValueNat(cPtr); |
349 | 312 |
} |
350 | 313 |
|
... | ... | |
355 | 318 |
* @return Array de Strings que corresponden a los metadatos que ofrece la im?gen |
356 | 319 |
*/ |
357 | 320 |
|
358 |
public String[] getMetadata()throws GdalException{ |
|
359 |
if(cPtr <= 0) |
|
360 |
throw new GdalException("Error en GDALGetMetadata(). La llamada GDALOpen no tuvo exito"); |
|
321 |
public String[] getMetadata()throws GdalException { |
|
361 | 322 |
String[] res = getMetadataNat(cPtr,null); |
362 | 323 |
if(res == null) |
363 | 324 |
return new String[0]; |
364 | 325 |
else return res; |
365 |
|
|
366 | 326 |
} |
367 | 327 |
|
368 | 328 |
/** |
... | ... | |
371 | 331 |
* @throws GdalException |
372 | 332 |
*/ |
373 | 333 |
|
374 |
public int getRasterColorInterpretation()throws GdalException{ |
|
375 |
if(cPtr <= 0) |
|
376 |
throw new GdalException("Error en getColorInterpretationName(). La llamada Open no tuvo exito"); |
|
334 |
public int getRasterColorInterpretation()throws GdalException { |
|
377 | 335 |
int bandType = getRasterColorInterpretationNat(cPtr); |
378 | 336 |
return bandType; |
379 | 337 |
} |
branches/v10/libraries/libjni-gdal/src/es/gva/cit/jgdal/GdalColorTable.java | ||
---|---|---|
23 | 23 |
* @throws GdalException |
24 | 24 |
*/ |
25 | 25 |
public int getColorEntryCount() throws GdalException{ |
26 |
if(cPtr <= 0) |
|
27 |
throw new GdalException("Error en getColorEntryCount(). La creaci?n de la tabla no tuvo exito"); |
|
28 |
|
|
26 |
|
|
29 | 27 |
return getColorEntryCountNat(cPtr); |
30 | 28 |
} |
31 | 29 |
|
... | ... | |
37 | 35 |
* @throws GdalException |
38 | 36 |
*/ |
39 | 37 |
public GdalColorEntry getColorEntryAsRGB(int pos) throws GdalException{ |
40 |
if(cPtr <= 0) |
|
41 |
throw new GdalException("Error en getColorEntryAsRGB(). La creaci?n de la tabla no tuvo exito"); |
|
38 |
|
|
42 | 39 |
GdalColorEntry entry = new GdalColorEntry(); |
43 | 40 |
short[] values = getColorEntryAsRGBNat(cPtr, pos); |
44 | 41 |
entry.c1 = values[0]; |
Also available in: Unified diff