Revision 30008 branches/v2_0_0_prep/libraries/libRaster/src/org/gvsig/raster/dataset/CompositeDataset.java
CompositeDataset.java | ||
---|---|---|
43 | 43 |
* rasters. Un cliente de esta clase debe tener una visi?n de la rejilla como si |
44 | 44 |
* fuese un solo raster, gestionando esta el acceso la imagen que corresponda en |
45 | 45 |
* cada petici?n de usuario. |
46 |
*
|
|
46 |
* |
|
47 | 47 |
* @version 29/08/2007 |
48 | 48 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
49 | 49 |
*/ |
50 | 50 |
public class CompositeDataset implements IRasterDataSource { |
51 | 51 |
private MultiRasterDataset[][] mosaic = null; |
52 | 52 |
private DatasetListStatistics stats = null; |
53 |
private BandList bandList = new BandList();
|
|
53 |
private BandList bandList = null;
|
|
54 | 54 |
private boolean readOnly = false; |
55 | 55 |
|
56 | 56 |
/** |
57 | 57 |
* Flag que fuerza al buffer en memoria |
58 | 58 |
*/ |
59 | 59 |
private boolean forceToMemory = false; |
60 |
|
|
60 |
|
|
61 | 61 |
/** |
62 | 62 |
* Constructor. Genera la estructura de n filas por n columnas de rasters. |
63 | 63 |
* @param n N?mero de filas |
64 | 64 |
* @param m N?mero de columnas |
65 | 65 |
*/ |
66 | 66 |
public CompositeDataset(int n, int m) { |
67 |
bandList = new BandList(); |
|
67 | 68 |
mosaic = new MultiRasterDataset[n][m]; |
68 | 69 |
} |
69 | 70 |
|
... | ... | |
74 | 75 |
* @param m N?mero de columnas |
75 | 76 |
*/ |
76 | 77 |
public CompositeDataset(MultiRasterDataset[][] mos) throws MosaicNotValidException { |
78 |
bandList = new BandList(); |
|
77 | 79 |
this.mosaic = deleteNullValues(mos); |
78 | 80 |
//this.mosaic = mos; |
79 |
|
|
81 |
|
|
80 | 82 |
/*if(!validateMosaic()) { |
81 | 83 |
this.mosaic = null; |
82 | 84 |
throw new MosaicNotValidException("Extends no validos para montar un mosaico"); |
83 | 85 |
}*/ |
84 | 86 |
init(); |
85 | 87 |
} |
86 |
|
|
88 |
|
|
87 | 89 |
/** |
88 | 90 |
* M?todo que elimina crea un array bidimensional eliminando los nulos del que tiene |
89 | 91 |
* el que se le pasa por par?metro |
... | ... | |
95 | 97 |
int m = values[0].length; |
96 | 98 |
int posInitX = 0; |
97 | 99 |
int posInitY = 0; |
98 |
|
|
100 |
|
|
99 | 101 |
int nRows = n, nCols = m; |
100 | 102 |
//Contador de filas |
101 | 103 |
boolean first = true; |
102 | 104 |
for (int row = 0; row < n; row++) { |
103 | 105 |
boolean isNull = true; |
104 |
for (int col = 0; col < m; col++) {
|
|
106 |
for (int col = 0; col < m; col++) |
|
105 | 107 |
if(values[row][col] != null) { |
106 | 108 |
isNull = false; |
107 | 109 |
if(first) { |
... | ... | |
109 | 111 |
first = false; |
110 | 112 |
} |
111 | 113 |
} |
112 |
} |
|
113 | 114 |
if(isNull) |
114 | 115 |
nRows --; |
115 | 116 |
} |
116 |
|
|
117 |
|
|
117 | 118 |
//Contador de columnas |
118 | 119 |
first = true; |
119 | 120 |
for (int col = 0; col < m; col++) { |
120 | 121 |
boolean isNull = true; |
121 |
for (int row = 0; row < n; row++) {
|
|
122 |
for (int row = 0; row < n; row++) |
|
122 | 123 |
if(values[row][col] != null) { |
123 | 124 |
isNull = false; |
124 | 125 |
if(first) { |
... | ... | |
126 | 127 |
first = false; |
127 | 128 |
} |
128 | 129 |
} |
129 |
} |
|
130 | 130 |
if(isNull) |
131 | 131 |
nCols --; |
132 | 132 |
} |
133 | 133 |
//Copia de datos |
134 | 134 |
MultiRasterDataset[][] result = new MultiRasterDataset[nRows][nCols]; |
135 |
|
|
136 |
for (int row = 0; row < result.length; row++)
|
|
137 |
for (int col = 0; col < result[row].length; col++)
|
|
135 |
|
|
136 |
for (int row = 0; row < result.length; row++) |
|
137 |
for (int col = 0; col < result[row].length; col++) |
|
138 | 138 |
result[row][col] = values[row + posInitY][col + posInitX]; |
139 | 139 |
return result; |
140 | 140 |
} |
141 |
|
|
141 |
|
|
142 | 142 |
/** |
143 | 143 |
* Abre un dataset pasando como par?metros la proyecci?n y un objeto identificador del dataset. Este |
144 |
* objeto puede ser una ruta a un fichero en disco. En este caso la extensi?n del fichero servir? para
|
|
144 |
* objeto puede ser una ruta a un fichero en disco. En este caso la extensi?n del fichero servir? para |
|
145 | 145 |
* buscar el driver que lo gestiona. Si proporcionamos un array de cadenas se tratar?n como la ruta a N ficheros |
146 | 146 |
* de disco. Tambi?n puede ser un buffer de datos en memoria o cualquier otro objeto |
147 |
* que pueda aceptar un driver.
|
|
147 |
* que pueda aceptar un driver. |
|
148 | 148 |
* @param proj PRoyecci?n |
149 | 149 |
* @param datasetOpenParam Par?metros al driver |
150 | 150 |
* @return RasterMultiDatset |
... | ... | |
155 | 155 |
if(datasetOpenParam instanceof String[][]) { |
156 | 156 |
String[][] param = (String[][])datasetOpenParam; |
157 | 157 |
MultiRasterDataset[][] mosaic = new MultiRasterDataset[param.length][param[0].length]; |
158 |
for (int i = 0; i < param.length; i++) {
|
|
159 |
for (int j = 0; j < param[i].length; j++)
|
|
158 |
for (int i = 0; i < param.length; i++) |
|
159 |
for (int j = 0; j < param[i].length; j++) |
|
160 | 160 |
mosaic[i][j] = MultiRasterDataset.open(proj, param[i][j]); |
161 |
} |
|
162 | 161 |
CompositeDataset cd; |
163 | 162 |
try { |
164 | 163 |
cd = new CompositeDataset(mosaic); |
... | ... | |
169 | 168 |
} |
170 | 169 |
return null; |
171 | 170 |
} |
172 |
|
|
171 |
|
|
173 | 172 |
/** |
174 | 173 |
* Valida que los extends del mosaico sean validos, es decir, que sean correlativos |
175 | 174 |
* formando la matriz. Adem?s tambi?n valida que el tama?o de pixel coincida en todos los |
176 |
* raster que forman el mosaico.
|
|
177 |
*
|
|
178 |
* @param mos
|
|
175 |
* raster que forman el mosaico. |
|
176 |
* |
|
177 |
* @param mos |
|
179 | 178 |
* @throws MosaicNotValidException |
180 | 179 |
*/ |
181 | 180 |
public boolean validateMosaic() { |
182 | 181 |
int n = mosaic.length; |
183 | 182 |
int m = mosaic[0].length; |
184 | 183 |
//Comprobamos en Horizontal |
185 |
if(m > 1) {
|
|
186 |
for (int row = 0; row < n; row++) {
|
|
187 |
for (int col = 0; col < m; col++) {
|
|
184 |
if(m > 1) |
|
185 |
for (int row = 0; row < n; row++) |
|
186 |
for (int col = 0; col < m; col++) |
|
188 | 187 |
if(col < (m - 1) && mosaic[row][col] != null) { |
189 | 188 |
Extent a = mosaic[row][col].getExtent(); |
190 | 189 |
Extent b = mosaic[row][col + 1].getExtent(); |
... | ... | |
199 | 198 |
if(mosaic[row][col].getBandCount() != mosaic[row][col + 1].getBandCount()) |
200 | 199 |
return false; |
201 | 200 |
} |
202 |
} |
|
203 |
} |
|
204 |
} |
|
205 | 201 |
|
206 | 202 |
//Comprobamos en Vertical |
207 |
if(n > 1) {
|
|
208 |
for (int col = 0; col < m; col++) {
|
|
209 |
for (int row = 0; row < n; row++) {
|
|
203 |
if(n > 1) |
|
204 |
for (int col = 0; col < m; col++) |
|
205 |
for (int row = 0; row < n; row++) |
|
210 | 206 |
if(row < (n - 1) && mosaic[row][col] != null) { |
211 | 207 |
Extent a = mosaic[row][col].getExtent(); |
212 | 208 |
Extent b = mosaic[row + 1][col].getExtent(); |
... | ... | |
221 | 217 |
if(mosaic[row][col].getBandCount() != mosaic[row + 1][col].getBandCount()) |
222 | 218 |
return false; |
223 | 219 |
} |
224 |
} |
|
225 |
} |
|
226 |
} |
|
227 |
|
|
220 |
|
|
228 | 221 |
return true; |
229 | 222 |
} |
230 | 223 |
|
... | ... | |
236 | 229 |
if(mosaic != null) { |
237 | 230 |
int n = mosaic.length; |
238 | 231 |
int m = mosaic[0].length; |
239 |
if(f.length == (n * m)) {
|
|
240 |
for (int i = 0; i < n; i++) {
|
|
232 |
if(f.length == (n * m)) |
|
233 |
for (int i = 0; i < n; i++) |
|
241 | 234 |
for (int j = 0; j < m; j++) { |
242 | 235 |
MultiRasterDataset mrd = new MultiRasterDataset(); |
243 |
mrd.addDataset(new RasterDataset[]{f[i * n + j]});
|
|
236 |
mrd.addDataset(new RasterDataset[]{f[i * n + j]}); |
|
244 | 237 |
} |
245 |
} |
|
246 |
} |
|
247 | 238 |
init(); |
248 | 239 |
} |
249 | 240 |
} |
... | ... | |
256 | 247 |
if(mosaic != null) { |
257 | 248 |
int n = mosaic.length; |
258 | 249 |
int m = mosaic[0].length; |
259 |
if(fileName.length == (n * m)) {
|
|
260 |
for (int i = 0; i < n; i++) {
|
|
250 |
if(fileName.length == (n * m)) |
|
251 |
for (int i = 0; i < n; i++) |
|
261 | 252 |
for (int j = 0; j < m; j++) { |
262 | 253 |
MultiRasterDataset mrd = new MultiRasterDataset(); |
263 |
mrd.addDataset(new RasterDataset[]{RasterDataset.open(null, fileName[i * n + j])});
|
|
254 |
mrd.addDataset(new RasterDataset[]{RasterDataset.open(null, fileName[i * n + j])}); |
|
264 | 255 |
} |
265 |
} |
|
266 |
} |
|
267 | 256 |
init(); |
268 | 257 |
} |
269 | 258 |
} |
... | ... | |
274 | 263 |
*/ |
275 | 264 |
private void init() { |
276 | 265 |
stats = new DatasetListStatistics(mosaic); |
277 |
|
|
266 |
|
|
278 | 267 |
//Creamos la lista de bandas |
279 | 268 |
bandList = (BandList)mosaic[0][0].getBands().clone(); |
280 | 269 |
int n = mosaic.length; |
281 | 270 |
int m = mosaic[0].length; |
282 |
for (int row = 0; row < n; row++) {
|
|
283 |
for (int col = 0; col < m; col++) {
|
|
284 |
if(row != 0 && col != 0) { //El primero ya est? a?adido
|
|
285 |
for (int i = 0; i < mosaic[0][0].getBandCount(); i++) {
|
|
271 |
for (int row = 0; row < n; row++) |
|
272 |
for (int col = 0; col < m; col++) |
|
273 |
if(row != 0 && col != 0) |
|
274 |
for (int i = 0; i < mosaic[0][0].getBandCount(); i++) |
|
286 | 275 |
if(mosaic[row][col] != null) |
287 | 276 |
bandList.getBand(i).setAdditionalName(mosaic[row][col].getBands().getBand(i).getFileName()); |
288 |
} |
|
289 |
} |
|
290 |
} |
|
291 |
} |
|
292 |
|
|
277 |
|
|
293 | 278 |
} |
294 |
|
|
279 |
|
|
295 | 280 |
/** |
296 |
* Obtiene la lista de nombres de los dataset
|
|
281 |
* Obtiene la lista de nombres de los dataset |
|
297 | 282 |
* @return |
298 | 283 |
*/ |
299 | 284 |
public String[][] getFileNames() { |
300 | 285 |
String[][] s = new String[mosaic.length][mosaic[0].length]; |
301 |
for (int i = 0; i < s.length; i++) {
|
|
302 |
for (int j = 0; j < s[i].length; j++) {
|
|
286 |
for (int i = 0; i < s.length; i++) |
|
287 |
for (int j = 0; j < s[i].length; j++) |
|
303 | 288 |
if(mosaic[i][j] != null) |
304 | 289 |
s[i][j] = mosaic[i][j].getDataset(0)[0].getFName(); |
305 |
} |
|
306 |
} |
|
307 | 290 |
return s; |
308 | 291 |
} |
309 |
|
|
292 |
|
|
310 | 293 |
/* |
311 | 294 |
* (non-Javadoc) |
312 | 295 |
* @see org.gvsig.raster.dataset.IRasterDataSource#calcSteps(double, double, double, double, double, double, int, int) |
... | ... | |
324 | 307 |
public void close() { |
325 | 308 |
int n = mosaic.length; |
326 | 309 |
int m = mosaic[0].length; |
327 |
for (int row = 0; row < n; row++) {
|
|
328 |
for (int col = 0; col < m; col++) {
|
|
329 |
if(mosaic[row][col] != null) |
|
310 |
for (int row = 0; row < n; row++) |
|
311 |
for (int col = 0; col < m; col++) |
|
312 |
if(mosaic[row][col] != null) {
|
|
330 | 313 |
mosaic[row][col].close(); |
331 |
} |
|
332 |
} |
|
314 |
mosaic[row][col] = null; |
|
315 |
} |
|
316 |
mosaic = null; |
|
317 |
bandList.clear(); |
|
318 |
bandList = null; |
|
333 | 319 |
} |
334 | 320 |
|
335 | 321 |
/* |
... | ... | |
340 | 326 |
int n = mosaic.length; |
341 | 327 |
int m = mosaic[0].length; |
342 | 328 |
MultiRasterDataset[][] mrd = new MultiRasterDataset[n][m]; |
343 |
for (int row = 0; row < n; row++)
|
|
344 |
for (int col = 0; col < m; col++)
|
|
329 |
for (int row = 0; row < n; row++) |
|
330 |
for (int col = 0; col < m; col++) |
|
345 | 331 |
if(mosaic[row][col] != null) |
346 | 332 |
mrd[row][col] = (MultiRasterDataset)mosaic[row][col].newDataset(); |
347 |
|
|
333 |
|
|
348 | 334 |
try { |
349 | 335 |
return new CompositeDataset(mrd); |
350 | 336 |
} catch (MosaicNotValidException e) { |
... | ... | |
361 | 347 |
return mosaic[0][0].getOwnAffineTransform(); |
362 | 348 |
return new AffineTransform(); |
363 | 349 |
} |
364 |
|
|
350 |
|
|
365 | 351 |
/* |
366 | 352 |
* (non-Javadoc) |
367 | 353 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getAffineTransform() |
... | ... | |
371 | 357 |
return mosaic[0][0].getAffineTransform(band); |
372 | 358 |
return new AffineTransform(); |
373 | 359 |
} |
374 |
|
|
360 |
|
|
375 | 361 |
/* |
376 | 362 |
* (non-Javadoc) |
377 | 363 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getExtent() |
... | ... | |
382 | 368 |
if(mosaic != null && mosaic[0][0] != null) { |
383 | 369 |
double ulx = mosaic[0][0].getExtent().getULX(); |
384 | 370 |
double uly = mosaic[0][0].getExtent().getULY(); |
385 |
|
|
371 |
|
|
386 | 372 |
double urx = mosaic[n - 1][0].getExtent().getURX(); |
387 | 373 |
double ury = mosaic[n - 1][0].getExtent().getURY(); |
388 |
|
|
374 |
|
|
389 | 375 |
double llx = mosaic[0][m - 1].getExtent().getLLX(); |
390 | 376 |
double lly = mosaic[0][m - 1].getExtent().getLLY(); |
391 |
|
|
377 |
|
|
392 | 378 |
double lrx = mosaic[n - 1][m - 1].getExtent().getLRX(); |
393 | 379 |
double lry = mosaic[n - 1][m - 1].getExtent().getLRY(); |
394 |
|
|
395 |
return new Extent( new Point2D.Double(ulx, uly),
|
|
396 |
new Point2D.Double(lrx, lry),
|
|
397 |
new Point2D.Double(urx, ury),
|
|
380 |
|
|
381 |
return new Extent( new Point2D.Double(ulx, uly), |
|
382 |
new Point2D.Double(lrx, lry), |
|
383 |
new Point2D.Double(urx, ury), |
|
398 | 384 |
new Point2D.Double(llx, lly)); |
399 | 385 |
} |
400 | 386 |
return null; |
... | ... | |
423 | 409 |
} |
424 | 410 |
return w; |
425 | 411 |
} |
426 |
|
|
412 |
|
|
427 | 413 |
/** |
428 | 414 |
* Obtiene el alto del mosaico completo en p?xeles, esto es la |
429 | 415 |
* suma de todos los raster que componen la extensi?n. |
... | ... | |
451 | 437 |
return 1; |
452 | 438 |
} |
453 | 439 |
} |
454 |
|
|
440 |
|
|
455 | 441 |
/* |
456 | 442 |
* (non-Javadoc) |
457 | 443 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getDataType() |
... | ... | |
461 | 447 |
return mosaic[0][0].getDataType(); |
462 | 448 |
return null; |
463 | 449 |
} |
464 |
|
|
450 |
|
|
465 | 451 |
/* |
466 | 452 |
* (non-Javadoc) |
467 | 453 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getDatasetCount() |
... | ... | |
480 | 466 |
long size = 0; |
481 | 467 |
int n = mosaic.length; |
482 | 468 |
int m = mosaic[0].length; |
483 |
for (int row = 0; row < n; row++) {
|
|
484 |
for (int col = 0; col < m; col++) {
|
|
469 |
for (int row = 0; row < n; row++) |
|
470 |
for (int col = 0; col < m; col++) |
|
485 | 471 |
if(mosaic[row][col] != null) |
486 | 472 |
size += mosaic[row][col].getFileSize(); |
487 |
} |
|
488 |
} |
|
489 | 473 |
return size; |
490 | 474 |
} |
491 |
|
|
475 |
|
|
492 | 476 |
/** |
493 | 477 |
* Obtiene el dataset cuyas coordenadas contienen el punto pasado por par?meto |
494 | 478 |
* @param x Coordenada X a comprobar |
... | ... | |
498 | 482 |
public Point2D getDatasetByCoords(double x, double y) { |
499 | 483 |
int n = mosaic.length; |
500 | 484 |
int m = mosaic[0].length; |
501 |
for (int row = 0; row < n; row++) {
|
|
502 |
for (int col = 0; col < m; col++) {
|
|
503 |
if(mosaic[row][col] != null &&
|
|
504 |
RasterUtilities.isInside(new Point2D.Double(x, y), mosaic[row][col].getExtent(), mosaic[row][col].getAffineTransform(0)))
|
|
485 |
for (int row = 0; row < n; row++) |
|
486 |
for (int col = 0; col < m; col++) |
|
487 |
if(mosaic[row][col] != null && |
|
488 |
RasterUtilities.isInside(new Point2D.Double(x, y), mosaic[row][col].getExtent(), mosaic[row][col].getAffineTransform(0))) |
|
505 | 489 |
return new Point2D.Double(row, col); |
506 |
} |
|
507 |
} |
|
508 | 490 |
|
509 | 491 |
return null; |
510 | 492 |
} |
511 |
|
|
493 |
|
|
512 | 494 |
/** |
513 | 495 |
* Obtiene la lista de datasets del mosaico que intersectan con el extent proporcionado |
514 | 496 |
* @param ulx Coordenada X superior izquierda |
... | ... | |
521 | 503 |
private MultiRasterDataset[][] getDatasetListInArea(double ulx, double uly, double lrx, double lry) throws NoninvertibleTransformException { |
522 | 504 |
int n = mosaic.length; |
523 | 505 |
int m = mosaic[0].length; |
524 |
|
|
506 |
|
|
525 | 507 |
MultiRasterDataset[][] result = new MultiRasterDataset[n][m]; |
526 |
|
|
527 |
for (int row = 0; row < n; row++) |
|
528 |
for (int col = 0; col < m; col++) |
|
529 |
if(mosaic[row][col] != null && |
|
530 |
RasterUtilities.intersects(new Extent(ulx, uly, lrx, lry), mosaic[row][col].getExtent(), mosaic[row][col].getAffineTransform(0))) { |
|
531 |
for (int k = 0; k < mosaic.length; k++) |
|
532 |
result[row][col] = mosaic[row][col]; |
|
533 |
} |
|
508 |
|
|
509 |
for (int row = 0; row < n; row++) |
|
510 |
for (int col = 0; col < m; col++) |
|
511 |
if(mosaic[row][col] != null && |
|
512 |
RasterUtilities.intersects(new Extent(ulx, uly, lrx, lry), mosaic[row][col].getExtent(), mosaic[row][col].getAffineTransform(0))) |
|
513 |
for (int k = 0; k < mosaic.length; k++) |
|
514 |
result[row][col] = mosaic[row][col]; |
|
534 | 515 |
return result; |
535 | 516 |
} |
536 | 517 |
|
... | ... | |
551 | 532 |
getAffineTransform(0).transform(pt, p); |
552 | 533 |
return p; |
553 | 534 |
} |
554 |
|
|
535 |
|
|
555 | 536 |
/* |
556 | 537 |
* (non-Javadoc) |
557 | 538 |
* @see org.gvsig.raster.dataset.IRasterDataSource#worldToRaster(java.awt.geom.Point2D) |
... | ... | |
592 | 573 |
public RasterDataset[] getDataset(int i) { |
593 | 574 |
RasterDataset[] d = new RasterDataset[mosaic.length * mosaic[0].length]; |
594 | 575 |
int count = 0; |
595 |
for (int row = 0; row < mosaic.length; row++) {
|
|
596 |
for (int col = 0; col < mosaic[row].length; col++) {
|
|
576 |
for (int row = 0; row < mosaic.length; row++) |
|
577 |
for (int col = 0; col < mosaic[row].length; col++) |
|
597 | 578 |
if(mosaic[row][col] != null) |
598 | 579 |
d[count] = mosaic[row][col].getDataset(i)[0]; |
599 |
} |
|
600 |
} |
|
601 | 580 |
return d; |
602 | 581 |
} |
603 |
|
|
582 |
|
|
604 | 583 |
/* |
605 | 584 |
* (non-Javadoc) |
606 | 585 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getStatistics() |
... | ... | |
608 | 587 |
public DatasetListStatistics getStatistics() { |
609 | 588 |
return stats; |
610 | 589 |
} |
611 |
|
|
590 |
|
|
612 | 591 |
/* |
613 | 592 |
* (non-Javadoc) |
614 | 593 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getBands() |
... | ... | |
616 | 595 |
public BandList getBands() { |
617 | 596 |
return bandList; |
618 | 597 |
} |
619 |
|
|
598 |
|
|
620 | 599 |
/** |
621 | 600 |
* Genera un buffer de datos ?nico a partir de una matriz de buffers donde puede haber |
622 |
* elementos con valor nulo.
|
|
601 |
* elementos con valor nulo. |
|
623 | 602 |
* @return |
624 | 603 |
*/ |
625 | 604 |
public IBuffer generateBuffer(IBuffer[][] bufList, int drawableBands) { |
... | ... | |
627 | 606 |
int m = mosaic[0].length; |
628 | 607 |
int nCols = 0, nRows = 0; |
629 | 608 |
//Contamos el n?mero de filas y columnas del buffer nuevo |
630 |
for (int row = 0; row < n; row++) {
|
|
631 |
for (int col = 0; col < m; col++) {
|
|
609 |
for (int row = 0; row < n; row++) { |
|
610 |
for (int col = 0; col < m; col++) |
|
632 | 611 |
if(bufList[row][col] != null) |
633 | 612 |
nCols += bufList[row][col].getWidth(); |
634 |
|
|
635 |
} |
|
636 | 613 |
if(nCols != 0) break; |
637 | 614 |
} |
638 |
for (int col = 0; col < m; col++) {
|
|
639 |
for (int row = 0; row < n; row++) {
|
|
615 |
for (int col = 0; col < m; col++) { |
|
616 |
for (int row = 0; row < n; row++) |
|
640 | 617 |
if(bufList[row][col] != null) |
641 | 618 |
nRows += bufList[row][col].getHeight(); |
642 |
} |
|
643 | 619 |
if(nRows != 0) break; |
644 | 620 |
} |
645 |
|
|
621 |
|
|
646 | 622 |
//Creamos el buffer |
647 | 623 |
IBuffer raster = RasterBuffer.getBuffer(bufList[0][0].getDataType(), nCols, nRows, drawableBands, true); |
648 |
|
|
624 |
|
|
649 | 625 |
//Hacemos la copia |
650 | 626 |
int[] pos = new int[2]; |
651 | 627 |
int validCol = 0; |
652 |
for (int row = 0; row < n; row++) {
|
|
628 |
for (int row = 0; row < n; row++) { |
|
653 | 629 |
for (int col = 0; col < m; col++) { |
654 | 630 |
pos[1] = (col == 0) ? 0 : pos[1]; |
655 | 631 |
if(bufList[row][col] == null) |
... | ... | |
663 | 639 |
} |
664 | 640 |
return raster; |
665 | 641 |
} |
666 |
|
|
642 |
|
|
667 | 643 |
/** |
668 | 644 |
* Copia un tile en el buffer que contendr? todos los tiles |
669 | 645 |
* @param origin Buffer de origen |
670 | 646 |
* @param dest Buffer de destino |
671 | 647 |
* @param col Columna del buffer de destino donde se empieza a escribir |
672 | 648 |
* @param row Fila del buffer de destino donde se empieza a escribir |
673 |
* @return array con los valores que representan la ?ltima fila y
|
|
674 |
* ?ltima columna que se escribieron
|
|
649 |
* @return array con los valores que representan la ?ltima fila y |
|
650 |
* ?ltima columna que se escribieron |
|
675 | 651 |
*/ |
676 | 652 |
private void copyTile(IBuffer origin, IBuffer dest, int r, int c) { |
677 | 653 |
switch(origin.getDataType()) { |
678 | 654 |
case IBuffer.TYPE_BYTE : |
679 |
for (int band = 0; band < origin.getBandCount(); band++)
|
|
680 |
for (int row = 0; row < origin.getHeight(); row++)
|
|
681 |
for (int col = 0; col < origin.getWidth(); col++)
|
|
655 |
for (int band = 0; band < origin.getBandCount(); band++) |
|
656 |
for (int row = 0; row < origin.getHeight(); row++) |
|
657 |
for (int col = 0; col < origin.getWidth(); col++) |
|
682 | 658 |
try { |
683 | 659 |
dest.setElem(row + r, col + c, band, origin.getElemByte(row, col, band)); |
684 | 660 |
} catch (ArrayIndexOutOfBoundsException e) {break;} |
685 | 661 |
break; |
686 | 662 |
case IBuffer.TYPE_SHORT : |
687 |
for (int band = 0; band < origin.getBandCount(); band++)
|
|
688 |
for (int row = 0; row < origin.getHeight(); row++)
|
|
689 |
for (int col = 0; col < origin.getWidth(); col++)
|
|
663 |
for (int band = 0; band < origin.getBandCount(); band++) |
|
664 |
for (int row = 0; row < origin.getHeight(); row++) |
|
665 |
for (int col = 0; col < origin.getWidth(); col++) |
|
690 | 666 |
try { |
691 | 667 |
dest.setElem(row + r, col + c, band, origin.getElemShort(row, col, band)); |
692 | 668 |
} catch (ArrayIndexOutOfBoundsException e) {break;} |
693 | 669 |
break; |
694 | 670 |
case IBuffer.TYPE_FLOAT : |
695 |
for (int band = 0; band < origin.getBandCount(); band++)
|
|
696 |
for (int row = 0; row < origin.getHeight(); row++)
|
|
697 |
for (int col = 0; col < origin.getWidth(); col++)
|
|
671 |
for (int band = 0; band < origin.getBandCount(); band++) |
|
672 |
for (int row = 0; row < origin.getHeight(); row++) |
|
673 |
for (int col = 0; col < origin.getWidth(); col++) |
|
698 | 674 |
try { |
699 | 675 |
dest.setElem(row + r, col + c, band, origin.getElemFloat(row, col, band)); |
700 | 676 |
} catch (ArrayIndexOutOfBoundsException e) {break;} |
701 | 677 |
break; |
702 | 678 |
case IBuffer.TYPE_DOUBLE: |
703 |
for (int band = 0; band < origin.getBandCount(); band++)
|
|
704 |
for (int row = 0; row < origin.getHeight(); row++)
|
|
705 |
for (int col = 0; col < origin.getWidth(); col++)
|
|
679 |
for (int band = 0; band < origin.getBandCount(); band++) |
|
680 |
for (int row = 0; row < origin.getHeight(); row++) |
|
681 |
for (int col = 0; col < origin.getWidth(); col++) |
|
706 | 682 |
try { |
707 | 683 |
dest.setElem(row + r, col + c, band, origin.getElemDouble(row, col, band)); |
708 | 684 |
} catch (ArrayIndexOutOfBoundsException e) {break;} |
709 | 685 |
break; |
710 | 686 |
} |
711 | 687 |
} |
712 |
|
|
688 |
|
|
713 | 689 |
/* |
714 | 690 |
* (non-Javadoc) |
715 | 691 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getWindowRaster(double, double, double, double) |
716 | 692 |
*/ |
717 |
public IBuffer getWindowRaster(double ulx, double uly, double lrx, double lry)
|
|
693 |
public IBuffer getWindowRaster(double ulx, double uly, double lrx, double lry) |
|
718 | 694 |
throws InvalidSetViewException, InterruptedException, RasterDriverException { |
719 | 695 |
try { |
720 | 696 |
MultiRasterDataset[][] datasetList = getDatasetListInArea(ulx, uly, lrx, lry); |
721 | 697 |
int n = mosaic.length; |
722 | 698 |
int m = mosaic[0].length; |
723 | 699 |
IBuffer[][] bufferList = new IBuffer[n][m]; |
724 |
for (int row = 0; row < n; row++)
|
|
725 |
for (int col = 0; col < m; col++)
|
|
700 |
for (int row = 0; row < n; row++) |
|
701 |
for (int col = 0; col < m; col++) |
|
726 | 702 |
if(datasetList[row][col] != null) |
727 | 703 |
bufferList[row][col] = datasetList[row][col].getWindowRaster(ulx, uly, lrx, lry); |
728 |
return generateBuffer(bufferList, mosaic[0][0].getBands().getDrawableBandsCount()); |
|
704 |
IBuffer endBuffer = generateBuffer(bufferList, mosaic[0][0] |
|
705 |
.getBands().getDrawableBandsCount()); |
|
706 |
for (int row = 0; row < n; row++) |
|
707 |
for (int col = 0; col < m; col++) |
|
708 |
if (bufferList[row][col] != null) |
|
709 |
bufferList[row][col].free(); |
|
710 |
return endBuffer; |
|
729 | 711 |
} catch (NoninvertibleTransformException e) { |
730 | 712 |
throw new InvalidSetViewException("No se ha podido aplicar la transformaci?n inversa para esa vista."); |
731 | 713 |
} |
... | ... | |
735 | 717 |
* (non-Javadoc) |
736 | 718 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getWindowRaster(double, double, double, double, boolean) |
737 | 719 |
*/ |
738 |
public IBuffer getWindowRaster(double ulx, double uly, double w, double h, boolean adjustToExtent)
|
|
720 |
public IBuffer getWindowRaster(double ulx, double uly, double w, double h, boolean adjustToExtent) |
|
739 | 721 |
throws InvalidSetViewException, RasterDriverException { |
740 | 722 |
//TODO: FUNCIONALIDAD: getWindowRaster en CompositeDataset sin implementar |
741 | 723 |
return null; |
... | ... | |
745 | 727 |
* (non-Javadoc) |
746 | 728 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getWindowRaster(double, double, double, double, int, int, boolean) |
747 | 729 |
*/ |
748 |
public IBuffer getWindowRaster(double ulx, double uly, double lrx, double lry, int bufWidth, int bufHeight, boolean adjustToExtent)
|
|
730 |
public IBuffer getWindowRaster(double ulx, double uly, double lrx, double lry, int bufWidth, int bufHeight, boolean adjustToExtent) |
|
749 | 731 |
throws InvalidSetViewException, InterruptedException, RasterDriverException { |
750 | 732 |
try { |
751 | 733 |
Point2D p1 = new Point2D.Double(ulx, uly); |
... | ... | |
756 | 738 |
int n = mosaic.length; |
757 | 739 |
int m = mosaic[0].length; |
758 | 740 |
IBuffer[][] bufferList = new IBuffer[n][m]; |
759 |
for (int row = 0; row < n; row++)
|
|
760 |
for (int col = 0; col < m; col++)
|
|
741 |
for (int row = 0; row < n; row++) |
|
742 |
for (int col = 0; col < m; col++) |
|
761 | 743 |
if(datasetList[row][col] != null) { |
762 | 744 |
int[] values = getLocalRequest((int)px1.getX(), (int)px1.getY(), (int)Math.abs(px2.getX() - px1.getX()), (int)Math.abs(px2.getY() - px1.getY()), row, col); |
763 | 745 |
if(values != null) { |
764 | 746 |
int bW = (int)Math.round((Math.abs(values[2] - values[0]) * bufWidth) / Math.abs(px2.getX() - px1.getX())); |
765 | 747 |
int bH = (int)Math.round((Math.abs(values[3] - values[1]) * bufHeight) / Math.abs(px2.getY() - px1.getY())); |
766 |
int wTile = ((int)Math.abs(values[2] - values[0]) > (int)datasetList[row][col].getWidth()) ? (int)datasetList[row][col].getWidth() : (int)Math.abs(values[2] - values[0]);
|
|
767 |
int hTile = ((int)Math.abs(values[3] - values[1]) > (int)datasetList[row][col].getHeight()) ? (int)datasetList[row][col].getHeight() : (int)Math.abs(values[3] - values[1]);
|
|
748 |
int wTile = (Math.abs(values[2] - values[0]) > (int)datasetList[row][col].getWidth()) ? (int)datasetList[row][col].getWidth() : (int)Math.abs(values[2] - values[0]);
|
|
749 |
int hTile = (Math.abs(values[3] - values[1]) > (int)datasetList[row][col].getHeight()) ? (int)datasetList[row][col].getHeight() : (int)Math.abs(values[3] - values[1]); |
|
768 | 750 |
bufferList[row][col] = datasetList[row][col].getWindowRaster(values[0], values[1], wTile, hTile, bW, bH); |
769 | 751 |
} |
770 | 752 |
} |
771 |
return generateBuffer(bufferList, mosaic[0][0].getBands().getDrawableBandsCount()); |
|
753 |
IBuffer endBuffer = generateBuffer(bufferList, mosaic[0][0] |
|
754 |
.getBands().getDrawableBandsCount()); |
|
755 |
for (int row = 0; row < n; row++) |
|
756 |
for (int col = 0; col < m; col++) |
|
757 |
if (bufferList[row][col] != null) |
|
758 |
bufferList[row][col].free(); |
|
759 |
return endBuffer; |
|
772 | 760 |
} catch (NoninvertibleTransformException e) { |
773 | 761 |
throw new InvalidSetViewException("No se ha podido aplicar la transformaci?n inversa para esa vista."); |
774 | 762 |
} |
... | ... | |
778 | 766 |
* (non-Javadoc) |
779 | 767 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getWindowRaster(int, int, int, int) |
780 | 768 |
*/ |
781 |
public IBuffer getWindowRaster(int x, int y, int w, int h)
|
|
769 |
public IBuffer getWindowRaster(int x, int y, int w, int h) |
|
782 | 770 |
throws InvalidSetViewException, InterruptedException, RasterDriverException { |
783 | 771 |
try { |
784 | 772 |
Point2D p1 = mosaic[0][0].rasterToWorld(new Point2D.Double(x, y)); |
... | ... | |
787 | 775 |
int n = mosaic.length; |
788 | 776 |
int m = mosaic[0].length; |
789 | 777 |
IBuffer[][] bufferList = new IBuffer[n][m]; |
790 |
for (int row = 0; row < n; row++)
|
|
791 |
for (int col = 0; col < m; col++)
|
|
778 |
for (int row = 0; row < n; row++) |
|
779 |
for (int col = 0; col < m; col++) |
|
792 | 780 |
if(datasetList[row][col] != null) { |
793 | 781 |
int[] values = getLocalRequest(x, y, w, h, row, col); |
794 |
int wTile = ((int)Math.abs(values[2] - values[0]) > (int)datasetList[row][col].getWidth()) ? (int)datasetList[row][col].getWidth() : (int)Math.abs(values[2] - values[0]);
|
|
795 |
int hTile = ((int)Math.abs(values[3] - values[1]) > (int)datasetList[row][col].getHeight()) ? (int)datasetList[row][col].getHeight() : (int)Math.abs(values[3] - values[1]);
|
|
796 |
if(values != null)
|
|
782 |
int wTile = (Math.abs(values[2] - values[0]) > (int)datasetList[row][col].getWidth()) ? (int)datasetList[row][col].getWidth() : (int)Math.abs(values[2] - values[0]);
|
|
783 |
int hTile = (Math.abs(values[3] - values[1]) > (int)datasetList[row][col].getHeight()) ? (int)datasetList[row][col].getHeight() : (int)Math.abs(values[3] - values[1]); |
|
784 |
if(values != null) |
|
797 | 785 |
bufferList[row][col] = datasetList[row][col].getWindowRaster(values[0], values[1], wTile, hTile); |
798 | 786 |
} |
799 |
return generateBuffer(bufferList, mosaic[0][0].getBands().getDrawableBandsCount()); |
|
787 |
IBuffer endBuffer = generateBuffer(bufferList, mosaic[0][0] |
|
788 |
.getBands().getDrawableBandsCount()); |
|
789 |
for (int row = 0; row < n; row++) |
|
790 |
for (int col = 0; col < m; col++) |
|
791 |
if (bufferList[row][col] != null) |
|
792 |
bufferList[row][col].free(); |
|
793 |
return endBuffer; |
|
800 | 794 |
} catch (NoninvertibleTransformException e) { |
801 | 795 |
throw new InvalidSetViewException("No se ha podido aplicar la transformaci?n inversa para esa vista."); |
802 | 796 |
} |
... | ... | |
806 | 800 |
* (non-Javadoc) |
807 | 801 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getWindowRaster(int, int, int, int, int, int) |
808 | 802 |
*/ |
809 |
public IBuffer getWindowRaster(int x, int y, int w, int h, int bufWidth, int bufHeight)
|
|
803 |
public IBuffer getWindowRaster(int x, int y, int w, int h, int bufWidth, int bufHeight) |
|
810 | 804 |
throws InvalidSetViewException, InterruptedException, RasterDriverException { |
811 | 805 |
try { |
812 | 806 |
Point2D p1 = mosaic[0][0].rasterToWorld(new Point2D.Double(x, y)); |
... | ... | |
815 | 809 |
int n = mosaic.length; |
816 | 810 |
int m = mosaic[0].length; |
817 | 811 |
IBuffer[][] bufferList = new IBuffer[n][m]; |
818 |
for (int row = 0; row < n; row++) {
|
|
819 |
for (int col = 0; col < m; col++) {
|
|
812 |
for (int row = 0; row < n; row++) |
|
813 |
for (int col = 0; col < m; col++) |
|
820 | 814 |
if(datasetList[row][col] != null) { |
821 | 815 |
int[] values = getLocalRequest(x, y, w, h, row, col); |
822 | 816 |
if(values != null) { |
823 | 817 |
int bW = Math.round((Math.abs(values[2] - values[0]) * bufWidth) / w); |
824 | 818 |
int bH = Math.round((Math.abs(values[3] - values[1]) * bufHeight) / h); |
825 |
int wTile = ((int)Math.abs(values[2] - values[0]) > (int)datasetList[row][col].getWidth()) ? (int)datasetList[row][col].getWidth() : (int)Math.abs(values[2] - values[0]);
|
|
826 |
int hTile = ((int)Math.abs(values[3] - values[1]) > (int)datasetList[row][col].getHeight()) ? (int)datasetList[row][col].getHeight() : (int)Math.abs(values[3] - values[1]);
|
|
819 |
int wTile = (Math.abs(values[2] - values[0]) > (int)datasetList[row][col].getWidth()) ? (int)datasetList[row][col].getWidth() : (int)Math.abs(values[2] - values[0]);
|
|
820 |
int hTile = (Math.abs(values[3] - values[1]) > (int)datasetList[row][col].getHeight()) ? (int)datasetList[row][col].getHeight() : (int)Math.abs(values[3] - values[1]); |
|
827 | 821 |
bufferList[row][col] = datasetList[row][col].getWindowRaster(values[0], values[1], wTile, hTile, bW, bH); |
828 | 822 |
} |
829 | 823 |
} |
830 |
} |
|
831 |
} |
|
832 |
return generateBuffer(bufferList, mosaic[0][0].getBands().getDrawableBandsCount()); |
|
824 |
IBuffer endBuffer = generateBuffer(bufferList, mosaic[0][0] |
|
825 |
.getBands().getDrawableBandsCount()); |
|
826 |
for (int row = 0; row < n; row++) |
|
827 |
for (int col = 0; col < m; col++) |
|
828 |
if (bufferList[row][col] != null) |
|
829 |
bufferList[row][col].free(); |
|
830 |
return endBuffer; |
|
833 | 831 |
} catch (NoninvertibleTransformException e) { |
834 | 832 |
throw new InvalidSetViewException("No se ha podido aplicar la transformaci?n inversa para esa vista."); |
835 | 833 |
} |
836 | 834 |
} |
837 |
|
|
835 |
|
|
838 | 836 |
/** |
839 | 837 |
* Convierte una petici?n global del mosaico en coordenadas pixel a una local al tile |
840 | 838 |
* concreto que se est? tratando |
... | ... | |
848 | 846 |
*/ |
849 | 847 |
private int[] getLocalRequest(int x, int y, int w, int h, int r, int c) { |
850 | 848 |
Point2D p1 = null, p2 = null; |
851 |
|
|
849 |
|
|
852 | 850 |
if(!requestGoThroughTile(x, y, w, h, r, c)) |
853 | 851 |
return null; |
854 |
|
|
852 |
|
|
855 | 853 |
if(isInside(x, y, r, c)) |
856 | 854 |
p1 = getLocalPixel(x, y); |
857 |
else { |
|
858 |
if(getTileFromPixelPoint(x, y)[0] == r) //Est? en la misma fila |
|
859 |
p1 = new Point2D.Double(0, getLocalPixel(x, y).getY()); |
|
860 |
else if(getTileFromPixelPoint(x, y)[1] == c) //Est? en la misma columna |
|
861 |
p1 = new Point2D.Double(getLocalPixel(x, y).getX(), 0); |
|
862 |
else |
|
863 |
p1 = new Point2D.Double(0, 0); |
|
864 |
} |
|
855 |
else if(getTileFromPixelPoint(x, y)[0] == r) //Est? en la misma fila |
|
856 |
p1 = new Point2D.Double(0, getLocalPixel(x, y).getY()); |
|
857 |
else if(getTileFromPixelPoint(x, y)[1] == c) //Est? en la misma columna |
|
858 |
p1 = new Point2D.Double(getLocalPixel(x, y).getX(), 0); |
|
859 |
else |
|
860 |
p1 = new Point2D.Double(0, 0); |
|
865 | 861 |
int fx = x + w; |
866 | 862 |
int fy = y + h; |
867 |
if(isInside(fx, fy, r, c))
|
|
863 |
if(isInside(fx, fy, r, c)) |
|
868 | 864 |
p2 = getLocalPixel(fx, fy); |
869 |
else { |
|
870 |
if(getTileFromPixelPoint(fx, fy)[0] == r) |
|
871 |
p2 = new Point2D.Double(mosaic[r][c].getWidth(), getLocalPixel(fx, fy).getY()); |
|
872 |
else if(getTileFromPixelPoint(fx, fy)[1] == c) |
|
873 |
p2 = new Point2D.Double(getLocalPixel(fx, fy).getX(), mosaic[r][c].getHeight()); |
|
874 |
else |
|
875 |
p2 = new Point2D.Double(mosaic[r][c].getWidth(), mosaic[r][c].getHeight()); |
|
876 |
} |
|
865 |
else if(getTileFromPixelPoint(fx, fy)[0] == r) |
|
866 |
p2 = new Point2D.Double(mosaic[r][c].getWidth(), getLocalPixel(fx, fy).getY()); |
|
867 |
else if(getTileFromPixelPoint(fx, fy)[1] == c) |
|
868 |
p2 = new Point2D.Double(getLocalPixel(fx, fy).getX(), mosaic[r][c].getHeight()); |
|
869 |
else |
|
870 |
p2 = new Point2D.Double(mosaic[r][c].getWidth(), mosaic[r][c].getHeight()); |
|
877 | 871 |
if(p1 != null && p2 != null) |
878 | 872 |
return new int[]{(int)p1.getX(), (int)p1.getY(), (int)p2.getX(), (int)p2.getY()}; |
879 | 873 |
return null; |
880 | 874 |
} |
881 |
|
|
875 |
|
|
882 | 876 |
/** |
883 | 877 |
* Consulta si una petici?n en coordenadas pixel de la imagen completa pasa a trav?s de un |
884 | 878 |
* tile de posici?n r, c |
... | ... | |
895 | 889 |
return true; |
896 | 890 |
Point2D p1 = getGlobalPixel(x, y, r, c); |
897 | 891 |
Point2D p2 = getGlobalPixel(w, h, r, c); |
898 |
|
|
899 |
//Intersecci?n entre el ?rea pedida y el tile. Si intersectan se devuelve true
|
|
900 |
if(((x <= p1.getX() && w >= p1.getX()) || (x <= p2.getX() && w >= p2.getX())) &&
|
|
901 |
((y <= p1.getY() && h >= p1.getY()) || (y <= p2.getY() && h >= p2.getY())))
|
|
892 |
|
|
893 |
//Intersecci?n entre el ?rea pedida y el tile. Si intersectan se devuelve true |
|
894 |
if(((x <= p1.getX() && w >= p1.getX()) || (x <= p2.getX() && w >= p2.getX())) && |
|
895 |
((y <= p1.getY() && h >= p1.getY()) || (y <= p2.getY() && h >= p2.getY()))) |
|
902 | 896 |
return true; |
903 | 897 |
return false; |
904 | 898 |
} |
905 |
|
|
899 |
|
|
906 | 900 |
/** |
907 | 901 |
* Obtiene el tile correspondiente a un pixel dado |
908 | 902 |
* @param x Posici?n X del punto a comprobar |
... | ... | |
918 | 912 |
return new int[]{row, col}; |
919 | 913 |
return null; |
920 | 914 |
} |
921 |
|
|
915 |
|
|
922 | 916 |
/** |
923 | 917 |
* Comprueba si un punto (x, y) cae dentro de un Tile (r, c) |
924 | 918 |
* @param x Posici?n X del punto a comprobar |
... | ... | |
947 | 941 |
} |
948 | 942 |
return (posR == r && posC == c) ? true : false; |
949 | 943 |
} |
950 |
|
|
951 |
|
|
944 |
|
|
945 |
|
|
952 | 946 |
/** |
953 | 947 |
* Obtiene la coordenada pixel local para un raster dada la coordenada pixel global |
954 | 948 |
* @param x Coordenada X global |
... | ... | |
975 | 969 |
} |
976 | 970 |
return new Point2D.Double(w, h); |
977 | 971 |
} |
978 |
|
|
972 |
|
|
979 | 973 |
/** |
980 | 974 |
* Obtiene la coordenada pixel global para un raster dada la coordenada pixel local |
981 | 975 |
* @param x Coordenada X local |
... | ... | |
989 | 983 |
for (int row = 0; row < (r - 1); row++) |
990 | 984 |
sumY += mosaic[row][0].getHeight(); |
991 | 985 |
sumY += y; |
992 |
for (int col = 0; col < (c - 1); col++)
|
|
986 |
for (int col = 0; col < (c - 1); col++) |
|
993 | 987 |
sumX += mosaic[0][col].getWidth(); |
994 | 988 |
sumX += x; |
995 | 989 |
return new Point2D.Double(sumX, sumY); |
996 | 990 |
} |
997 |
|
|
991 |
|
|
998 | 992 |
/* |
999 | 993 |
* (non-Javadoc) |
1000 | 994 |
* @see org.gvsig.raster.dataset.IRasterDataSource#setDrawableBands(int[]) |
... | ... | |
1002 | 996 |
public void setDrawableBands(int[] db) { |
1003 | 997 |
int n = mosaic.length; |
1004 | 998 |
int m = mosaic[0].length; |
1005 |
for (int row = 0; row < n; row++)
|
|
1006 |
for (int col = 0; col < m; col++)
|
|
999 |
for (int row = 0; row < n; row++) |
|
1000 |
for (int col = 0; col < m; col++) |
|
1007 | 1001 |
mosaic[row][col].setDrawableBands(db); |
1008 | 1002 |
} |
1009 |
|
|
1003 |
|
|
1010 | 1004 |
/* |
1011 | 1005 |
* (non-Javadoc) |
1012 | 1006 |
* @see org.gvsig.raster.dataset.IRasterDataSource#clearDrawableBands() |
... | ... | |
1014 | 1008 |
public void clearDrawableBands() { |
1015 | 1009 |
int n = mosaic.length; |
1016 | 1010 |
int m = mosaic[0].length; |
1017 |
for (int row = 0; row < n; row++)
|
|
1018 |
for (int col = 0; col < m; col++)
|
|
1011 |
for (int row = 0; row < n; row++) |
|
1012 |
for (int col = 0; col < m; col++) |
|
1019 | 1013 |
mosaic[row][col].clearDrawableBands(); |
1020 | 1014 |
} |
1021 |
|
|
1015 |
|
|
1022 | 1016 |
/* |
1023 | 1017 |
* (non-Javadoc) |
1024 | 1018 |
* @see org.gvsig.raster.dataset.IRasterDataSource#addDrawableBand(int, int) |
... | ... | |
1026 | 1020 |
public void addDrawableBand(int posRasterBuf, int imageBand){ |
1027 | 1021 |
int n = mosaic.length; |
1028 | 1022 |
int m = mosaic[0].length; |
1029 |
for (int row = 0; row < n; row++)
|
|
1030 |
for (int col = 0; col < m; col++)
|
|
1023 |
for (int row = 0; row < n; row++) |
|
1024 |
for (int col = 0; col < m; col++) |
|
1031 | 1025 |
mosaic[row][col].addDrawableBand(posRasterBuf, imageBand); |
1032 | 1026 |
} |
1033 | 1027 |
|
... | ... | |
1040 | 1034 |
return mosaic[0][0].getTransparencyFilesStatus(); |
1041 | 1035 |
return new Transparency(); |
1042 | 1036 |
} |
1043 |
|
|
1037 |
|
|
1044 | 1038 |
/* |
1045 | 1039 |
* (non-Javadoc) |
1046 | 1040 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getColorTables() |
... | ... | |
1050 | 1044 |
return mosaic[0][0].getColorTables(); |
1051 | 1045 |
return null; |
1052 | 1046 |
} |
1053 |
|
|
1047 |
|
|
1054 | 1048 |
/* |
1055 | 1049 |
* (non-Javadoc) |
1056 | 1050 |
* @see org.gvsig.raster.hierarchy.IHistogramable#getHistogram() |
1057 | 1051 |
*/ |
1058 | 1052 |
public Histogram getHistogram() throws InterruptedException, HistogramException { |
1059 | 1053 |
Histogram[][] histogram = new Histogram[mosaic.length][mosaic[0].length]; |
1060 |
|
|
1054 |
|
|
1061 | 1055 |
try { |
1062 |
for (int i = 0; i < histogram.length; i++) {
|
|
1063 |
for (int j = 0; j < histogram[i].length; j++) {
|
|
1056 |
for (int i = 0; i < histogram.length; i++) |
|
1057 |
for (int j = 0; j < histogram[i].length; j++) { |
|
1064 | 1058 |
histogram[i][j] = new DatasetListHistogram(mosaic[i][j]).getHistogram(); |
1065 |
if(i != 0 || j != 0)
|
|
1059 |
if(i != 0 || j != 0) |
|
1066 | 1060 |
histogram[0][0].union(histogram[i][j]); |
1067 | 1061 |
} |
1068 |
} |
|
1069 | 1062 |
return histogram[0][0]; |
1070 | 1063 |
} catch (FileNotOpenException e) { |
1071 | 1064 |
throw new HistogramException("FileNotOpenException"); |
... | ... | |
1073 | 1066 |
throw new HistogramException("RasterDriverException"); |
1074 | 1067 |
} |
1075 | 1068 |
} |
1076 |
|
|
1069 |
|
|
1077 | 1070 |
/** |
1078 | 1071 |
* Obtiene la paleta correspondiente a uno de los ficheros que forman el GeoMultiRasterFile |
1079 | 1072 |
* @param i Posici?n del raster |
... | ... | |
1082 | 1075 |
public ColorTable getColorTable(int i){ |
1083 | 1076 |
return (mosaic != null) ? mosaic[0][0].getColorTable(i) : null; |
1084 | 1077 |
} |
1085 |
|
|
1078 |
|
|
1086 | 1079 |
/** |
1087 |
* Obtiene la paleta correspondiente al nombre del fichero pasado por par?metro.
|
|
1080 |
* Obtiene la paleta correspondiente al nombre del fichero pasado por par?metro. |
|
1088 | 1081 |
* @param fileName Nombre del fichero |
1089 | 1082 |
* @return Paleta o null si no la tiene |
1090 | 1083 |
*/ |
1091 | 1084 |
public ColorTable getColorTable(String fileName){ |
1092 | 1085 |
return (mosaic != null) ? mosaic[0][0].getColorTable(fileName) : null; |
1093 | 1086 |
} |
1094 |
|
|
1087 |
|
|
1095 | 1088 |
/* |
1096 | 1089 |
* (non-Javadoc) |
1097 | 1090 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getData(int, int, int) |
... | ... | |
1121 | 1114 |
public void setReadOnly(boolean readOnly) { |
1122 | 1115 |
this.readOnly = readOnly; |
1123 | 1116 |
} |
1124 |
|
|
1117 |
|
|
1125 | 1118 |
/* |
1126 | 1119 |
* (non-Javadoc) |
1127 | 1120 |
* @see org.gvsig.raster.dataset.IRasterDataSource#isMemoryBuffer() |
... | ... | |
1217 | 1210 |
for (int col = 0; col < m; col++) |
1218 | 1211 |
mosaic[row][col].setNoDataEnabled(enabled); |
1219 | 1212 |
} |
1220 |
|
|
1213 |
|
|
1221 | 1214 |
/* |
1222 | 1215 |
* (non-Javadoc) |
1223 | 1216 |
* @see org.gvsig.raster.dataset.IRasterDataSource#loadGeoPointsFromRmf() |
... | ... | |
1231 | 1224 |
* @see org.gvsig.raster.dataset.IRasterDataSource#saveGeoPointsToRmf(org.gvsig.raster.datastruct.GeoPointList) |
1232 | 1225 |
*/ |
1233 | 1226 |
public void saveGeoPointsToRmf(GeoPointList geoPoints) throws IOException { |
1234 |
throw new IOException("Not implemented yet");
|
|
1227 |
throw new IOException("Not implemented yet"); |
|
1235 | 1228 |
} |
1236 |
|
|
1229 |
|
|
1237 | 1230 |
/* |
1238 | 1231 |
* (non-Javadoc) |
1239 | 1232 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getDataset(java.lang.String) |
... | ... | |
1273 | 1266 |
public int getPercent() { |
1274 | 1267 |
return 0; |
1275 | 1268 |
} |
1276 |
|
|
1269 |
|
|
1277 | 1270 |
/* |
1278 | 1271 |
* (non-Javadoc) |
1279 | 1272 |
* @see org.gvsig.raster.dataset.IRasterDataSource#getColorInterpretation() |
Also available in: Unified diff