Revision 3735
org.gvsig.raster.gdal/tags/pre-remove-jgdal/org.gvsig.raster.gdal/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/gdal/io/GdalNative.java | ||
---|---|---|
49 | 49 |
import org.gvsig.jgdal.GdalBuffer; |
50 | 50 |
import org.gvsig.jgdal.GdalColorEntry; |
51 | 51 |
import org.gvsig.jgdal.GdalColorTable; |
52 |
import org.gvsig.jgdal.GdalDataset; |
|
52 | 53 |
import org.gvsig.jgdal.GdalException; |
53 | 54 |
import org.gvsig.jgdal.GdalRasterBand; |
54 | 55 |
import org.gvsig.jgdal.GeoTransform; |
... | ... | |
70 | 71 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
71 | 72 |
*/ |
72 | 73 |
public class GdalNative extends Gdal implements Disposable { |
73 |
private boolean isInitialized = false; |
|
74 |
// private boolean isInitialized = false;
|
|
74 | 75 |
private String fileName = null; |
75 | 76 |
private String shortName = ""; |
76 | 77 |
public GeoTransform trans = null; |
... | ... | |
185 | 186 |
if (data == null) |
186 | 187 |
throw new GdalException("Error en la apertura del fichero. El fichero no tiene un formato v?lido."); |
187 | 188 |
|
188 |
return Dataset.getCPtr(data); |
|
189 |
return GdalDataset.getCPtr(data);
|
|
189 | 190 |
} |
190 | 191 |
|
191 |
public GdalNative(long cPtr, String fName) throws GdalException, IOException { |
|
192 |
super(cPtr); |
|
193 |
isInitialized = true; |
|
194 |
init(fName); |
|
195 |
} |
|
192 |
// public GdalNative(long cPtr, String fName) throws GdalException, IOException {
|
|
193 |
// super(cPtr);
|
|
194 |
// isInitialized = true;
|
|
195 |
// init(fName);
|
|
196 |
// }
|
|
196 | 197 |
|
197 | 198 |
private void init(String fName) throws GdalException, IOException { |
198 | 199 |
gdalJNI.AllRegister(); |
... | ... | |
202 | 203 |
open = true; |
203 | 204 |
if (getPtro() == -1) |
204 | 205 |
throw new GdalException("Error en la apertura del fichero. El fichero no tiene un formato v?lido."); |
205 |
if(isInitialized){ |
|
206 |
// if(isInitialized){
|
|
206 | 207 |
// ext = RasterUtilities.getExtensionFromFileName(fName); |
207 | 208 |
width = getRasterXSize(); |
208 | 209 |
height = getRasterYSize(); |
... | ... | |
273 | 274 |
overviewHeight = height; |
274 | 275 |
this.georeferenced = false; |
275 | 276 |
} |
276 |
} |
|
277 |
// }
|
|
277 | 278 |
} |
278 | 279 |
|
279 | 280 |
/** |
... | ... | |
1475 | 1476 |
} |
1476 | 1477 |
gdalBands = null; |
1477 | 1478 |
} |
1478 |
super.finalize();
|
|
1479 |
this.finalize();
|
|
1479 | 1480 |
} |
1480 | 1481 |
|
1481 | 1482 |
} |
org.gvsig.raster.gdal/tags/pre-remove-jgdal/org.gvsig.raster.gdal/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/raster/gdal/io/GdalProvider.java | ||
---|---|---|
237 | 237 |
setParam(storeServices, params); |
238 | 238 |
validRmf(params.getURI()); |
239 | 239 |
setFName(translateFileName(params.getURI())); |
240 |
GdalNative aux = new GdalNative(translateFileName(params.getURI())); |
|
241 |
long ptro = aux.getPtro(); |
|
242 |
aux.delete(); |
|
243 |
file = new GdalNative(ptro, translateFileName(params.getURI()));
|
|
240 |
// GdalNative aux = new GdalNative(translateFileName(params.getURI()));
|
|
241 |
// long ptro = aux.getPtro();
|
|
242 |
// aux.delete();
|
|
243 |
file = new GdalNative(translateFileName(params.getURI())); |
|
244 | 244 |
setColorInterpretation(file.colorInterpr); |
245 | 245 |
setColorTable(file.palette); |
246 | 246 |
noData = file.getNoDataValue(); |
org.gvsig.raster.gdal/tags/pre-remove-jgdal/org.gvsig.raster.gdal/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/jgdal/Gdal.java | ||
---|---|---|
37 | 37 |
* |
38 | 38 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
39 | 39 |
*/ |
40 |
public class Gdal extends Dataset {
|
|
40 |
public class Gdal extends gdalJNI {
|
|
41 | 41 |
// CONSTANTES |
42 | 42 |
|
43 | 43 |
// GDALAccess |
... | ... | |
61 | 61 |
|
62 | 62 |
private String pszFilename = ""; |
63 | 63 |
private long cPtr; |
64 |
private Dataset dataset; |
|
64 | 65 |
|
65 | 66 |
//private Dataset gdalDataset; |
66 | 67 |
|
... | ... | |
82 | 83 |
/** |
83 | 84 |
*Constructor a partir de la direcci?n de memoria |
84 | 85 |
*/ |
85 |
public Gdal(long cPtr){ |
|
86 |
super(cPtr,true);
|
|
87 |
} |
|
86 |
// public Gdal(long cPtr){
|
|
87 |
// super();
|
|
88 |
// }
|
|
88 | 89 |
|
89 |
public Gdal(long cPtr, boolean access){ |
|
90 |
super(cPtr,access);
|
|
91 |
gdalJNI.AllRegister(); |
|
92 |
ogrJNI.RegisterAll(); |
|
93 |
this.cPtr = cPtr; |
|
94 |
} |
|
90 |
// public Gdal(long cPtr, boolean access){
|
|
91 |
// super();
|
|
92 |
// gdalJNI.AllRegister();
|
|
93 |
// ogrJNI.RegisterAll();
|
|
94 |
// this.cPtr = cPtr;
|
|
95 |
// }
|
|
95 | 96 |
|
96 | 97 |
/** |
97 | 98 |
*Constructor generico |
98 | 99 |
*/ |
99 | 100 |
public Gdal(){ |
100 |
this(-1, false); |
|
101 |
super(); |
|
102 |
//this(-1, false); |
|
101 | 103 |
} |
104 |
|
|
105 |
public Gdal(Dataset dataset){ |
|
106 |
super(); |
|
107 |
this.dataset = dataset; |
|
108 |
} |
|
102 | 109 |
|
103 | 110 |
|
104 | 111 |
/** |
... | ... | |
119 | 126 |
if ((access < 0) || (access > 1)) |
120 | 127 |
throw new GdalException("Tipo de acceso al dataset incorrecto"); |
121 | 128 |
|
122 |
Dataset data = gdal.Open(pszFilename, access);
|
|
129 |
this.dataset = gdal.Open(pszFilename, access);
|
|
123 | 130 |
// cPtr = openArrayNat(pszFilename.getBytes(), access); |
124 | 131 |
|
125 |
if (data == null)
|
|
132 |
if (this.dataset == null)
|
|
126 | 133 |
throw new GdalException("No se ha podido acceder al archivo."); |
127 | 134 |
|
128 |
cPtr = Dataset.getCPtr(data);
|
|
135 |
cPtr = GdalDataset.getCPtr(this.dataset);
|
|
129 | 136 |
} |
130 | 137 |
|
131 | 138 |
/** |
... | ... | |
147 | 154 |
* @return Array de Strings que corresponden a los metadatos que ofrece la imagen |
148 | 155 |
*/ |
149 | 156 |
public String[] getMetadata(String domain)throws GdalException { |
150 |
Vector res = this.GetMetadata_List(domain); |
|
157 |
Vector res = this.dataset.GetMetadata_List(domain);
|
|
151 | 158 |
if(res == null) |
152 | 159 |
return new String[0]; |
153 | 160 |
else return OGRTools.safeVectorToStringArray(res); |
... | ... | |
171 | 178 |
if (cPtr == 0) |
172 | 179 |
throw new GdalException("No se ha podido acceder al archivo."); |
173 | 180 |
|
174 |
rb = this.GetRasterBand(hBand); |
|
181 |
rb = this.dataset.GetRasterBand(hBand);
|
|
175 | 182 |
|
176 |
return new GdalRasterBand(Band.getCPtr(rb));
|
|
183 |
return new GdalRasterBand(rb);
|
|
177 | 184 |
} |
178 | 185 |
|
179 | 186 |
|
... | ... | |
184 | 191 |
* @return Devuelve un entero con la longitud de la imagen en el eje X en pixels. |
185 | 192 |
*/ |
186 | 193 |
public int getRasterXSize() { |
187 |
return super.getRasterXSize();
|
|
194 |
return this.dataset.getRasterXSize();
|
|
188 | 195 |
} |
189 | 196 |
|
190 | 197 |
|
... | ... | |
194 | 201 |
* @return Devuelve un entero con la longitud de la imagen en el eje Y en pixels. |
195 | 202 |
*/ |
196 | 203 |
public int getRasterYSize() { |
197 |
return super.getRasterYSize();
|
|
204 |
return this.dataset.getRasterYSize();
|
|
198 | 205 |
} |
199 | 206 |
|
200 | 207 |
|
... | ... | |
204 | 211 |
* @return Devuelve un entero con el n?mero de bandas que contiene la imagen. |
205 | 212 |
*/ |
206 | 213 |
public int getRasterCount() { |
207 |
return super.getRasterCount();
|
|
214 |
return this.dataset.getRasterCount();
|
|
208 | 215 |
} |
209 | 216 |
|
210 | 217 |
|
... | ... | |
222 | 229 |
|
223 | 230 |
// if() |
224 | 231 |
// throw new GdalException("Error en getGeoTransform(). No se han obtenido valores para geoTransform."); |
225 |
this.GetGeoTransform(gt.adfgeotransform); |
|
232 |
this.dataset.GetGeoTransform(gt.adfgeotransform);
|
|
226 | 233 |
return gt; |
227 | 234 |
} |
228 | 235 |
|
... | ... | |
236 | 243 |
if (cPtr == 0) |
237 | 244 |
throw new GdalException("No se ha podido acceder al archivo."); |
238 | 245 |
|
239 |
String shortName = GetDriver().getShortName();
|
|
246 |
String shortName =this.dataset.GetDriver().getShortName();
|
|
240 | 247 |
|
241 | 248 |
if(shortName == null) |
242 | 249 |
throw new GdalException("Error en getDriverShortName(). No ha podido obtenerse el driver"); |
... | ... | |
256 | 263 |
if (gt == null) |
257 | 264 |
throw new GdalException("el objeto " + gt.getClass().getName() + " es null"); |
258 | 265 |
|
259 |
int res = SetGeoTransform(gt.adfgeotransform); |
|
266 |
int res = this.dataset.SetGeoTransform(gt.adfgeotransform);
|
|
260 | 267 |
} |
261 | 268 |
|
262 | 269 |
/** |
... | ... | |
269 | 276 |
if (cPtr == 0) |
270 | 277 |
throw new GdalException("No se ha podido acceder al archivo."); |
271 | 278 |
|
272 |
String res = GetProjectionRef(); |
|
279 |
String res = this.dataset.GetProjectionRef();
|
|
273 | 280 |
|
274 | 281 |
if(res == null)return new String(""); |
275 | 282 |
else return res; |
... | ... | |
285 | 292 |
// throw new GdalException("No se ha podido acceder al archivo."); |
286 | 293 |
// |
287 | 294 |
// closeNat(cPtr); |
288 |
this.delete(); |
|
295 |
this.dataset.delete();
|
|
289 | 296 |
} |
290 | 297 |
|
291 | 298 |
/** |
... | ... | |
311 | 318 |
* @throws GdalException |
312 | 319 |
*/ |
313 | 320 |
public int getGCPCount()throws GdalException { |
314 |
String msg1="Error en GDALGetRasterCount. . La llamada GDALOpen no tuvo ?xito"; |
|
315 |
String msg2="Error en el conteo de n?mero de bandas"; |
|
316 |
return GetGCPCount(); |
|
321 |
// String msg1="Error en GDALGetRasterCount. . La llamada GDALOpen no tuvo ?xito";
|
|
322 |
// String msg2="Error en el conteo de n?mero de bandas";
|
|
323 |
return this.dataset.GetGCPCount();
|
|
317 | 324 |
} |
318 | 325 |
|
319 | 326 |
/** |
... | ... | |
327 | 334 |
if (proj == null) |
328 | 335 |
throw new GdalException("La proyeccion es null"); |
329 | 336 |
|
330 |
int res = SetProjection(proj); |
|
337 |
int res = this.dataset.SetProjection(proj);
|
|
331 | 338 |
|
332 | 339 |
if(res < 0) |
333 | 340 |
throw new GdalException("Error en setProjection(). No se ha podido asignar la proyecci?n."); |
org.gvsig.raster.gdal/tags/pre-remove-jgdal/org.gvsig.raster.gdal/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/jgdal/GdalDataset.java | ||
---|---|---|
1 |
package org.gvsig.jgdal; |
|
2 |
|
|
3 |
import org.gdal.gdal.Dataset; |
|
4 |
|
|
5 |
public class GdalDataset extends Dataset{ |
|
6 |
|
|
7 |
public GdalDataset(long cPtr, boolean cMemoryOwn) { |
|
8 |
super(cPtr, cMemoryOwn); |
|
9 |
} |
|
10 |
|
|
11 |
public GdalDataset(Dataset dataset) { |
|
12 |
super(Dataset.getCPtr(dataset), true); |
|
13 |
} |
|
14 |
|
|
15 |
|
|
16 |
public static long getCPtr(Dataset obj) { |
|
17 |
return Dataset.getCPtr(obj); |
|
18 |
} |
|
19 |
|
|
20 |
} |
|
0 | 21 |
org.gvsig.raster.gdal/tags/pre-remove-jgdal/org.gvsig.raster.gdal/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/jgdal/GdalRasterBand.java | ||
---|---|---|
70 | 70 |
super(cPtr, true); |
71 | 71 |
} |
72 | 72 |
|
73 |
public GdalRasterBand(Band band) { |
|
74 |
super(Band.getCPtr(band), true); |
|
75 |
} |
|
73 | 76 |
|
74 | 77 |
/** |
75 | 78 |
* Lee datos de la banda de la imagen |
... | ... | |
152 | 155 |
} |
153 | 156 |
|
154 | 157 |
|
155 |
if(i==0)
|
|
158 |
if(i>0)
|
|
156 | 159 |
return buf; |
157 | 160 |
else |
158 | 161 |
return null; |
org.gvsig.raster.gdal/tags/pre-remove-jgdal/org.gvsig.raster.gdal/org.gvsig.raster.gdal.io/src/main/java/org/gvsig/jgdal/GdalDriver.java | ||
---|---|---|
77 | 77 |
// if (ptr == 0) |
78 | 78 |
// throw new GdalException("No se ha podido crear la copia"); |
79 | 79 |
|
80 |
return ((Gdal)copyDataset);
|
|
80 |
return new Gdal(copyDataset);
|
|
81 | 81 |
} |
82 | 82 |
|
83 | 83 |
|
... | ... | |
132 | 132 |
if (copyDataset == null) |
133 | 133 |
throw new GdalException("No se ha podido crear la copia"); |
134 | 134 |
|
135 |
return (Gdal)copyDataset;
|
|
135 |
return new Gdal(copyDataset);
|
|
136 | 136 |
} |
137 | 137 |
|
138 | 138 |
|
... | ... | |
152 | 152 |
|
153 | 153 |
Dataset data = Create(filename, nXSize, nYSize, nBands, nType, params); |
154 | 154 |
|
155 |
return (Gdal)data;
|
|
155 |
return new Gdal(data);
|
|
156 | 156 |
} |
157 | 157 |
} |
Also available in: Unified diff