Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extRemoteSensing / src / org / gvsig / remotesensing / mosaic / process / MosaicProcess.java @ 26348

History | View | Annotate | Download (20.5 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Iba?ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
34
 *   Campus Universitario s/n
35
 *   02071 Alabacete
36
 *   Spain
37
 *
38
 *   +34 967 599 200
39
 */
40

    
41
package org.gvsig.remotesensing.mosaic.process;
42

    
43
import java.awt.Point;
44
import java.awt.geom.AffineTransform;
45
import java.awt.geom.Point2D;
46
import java.awt.image.DataBuffer;
47
import java.io.File;
48
import java.io.IOException;
49

    
50
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
51
import org.gvsig.raster.RasterProcess;
52
import org.gvsig.raster.buffer.BufferFactory;
53
import org.gvsig.raster.buffer.BufferInterpolation;
54
import org.gvsig.raster.buffer.RasterBuffer;
55
import org.gvsig.raster.buffer.RasterBufferInvalidException;
56
import org.gvsig.raster.buffer.WriterBufferServer;
57
import org.gvsig.raster.dataset.FileNotOpenException;
58
import org.gvsig.raster.dataset.GeoRasterWriter;
59
import org.gvsig.raster.dataset.IBuffer;
60
import org.gvsig.raster.dataset.IRasterDataSource;
61
import org.gvsig.raster.dataset.InvalidSetViewException;
62
import org.gvsig.raster.dataset.NotSupportedExtensionException;
63
import org.gvsig.raster.dataset.io.RasterDriverException;
64
import org.gvsig.raster.grid.Grid;
65
import org.gvsig.raster.grid.GridCell;
66
import org.gvsig.raster.grid.GridExtent;
67
import org.gvsig.raster.grid.OutOfGridException;
68
import org.gvsig.raster.grid.filter.RasterFilter;
69
import org.gvsig.raster.grid.filter.enhancement.EnhancementStretchListManager;
70
import org.gvsig.raster.grid.filter.enhancement.LinearStretchParams;
71
import org.gvsig.raster.util.RasterToolsUtil;
72
import org.gvsig.remotesensing.RemoteSensingUtils;
73

    
74
import com.iver.andami.PluginServices;
75
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException;
76

    
77
/** 
78
* Clase que implementa el proceso de construccion de un mosaico mediante los m?todos b?sicos.
79
* 
80
* @params
81
* <LI>FLyrRasterSE[] "inputRasterLayers": Capas raster de entrada</LI>
82
* <LI>int "methodCode": M?todo de construcci?n (0:Valor m?ximo, 1:Valor m?nimo, 2: Valor Medio,
83
* 3: Valor del pixel de la capa superior, 4:Valor del pixel de la capa inferior)</LI>
84
* <LI>String "outputPath": Ruta completa al fichero de salida del proceso</LI>
85
* 
86
* @result
87
* <LI>outputRassterLayers[]: Capas raster resultantes</LI>
88
*
89
* 
90
* @author aMu?oz (alejandro.mu?oz@uclm.es)
91
* @version 30/4/2008
92
* */
93

    
94
public class MosaicProcess extends RasterProcess {
95
        
96
        public static final int MAX                 = 0;
97
        public static final int MIN                 = 1;
98
        public static final int AVERAGE         = 2;
99
        public static final int FRONT                 = 3;
100
        public static final int BACK                 = 4;
101

    
102
        // Layers que intervienen en el proceso
103
        private FLyrRasterSE inputRasterLayers[] = null;
104
        
105
        //Layer de salida
106
        private FLyrRasterSE outputRasterLayer = null;
107

    
108
        // Extend completo del mosaico
109
        private GridExtent fullExtend= null;
110
        
111
        // Grid resultante
112
        Grid mosaicGrid = null;
113
        
114
        // Buffers con las imagenes
115
        IBuffer buffers[]= null;
116
        
117
        // Codigo operacion mayor, menor,media valor de la situada encima.
118
        int codOp= 0; 
119
        
120
        // indicador de proceso
121
        int percent=0, proceso=0;
122
         
123
        // writer para escritura en fichero 
124
        private WriterBufferServer writerBufferServer =null;
125
        
126
        //  Numero de bandas 3 o 1 dependiendo de si es RGB o Nivel de gris
127
        int resultbandCount=0;
128
         
129
        // Fichero de salida
130
        private String fileName=null; 
131
        
132
        
133
        private Grid layersGrid[]= null;
134
        
135
        /** Inicializaci?n de los par?metros
136
         *  layers -  FLayers con los layers seleccionados para el mosaico.
137
         * 
138
         *         En la inicializacion se calcula el grid resultante.
139
         * */
140
        public void init() {
141
                
142
                inputRasterLayers= (FLyrRasterSE[])getParam("inputRasterLayers");
143
                codOp= getIntParam("methodCode");
144
                resultbandCount= getIntParam("numbands");
145
                fileName = getStringParam("outputPath");
146
                layersGrid = new Grid [inputRasterLayers.length];
147
                
148
//                 Calculo del extend resultante
149
                fullExtend= calculateExtend(inputRasterLayers);
150
                
151
                try {
152
                                mosaicGrid= new Grid(fullExtend,fullExtend,IBuffer.TYPE_BYTE,new int[] { 0, 1, 2 });
153
                                //mosaicGrid.setNoDataValue(-127);
154
                                resultbandCount = mosaicGrid.getBandCount();
155
                } catch (RasterBufferInvalidException e) {
156
                        RasterToolsUtil.messageBoxError("buffer_incorrecto", this, e);
157
                }
158
        }
159

    
160
        
161
        /**
162
         *  Proceso
163
         * */
164
        public void process() throws InterruptedException {
165
                
166
                // Parte de carga de los datos
167
                buffers= new RasterBuffer[inputRasterLayers.length];
168
                IRasterDataSource dsetCopy = null; 
169
                try {
170
                
171
                        double minX= fullExtend.getMin().getX();
172
                        double minY= fullExtend.getMin().getY();
173
                        double maxX=  fullExtend.getMax().getX();
174
                        double maxY=  fullExtend.getMax().getY();
175
                        // Se cargan todos los raster en los grid correspondientes
176
                        percent=1;
177
                        for(int i=0; i< inputRasterLayers.length;i++)
178
                        {        
179
                                dsetCopy = ((FLyrRasterSE)inputRasterLayers[i]).getDataSource().newDataset();
180
                                BufferFactory bufferFactory = new BufferFactory(dsetCopy);
181
                                bufferFactory.setAdjustToExtent(false);
182
                                if (!RasterBuffer.loadInMemory(dsetCopy))
183
                                        bufferFactory.setReadOnly(true);
184
                                // Si pongo solo las renderizadas en algunos casos da problemas
185
                                bufferFactory.setDrawableBands(inputRasterLayers[i].getRenderBands());
186
                                
187
                                GridExtent gridExtent = new GridExtent(fullExtend.getMin().getX(),
188
                                                fullExtend.getMin().getY(),
189
                                                fullExtend.getMax().getX(),
190
                                                fullExtend.getMax().getY(),
191
                                                inputRasterLayers[i].getAffineTransform().getScaleX(),
192
                                                inputRasterLayers[i].getAffineTransform().getScaleY());
193
                                
194
                                bufferFactory.setAreaOfInterest(minX,minY,maxX,maxY,gridExtent.getNX(),gridExtent.getNY());
195
                                buffers[i]= (RasterBuffer) bufferFactory.getRasterBuf();
196
                                //buffers[i] = ((RasterBuffer)buffers[i]).getAdjustedWindow(fullExtend.getNX(), fullExtend.getNY(), BufferInterpolation.INTERPOLATION_Bilinear);
197
                                try {
198
                                        layersGrid[i]= new Grid (bufferFactory,inputRasterLayers[i].getRenderBands());
199
                                } catch (RasterBufferInvalidException e) {
200
                                        // TODO Auto-generated catch block
201
                                        e.printStackTrace();
202
                                };
203
                                percent=(int)((i+1)*100/inputRasterLayers.length);
204
                                
205
                                //Aplicar filtro de realce si es necesario:
206
                                if(buffers[i].getDataType()!=DataBuffer.TYPE_BYTE){
207
                                        LinearStretchParams leParams = null;
208
                                        leParams = LinearStretchParams.createStandardParam(inputRasterLayers[i].getRenderBands(), 0.0, bufferFactory.getDataSource().getStatistics(), false);
209
                                
210
                                        RasterFilter linearStretchEnhancementFilter = EnhancementStretchListManager.createEnhancedFilter(leParams, bufferFactory.getDataSource().getStatistics(),
211
                                                        inputRasterLayers[i].getRenderBands(), false);
212
                                        linearStretchEnhancementFilter.addParam("raster", buffers[i]);
213
                                        linearStretchEnhancementFilter.execute();
214
                                        buffers[i] = (IBuffer)linearStretchEnhancementFilter.getResult("raster");
215
                                }
216
                        
217
                        }
218
                }catch (RasterDriverException e) {
219
                        RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_writer"), this, e);        
220
                } catch (InvalidSetViewException e) {
221
                        RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_extension"), this, e);        
222
                } catch (InterruptedException e) {
223
                        Thread.currentThread().interrupt();
224
                } catch (FileNotOpenException e) {
225
                        RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_writer"), this, e);        
226
                } 
227
                
228
                proceso=1;
229
            
230
//                 Construccion del mosaico: Operaci?n M?ximo
231
                if(codOp==MAX){
232
                        int progress = 0;
233
                        for(int band=0; band<resultbandCount; band++){
234
                                mosaicGrid.setBandToOperate(band);
235
                                for(int row=0; row<mosaicGrid.getLayerNY(); row++){
236
                                        progress++;
237
                                        for(int col=0; col<mosaicGrid.getLayerNX();col++){
238
                                                setValueMax(col,row,band);
239
                                        }
240
                                        percent=(int)( progress*100/(mosaicGrid.getLayerNY()*resultbandCount));
241
                                }
242
                        }
243
                }
244
                
245
//                Construccion del mosaico: Operaci?n M?nimo
246
                if(codOp==MIN){
247
                        int progress = 0;
248
                        for(int band=0; band<resultbandCount; band++){
249
                                mosaicGrid.setBandToOperate(band);
250
                                for(int row=0; row<mosaicGrid.getLayerNY(); row++){
251
                                        progress++;
252
                                        for(int col=0; col<mosaicGrid.getLayerNX();col++){
253
                                                setValueMin(col,row,band);
254
                                        }
255
                                        percent=(int)( progress*100/(mosaicGrid.getLayerNY()*resultbandCount));
256
                                }
257
                        }
258
                }
259
                
260
//                 Construccion del mosaico: Operaci?n Media
261
                if(codOp==AVERAGE){
262
                        int progress = 0;
263
                        for(int band=0; band<resultbandCount; band++){
264
                                mosaicGrid.setBandToOperate(band);
265
                                for(int col=0; col<mosaicGrid.getLayerNY(); col++){
266
                                        progress++;
267
                                        for(int row=0; row<mosaicGrid.getLayerNX();row++){
268
                                                setValueMean(row,col,band);
269
                                        }
270
                                        percent=(int)( progress*100/(mosaicGrid.getLayerNY()*resultbandCount));
271
                                }
272
                        }
273
                }
274
                
275
//                Construccion del mosaico: Operacion valor de capa de delantera
276
                if(codOp==FRONT){
277
                        int progress = 0;
278
                        for(int band=0; band<resultbandCount; band++){
279
                                mosaicGrid.setBandToOperate(band);
280
                                for(int row=0; row<mosaicGrid.getLayerNY(); row++){
281
                                        progress++;
282
                                        for(int col=0; col<mosaicGrid.getLayerNX();col++){
283
                                                setValueFront(col,row,band);
284
                                        }
285
                                        percent=(int)( progress*100/(mosaicGrid.getLayerNY()*resultbandCount));
286
                                }
287
                        }
288
                }
289
                
290
                
291
//                Construccion del mosaico: Operaci?n Valor de capa de trasera
292
                if(codOp==BACK){
293
                        int progress = 0;
294
                        for(int band=0; band<resultbandCount; band++){
295
                                mosaicGrid.setBandToOperate(band);
296
                                for(int row=0; row<mosaicGrid.getLayerNY(); row++){
297
                                        progress++;
298
                                        for(int col=0; col<mosaicGrid.getLayerNX();col++){
299
                                                setValueBack(col,row,band);
300
                                        }
301
                                        percent=(int)( progress*100/(mosaicGrid.getLayerNY()*resultbandCount));
302
                                }
303
                        }
304
                }
305
                
306
                // Se liberan los buffers
307
                for(int i=0; i<inputRasterLayers.length;i++)
308
                        buffers[i].free();
309
                
310
                // Escritura en fichero
311
                proceso=2;
312
                createLayer();
313
                if (externalActions != null)
314
                        externalActions.end(outputRasterLayer);
315
        }
316

    
317
        
318
        /**
319
         *  M?todo que establece para la coordenada x,y el valor m?ximo 
320
         *  de todos los valores para ese p?xel en cualquiera de las imagenes.
321
         *  @param cordenada x 
322
         *  @param coordenada y  
323
         * */
324
        public void setValueMax(int x, int y, int band){
325
                byte result=Byte.MIN_VALUE; byte data=Byte.MIN_VALUE;
326
                int numLayers= buffers.length;
327
                Point2D worldPoint= (Point2D) mosaicGrid.getGridExtent().getWorldCoordsFromGridCoords(new GridCell(x,y,(double)0));
328
                for(int i=0; i<numLayers;i++){
329
                        if(layersGrid[i].getGridExtent().isAt(worldPoint))
330
                        {
331
                                data = (byte)RemoteSensingUtils.getCellValueInLayerCoords(buffers[i], x, y, band);
332
                                result=(byte) Math.max((byte)result,(byte)data);        
333
                        }
334
                }
335
                try {
336
                                mosaicGrid.setCellValue(x,y,(byte)result);
337
                } catch (OutOfGridException e) {
338
                                e.printStackTrace();
339
                }
340
        }
341
        
342
        /**
343
         *  M?todo que establece para la coordenada x,y el valor m?ximo 
344
         *  de todos los valores para ese p?xel en cualquiera de las imagenes.
345
         *  Si el valor en cualquiera de las imagenes es noData no es tenido en cuenta 
346
         *  @param cordenada x 
347
         *  @param coordenada y  
348
         * */
349
        public void setValueMin(int x, int y,int band){
350
                byte result=Byte.MAX_VALUE; byte data=Byte.MAX_VALUE;
351
                int numLayers= buffers.length;
352
                Point2D worldPoint= (Point2D) mosaicGrid.getGridExtent().getWorldCoordsFromGridCoords(new GridCell(x,y,(double)0));
353
                for(int i=0; i<numLayers;i++){
354
                                if(layersGrid[i].getGridExtent().isAt(worldPoint))
355
                                {
356
                                        data = (byte)RemoteSensingUtils.getCellValueInLayerCoords(buffers[i], x, y, band);
357
                                        result=(byte) Math.min((byte)result,(byte)data);        
358
                                }
359
                }
360
                try {
361
                                mosaicGrid.setCellValue(x,y,(byte)result);
362
                } catch (OutOfGridException e) {
363
                                e.printStackTrace();
364
                }
365
        }
366
        
367
        
368
        /**
369
         *  M?todo que establece para la coordenada x,y el valor medio  
370
         *  de todos los valores para ese p?xel en cualquiera de las imagenes.
371
         *  Si el valor en cualquiera de las imagenes es noData no es tenido en cuenta 
372
         *  @param cordenada x 
373
         *  @param coordenada y  
374
         * */
375
        public void setValueMean(int x, int y, int band){
376
                int buffTotales=0; byte result=0;
377
                int numLayers= buffers.length;
378
                Point2D worldPoint= (Point2D) mosaicGrid.getGridExtent().getWorldCoordsFromGridCoords(new GridCell(x,y,(double)0));
379
                for(int i=0; i<numLayers;i++){
380
                        if(layersGrid[i].getGridExtent().isAt(worldPoint))
381
                        {
382
                                result+= (byte)RemoteSensingUtils.getCellValueInLayerCoords(buffers[i], x, y, band);
383
                                buffTotales++;
384
                        }
385
                }
386
                if(buffTotales==0)
387
                        buffTotales=1;
388
                result=(byte) ((byte)(new Double(result/(byte)buffTotales).byteValue())&0xff);
389
                
390
                try {
391
                                mosaicGrid.setCellValue(x,y,(byte)(result));
392
                } catch (OutOfGridException e) {
393
                                e.printStackTrace();
394
                }
395
        }
396
        
397
        
398
        /**
399
         *  M?todo que establece para la coordenada x,y el valor de la capa superior 
400
         *  en caso de solape. Se parte de un array de buffer ordenados, de tal manera que
401
         *  el primer elemento corresponde a la capa situada mas al frente. El ?ltimo por 
402
         *  contra es el situado al fondo.
403
         
404
         *  @param cordenada x 
405
         *  @param coordenada y  
406
         * */
407
        public void setValueFront(int x, int y, int band){
408
                byte result=0;
409
                int numLayers= buffers.length;
410
                Point2D worldPoint= (Point2D) mosaicGrid.getGridExtent().getWorldCoordsFromGridCoords(new GridCell(x,y,(double)0));
411
                for(int i=0; i<numLayers;i++){
412
                        if(layersGrid[i].getGridExtent().isAt(worldPoint))
413
                                {
414
                                        result = (byte)RemoteSensingUtils.getCellValueInLayerCoords(buffers[i], x, y, band);
415
                                        break;
416
                                }
417
                }
418
                try {
419
                                mosaicGrid.setCellValue(x,y,(byte)result);
420
                } catch (OutOfGridException e) {
421
                                e.printStackTrace();
422
                }
423
        }
424
        
425
        
426
        /**
427
         *  M?todo que establece para la coordenada x,y el valor de la capa inferior
428
         *  en caso de solape. Se parte de un array de buffer ordenados, de tal manera que
429
         *  el primer elemento corresponde a la capa situada mas al frente. El ?ltimo por 
430
         *  contra es el situado al fondo.
431
         
432
         *  @param cordenada x 
433
         *  @param coordenada y  
434
         * */
435
        public void setValueBack(int x, int y, int band){
436
                byte result=0;
437
                int numLayers= buffers.length;
438
                Point2D worldPoint= (Point2D) mosaicGrid.getGridExtent().getWorldCoordsFromGridCoords(new GridCell(x,y,(double)0));
439
                for(int i=0; i<numLayers;i++){
440
                        if(layersGrid[i].getGridExtent().isAt(worldPoint))
441
                                {
442
                                        result = (byte)RemoteSensingUtils.getCellValueInLayerCoords(buffers[i], x, y, band);
443
                                        
444
                                }
445
                }
446
                try {
447
                                mosaicGrid.setCellValue(x,y,(byte)result);
448
                } catch (OutOfGridException e) {
449
                                e.printStackTrace();
450
                }
451
        }
452
        
453
        
454
        /**
455
         * M?todo que calcula el extend resultante para la operaci?n de mosaico
456
         * 
457
         * @param layers que intervienen en la operacion.
458
         * @return GridExtend del mosaico
459
         * */
460
        
461
        private GridExtent calculateExtend (FLyrRasterSE layers[]){
462
                
463
                GridExtent result= null;
464
                IRasterDataSource dsetCopy = null; 
465
                double cellSize=Double.MAX_VALUE;
466
                double minX=0,maxX=0,minY=0,maxY=0;
467
                // Se obtiene el menor tama?o de celda mayor
468
                for(int i=0; i< layers.length;i++)
469
                {        
470
                        dsetCopy = ((FLyrRasterSE)layers[i]).getDataSource().newDataset();
471
                        BufferFactory bufferFactory = new BufferFactory(dsetCopy);
472
                        bufferFactory.setAdjustToExtent(false);
473
                        cellSize= Math.min(cellSize,bufferFactory.getDataSource().getCellSize());
474
                }
475
                
476
                minX = layers[0].getFullExtent().getMinX();
477
                minY = layers[0].getFullExtent().getMinY();
478
                maxX = layers[0].getFullExtent().getMaxX();
479
                maxY = layers[0].getFullExtent().getMaxY();
480
                
481
                for(int i=1; i<layers.length;i++){
482
                        
483
                        minX= Math.min(minX,layers[i].getFullExtent().getMinX());
484
                        minY= Math.min(minY,layers[i].getFullExtent().getMinY());
485
                        maxX= Math.max(maxX,layers[i].getFullExtent().getMaxX());
486
                        maxY= Math.max(maxY,layers[i].getFullExtent().getMaxY());
487
                }
488
                
489
                result = new GridExtent(minX,minY,maxX,maxY,cellSize);
490
                return result;
491
        }
492
        
493
        /**
494
         * Escritura del resultado en disco y carga en la vista 
495
         */
496
        public void createLayer(){
497
                try{
498
                        // Escritura de los datos a fichero temporal
499
                        int endIndex = fileName.lastIndexOf(".");
500
                        if (endIndex < 0)
501
                                 endIndex = fileName.length();
502
                        GeoRasterWriter grw = null;
503
                        writerBufferServer = new WriterBufferServer(mosaicGrid.getRasterBuf());
504
                        AffineTransform aTransform = new AffineTransform(fullExtend.getCellSize(),0.0,0.0,-fullExtend.getCellSize(),fullExtend.getMin().getX(),fullExtend.getMax().getY());
505
                        grw = GeoRasterWriter.getWriter(writerBufferServer, fileName, mosaicGrid.getBandCount(),aTransform, mosaicGrid.getRasterBuf().getWidth(), mosaicGrid.getRasterBuf().getHeight(), mosaicGrid.getRasterBuf().getDataType(), GeoRasterWriter.getWriter(fileName).getParams(), inputRasterLayers[0].getProjection());
506
                        grw.dataWrite();
507
                        grw.setWkt((String)((FLyrRasterSE)inputRasterLayers[0]).getWktProjection());
508
                        grw.writeClose();
509
                        mosaicGrid.getRasterBuf().free();
510
                        outputRasterLayer = FLyrRasterSE.createLayer(fileName.substring(fileName.lastIndexOf(File.separator) + 1, endIndex),
511
                                        fileName, null);
512
        
513
                } catch (NotSupportedExtensionException e) {
514
                        RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_writer_notsupportedextension"), this, e);
515
                } catch (IOException e) {
516
                        RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_writer"), this, e);
517
                } catch (InterruptedException e) {
518
                                Thread.currentThread().interrupt();
519
                } catch (RasterDriverException e) {
520
                        RasterToolsUtil.messageBoxError(PluginServices.getText(this, "raster_buffer_invalid_extension"), this, e);
521
                } catch (LoadLayerException e) {
522
                        RasterToolsUtil.messageBoxError("error_cargar_capa", this, e);
523
                }
524

    
525
        }
526
        
527
        public Object getResult() {
528
                return outputRasterLayer;
529
        }
530

    
531

    
532
        /**
533
         * @return descripcion
534
         * */
535
        public String getTitle() {
536
                return PluginServices.getText(this,"mosaic_process");
537
        }
538

    
539
        
540
        /**
541
         *  @return String con el log en cada parte del proceso
542
         * */
543
        public String getLog()
544
        {
545
                if(proceso==0)
546
                        return PluginServices.getText(this,"load_buffer_data");
547
                else if (proceso==1)
548
                        return PluginServices.getText(this,"generate_mosaic");
549
                else
550
                        return PluginServices.getText(this,"write_to_file");
551
        }
552
        
553
        /**
554
         * @return  indicador de progreso
555
         * */
556
        public int getPercent() {
557
                if(writerBufferServer==null)
558
                        return percent;
559
                else 
560
                        return writerBufferServer.getPercent();
561
        }
562

    
563

    
564
        /*
565
        // Identificaci?n de zonas de solapamiento
566
        public boolean getSolapes(FLyrRasterSE raster1, FLyrRasterSE raster2){
567
                
568
                Grid grid1=null, grid2=null, aux=null;;
569
                IRasterDataSource dsetCopy = null; 
570
                dsetCopy =raster1.getDataSource().newDataset();
571
                BufferFactory bufferFactory = new BufferFactory(dsetCopy);
572
                
573
                IRasterDataSource dsetCopy2 = null; 
574
                dsetCopy2 =raster2.getDataSource().newDataset();
575
                BufferFactory bufferFactory2 = new BufferFactory(dsetCopy2);
576
                
577
                
578
                if (!RasterBuffer.loadInMemory(dsetCopy))
579
                        bufferFactory.setReadOnly(true);        
580
                
581
                try {
582
                        grid1 = new Grid(bufferFactory,raster1.getRenderBands());
583
                        grid2= new Grid(bufferFactory2,raster2.getRenderBands());
584
                } catch (RasterBufferInvalidException e) {
585
                        e.printStackTrace();
586
                }        
587
                
588
                // En grid1 la imagen con la cordenada x menor.
589
                if(grid2.getGridExtent().getMin().getX()< grid1.getGridExtent().getMin().getX())
590
                        {
591
                                try {
592
                                        grid1 = new Grid(bufferFactory2,raster2.getRenderBands());
593
                                        grid2= new Grid(bufferFactory,raster1.getRenderBands());
594
                                } catch (RasterBufferInvalidException e) {
595
                                        e.printStackTrace();
596
                                }        
597
                                
598
                        }
599
                
600
                double xmin= grid1.getGridExtent().getMin().getX();
601
                double xmax= grid1.getGridExtent().getMax().getX();
602
                double ymin= grid1.getGridExtent().getMin().getY();
603
                double ymax= grid1.getGridExtent().getMax().getY();
604
                
605
                double xmin2= grid2.getGridExtent().getMin().getX();
606
                double ymin2= grid2.getGridExtent().getMin().getY();
607
                
608
                if(!(xmin2>xmin && xmin2<xmax)){
609
                        System.out.print("Las imagenes no se solapan en las X");
610
                        return false;
611
                }
612
        
613
                if(!(ymin2>ymin && ymin2<ymax)){
614
                        System.out.print("Las imagenes no se solapan en las Y");
615
                        return false;
616
                }
617
                
618
                // Detectado el solapamiento
619
                System.out.print("Rango x["+ xmin2 + ","+ Math.min(xmax,grid2.getGridExtent().getMax().getX())+"].");
620
                System.out.print("Rango y["+ ymin2 + ","+ Math.min(ymax,grid2.getGridExtent().getMax().getY())+"].");
621
                
622
                return true;
623
        }*/
624

    
625

    
626
}