Revision 22548

View differences:

trunk/extensions/extRemoteSensing/src-test/org/gvsig/remotesensing/featherprocess/FeatherProcessTest.java
5 5
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
6 6
import org.gvsig.raster.BaseTest;
7 7
import org.gvsig.raster.Configuration;
8
import org.gvsig.raster.RasterLibrary;
8 9
import org.gvsig.remotesensing.mosaic.process.FeatherProcess;
9 10

  
10 11
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException;
11 12

  
12 13
public class FeatherProcessTest extends BaseTest {
13 14
	
15
	private String baseDir = "./test-images/";
16
	
17
	static{
18
		RasterLibrary.wakeUp();
19
	}
20
	
14 21
	protected void setUp(){
15 22
	}
16 23
	
......
22 29
	public void testStack() {
23 30
		try {
24 31
			FLyrRasterSE.setConfiguration(Configuration.getSingleton());
25
			//FLyrRasterSE lyr1 = FLyrRasterSE.createLayer("m1", baseDir + "mosaic_test1.tif", null);
26
			//FLyrRasterSE lyr2 = FLyrRasterSE.createLayer("m1", baseDir + "mosaic_test1.tif", null);
27
			//FLyrRasterSE lyr1 = FLyrRasterSE.createLayer("m2", "test-images/mosaic_test2.tif", null);
28
			//FLyrRasterSE lyr2 = FLyrRasterSE.createLayer("m1", "test-images/mosaic_test1.tif", null);
29
			FLyrRasterSE lyr1 = FLyrRasterSE.createLayer("m1", "/home/dguerrero/datos/Raster/mosaico/Cn_ccolor_l5_20033_20070624/cn_ccolor_i5_20033_20070624_subset.img", null);
30
			FLyrRasterSE lyr2 = FLyrRasterSE.createLayer("m2", "/home/dguerrero/datos/Raster/mosaico/Cn_ccolor_l5_19933_20070703/cn_ccolor_i5_19933_20070703_subset.img", null);
32
			FLyrRasterSE lyr1 = FLyrRasterSE.createLayer("m1", baseDir + "mosaic_test1.tif", null);
33
			FLyrRasterSE lyr2 = FLyrRasterSE.createLayer("m2", baseDir + "mosaic_test2.tif", null);
34
			//FLyrRasterSE lyr1 = FLyrRasterSE.createLayer("m1", "/home/dguerrero/datos/Raster/mosaico/Cn_ccolor_l5_20033_20070624/cn_ccolor_i5_20033_20070624_subset.img", null);
35
			//FLyrRasterSE lyr2 = FLyrRasterSE.createLayer("m2", "/home/dguerrero/datos/Raster/mosaico/Cn_ccolor_l5_19933_20070703/cn_ccolor_i5_19933_20070703_subset.img", null);
31 36
			FLyrRasterSE[] layers = new FLyrRasterSE[2]; 
32 37
			layers[0]=lyr1;
33 38
			layers[1]=lyr2;
trunk/extensions/extRemoteSensing/src-test/org/gvsig/remotesensing/featherprocess/FeatherProcessBuffTest.java
5 5
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
6 6
import org.gvsig.raster.BaseTest;
7 7
import org.gvsig.raster.Configuration;
8
import org.gvsig.raster.RasterLibrary;
8 9
import org.gvsig.remotesensing.mosaic.process.FeatherProcessBuff;
9 10

  
10 11
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException;
11 12

  
12 13
public class FeatherProcessBuffTest extends BaseTest {
13 14
	
15
	private String baseDir = "./test-images/";
16
	
17
	static{
18
		RasterLibrary.wakeUp();
19
	}
20
	
14 21
	protected void setUp(){
15 22
	}
16 23
	
......
23 30
		try {
24 31
			FLyrRasterSE.setConfiguration(Configuration.getSingleton());
25 32
			//FLyrRasterSE lyr1 = FLyrRasterSE.createLayer("m1", baseDir + "mosaic_test1.tif", null);
26
			//FLyrRasterSE lyr2 = FLyrRasterSE.createLayer("m1", baseDir + "mosaic_test1.tif", null);
27
			FLyrRasterSE lyr1 = FLyrRasterSE.createLayer("m1", "test-images/mosaic_test1.tif", null);
28
			FLyrRasterSE lyr2 = FLyrRasterSE.createLayer("m2", "test-images/mosaic_test2.tif", null);
29
			//FLyrRasterSE lyr1 = FLyrRasterSE.createLayer("m1", "/home/dguerrero/datos/Raster/mosaico/Cn_ccolor_l5_20033_20070624/cn_ccolor_i5_20033_20070624_subset.img", null);
30
			//FLyrRasterSE lyr2 = FLyrRasterSE.createLayer("m2", "/home/dguerrero/datos/Raster/mosaico/Cn_ccolor_l5_19933_20070703/cn_ccolor_i5_19933_20070703_subset.img", null);
33
			//FLyrRasterSE lyr2 = FLyrRasterSE.createLayer("m2", baseDir + "mosaic_test2.tif", null);
34
			FLyrRasterSE lyr1 = FLyrRasterSE.createLayer("m1", "/home/dguerrero/datos/Raster/mosaico/Cn_ccolor_l5_20033_20070624/cn_ccolor_i5_20033_20070624_subset.img", null);
35
			FLyrRasterSE lyr2 = FLyrRasterSE.createLayer("m2", "/home/dguerrero/datos/Raster/mosaico/Cn_ccolor_l5_19933_20070703/cn_ccolor_i5_19933_20070703_subset.img", null);
31 36
			FLyrRasterSE[] layers = new FLyrRasterSE[2]; 
32 37
			layers[0]=lyr1;
33 38
			layers[1]=lyr2;
trunk/extensions/extRemoteSensing/config/text.properties
110 110
pc = Componentes principales
111 111
perfiles_imagen = Perfiles de la imagen
112 112
pixeles=Pixeles
113
preparando_entrada=Preparando datos de entrada
113 114
principal_components_tooltip
114 115
principal_component = Componentes Principales
115 116
procesando= Procesando
......
118 119
principal_components_calculus=C?lculo imagen
119 120
remote_sensing=Teledetecci?n
120 121
rois= Rois
121
regiones_interes_chart= Regiones inter?s en gr?fico
122 122
rangox=Rango x:
123 123
rangoy=Rango y:
124
realizando_degradado=Realizado Degradado
125
regiones_interes_chart=Regiones inter?s en gr?fico
124 126
salida= Salida
125 127
seleccion_banda= Selecci?n Bandas
126 128
seleccion_metodo= Selecci?n M?todo
trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/mosaic/process/FeatherProcessBuff.java
49 49
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
50 50
import org.gvsig.raster.RasterProcess;
51 51
import org.gvsig.raster.buffer.BufferFactory;
52
import org.gvsig.raster.buffer.RasterBuffer;
53 52
import org.gvsig.raster.buffer.RasterBufferInvalidException;
54 53
import org.gvsig.raster.buffer.WriterBufferServer;
55 54
import org.gvsig.raster.dataset.GeoRasterWriter;
......
78 77

  
79 78
	private FLyrRasterSE inputRasterLayers[] = null;
80 79
	private IBuffer inputBuffers[] = null;
81
	private int xResolution, yResolution = 0;
82 80

  
83 81
	private FLyrRasterSE outputRasterLayer = null;
84 82

  
......
89 87

  
90 88
	private Grid resultGrid = null;
91 89
	private GridExtent resultGridExtent = null;
90
	private int resultPxWidth, resultPxHeight= 0;
92 91
	private int resultbandCount = 0;
93 92

  
94 93
	private WriterBufferServer writerBufferServer = null;
......
100 99
	private byte values[] = null;
101 100
	private double totalD = 0;
102 101
	private double result[] = null;
102
	
103
	private GeoRasterWriter grw;
103 104

  
104 105
	public void init() {
105 106

  
107
		insertLineLog(PluginServices.getText(this, "preparando_entrada")+"...");
106 108
		// Obtener las capas que intervienen en el mosaico.
107 109
		inputRasterLayers = (FLyrRasterSE[]) getParam("inputRasterLayers");
108 110

  
......
124 126

  
125 127
		resultGridExtent = new GridExtent(new Extent(resultExtent), cellSizeX,
126 128
				cellSizeY);
127
		xResolution = resultGridExtent.getNX();
128
		yResolution = resultGridExtent.getNY();
129
		
130
		resultPxWidth = resultGridExtent.getNX();
131
		resultPxHeight = resultGridExtent.getNY();
129 132

  
130 133
		// Grid Resultante
131 134
		try {
......
144 147
	}
145 148

  
146 149
	public void process() throws InterruptedException {
147
		// Calculara las lineas de borde (entre 0, 3 o 4 lineas)
150
		// Calcular las lineas de borde (entre 0, 3 o 4 lineas)
148 151
		calculateBorders();
149 152
		distances = new double[borders.length];
150 153

  
......
161 164
			bufferFactory.setDrawableBands(drawableBands);
162 165

  
163 166
			try {
164
				/*if (RasterBuffer.isBufferTooBig(new double[] {
165
						resultGridExtent.getMin().getX(),
166
						resultGridExtent.getMin().getY(),
167
						resultGridExtent.getMax().getX(),
168
						resultGridExtent.getMax().getY() },
169
						drawableBands.length))*/
170 167
					bufferFactory.setReadOnly(true);
171 168

  
172 169
				bufferFactory.setAreaOfInterest(resultGridExtent.getMin().getX(), resultGridExtent.getMax().getY(), 
173 170
						resultGridExtent.getMax().getX(), resultGridExtent.getMin().getY(), resultGridExtent.getNX(),resultGridExtent.getNY());
174 171
				
175
				/*bufferFactory.setAreaOfInterest(inputExtents[l].getMinX(), inputExtents[l].getMaxY(), 
176
						inputExtents[l].getMaxX(), inputExtents[l].getMinY(),resultGridExtent.getNX(),resultGridExtent.getNY());
177
						*/
178
				
179
				/*
180
				bufferFactory.setAreaOfInterest(inputExtents[l].getMinX(), inputExtents[l].getMaxY(), 
181
						inputExtents[l].getMaxX()- inputExtents[l].getMinX(), inputExtents[l].getMaxY() - inputExtents[l].getMinY());
182
						*/
183 172
			} catch (InvalidSetViewException e) {
184 173
				// TODO Auto-generated catch block
185 174
				e.printStackTrace();
......
188 177
				e.printStackTrace();
189 178
			}
190 179
			inputBuffers[l] = bufferFactory.getRasterBuf();
191

  
192
			insertLineLog(RasterToolsUtil.getText(this, "interpolando"));
193

  
194
			/*inputBuffers[l] = ((RasterBuffer) inputBuffers[l])
195
					.getAdjustedWindow(xResolution, yResolution,
196
							GridInterpolated.INTERPOLATION_NearestNeighbour);*/
197
			
198 180
		}
199 181

  
200 182
		// Recorrido del grid resultante
201
		// for (int band = 0; band < resultGrid.getBandCount(); band++){
202
		// resultGrid.setBandToOperate(band);
203
		for (int col = 0; col < resultGrid.getNX(); col++) {
204
			// percent =
205
			// col*resultGrid.getBandCount()*100/resultGrid.getNX()*resultGrid.getBandCount();
206
			for (int row = 0; row < resultGrid.getNY(); row++) {
183
		insertLineLog(PluginServices.getText(this, "realizando_degradado")+"...");
184
		for (int col = 0; col < resultPxWidth; col++) {
185
			percent = col*100/resultPxWidth; 
186
			for (int row = 0; row < resultPxHeight; row++) {
207 187
				try {
208 188
					setValue(col, row);
209
					// resultGrid.setCellValue(col, row, getValue(col, row,
210
					// band));
211 189
				} catch (OutOfGridException e) {
212 190
					RasterToolsUtil.messageBoxError(PluginServices.getText(
213 191
							this, "bad_access_grid"), this, e);
214 192
				}
215 193
			}
216 194
		}
217
		// }
195
		
196
		// Se liberan los buffers
197
		for(int i=0; i<inputRasterLayers.length;i++)
198
			inputBuffers[i].free();
199
		
218 200
		createLayer();
219 201
		if (externalActions != null)
220 202
			externalActions.end(outputRasterLayer);
221 203
	}
222 204

  
223 205
	private void createLayer() {
206
		insertLineLog(PluginServices.getText(this, "escribiendo_resultado")+"...");
207
		
224 208
		writerBufferServer = new WriterBufferServer(resultGrid.getRasterBuf());
225 209
		AffineTransform aTransform = new AffineTransform(resultGridExtent
226 210
				.getCellSizeX(), 0.0, 0.0, resultGridExtent.getCellSizeY(),
227 211
				resultGridExtent.getMin().getX(), resultGridExtent.getMax()
228 212
						.getY());
229
		GeoRasterWriter grw;
230 213
		try {
231 214
			grw = GeoRasterWriter.getWriter(writerBufferServer, fileName,
232 215
					resultGrid.getBandCount(), aTransform, resultGridExtent
......
235 218
							.getParams(), null);
236 219
			grw.dataWrite();
237 220
			grw.writeClose();
238

  
221
			resultGrid.getRasterBuf().free();
239 222
			outputRasterLayer = FLyrRasterSE.createLayer("outputLayer",
240 223
					fileName, null);
241 224
			
......
243 226
			/*
244 227
			 * DEBUG: Escritura de los buffers interpolados de las im?genes de entrada 
245 228
			 */
246
			
229
			/*
247 230
			for(int i=0; i<inputBuffers.length; i++){
248 231
				writerBufferServer = new WriterBufferServer(inputBuffers[i]);
249 232
				aTransform = new AffineTransform(resultGridExtent
......
345 328
	}
346 329

  
347 330
	public int getPercent() {
348
		// TODO Auto-generated method stub
349
		return 0;
331
		if (grw != null)
332
			return grw.getPercent();
333
		
334
		return percent;
350 335
	}
351 336

  
352 337
	public String getTitle() {
trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/mosaic/process/HistogramMatchProcess.java
49 49
import org.gvsig.raster.buffer.RasterBuffer;
50 50
import org.gvsig.raster.buffer.WriterBufferServer;
51 51
import org.gvsig.raster.dataset.GeoRasterWriter;
52
import org.gvsig.raster.dataset.IBuffer;
52 53
import org.gvsig.raster.dataset.IRasterDataSource;
53 54
import org.gvsig.raster.dataset.NotSupportedExtensionException;
54 55
import org.gvsig.raster.dataset.io.RasterDriverException;
......
75 76
 * */
76 77
public class HistogramMatchProcess  extends RasterProcess{
77 78

  
78
	FLyrRasterSE layers[]= null;
79
	FLyrRasterSE inputRasterLayers[]= null;
80
	FLyrRasterSE outputRassterLayers[] = null;
79 81
	Histogram histogramMaster= null;
80 82
	View view= null;
81 83
	int progreso=0;
......
84 86
	int countInProcess=0,totalcount=0;
85 87
	int numbands = 0;
86 88
	RasterFilter filtro= new HistogramMatchingByteFilter();
87
	RasterBuffer rasterResult=null;
89
	IBuffer rasterResult=null;
88 90
	WriterBufferServer writerBufferServer=null;
89 91
	boolean optionLoad= false;
90 92
	
......
96 98
	 * */
97 99
	
98 100
	public void init() {
99
		layers =(FLyrRasterSE []) getParam("layers");
101
		inputRasterLayers =(FLyrRasterSE []) getParam("layers");
102
		outputRassterLayers = new FLyrRasterSE[inputRasterLayers.length];
100 103
		histogramMaster= (Histogram) getParam("histogramMaster");
101 104
		numbands = ((Integer)getParam("numbands")).intValue();
102 105
		view= (View)getParam("view");
......
115 118
		try{
116 119
			int k=0;
117 120
			String path= null;
118
			totalcount= layers.length-1;
119
			for (int i=0; i< layers.length;i++){
121
			totalcount= inputRasterLayers.length-1;
122
			for (int i=0; i< inputRasterLayers.length;i++){
120 123
				path = Utilities.createTempDirectory() + File.separator + "hist"+i+ ".tif";
121 124
				// Para el resto de los histogramas seleccionados
122
				if(layers[i]!=null){
125
				if(inputRasterLayers[i]!=null){
123 126
					k++;
124
					layerInProcess= layers[i].getName();
127
					layerInProcess= inputRasterLayers[i].getName();
125 128
					IRasterDataSource dsetCopy = null; 
126
					dsetCopy = layers[i].getDataSource().newDataset();
129
					dsetCopy = inputRasterLayers[i].getDataSource().newDataset();
127 130
					BufferFactory bufferFactory = new BufferFactory(dsetCopy);
128 131
					if (!RasterBuffer.loadInMemory(dsetCopy))
129 132
						bufferFactory.setReadOnly(true);			
......
135 138
					filtro.execute();
136 139
					rasterResult=(RasterBuffer) filtro.getResult("raster");
137 140
					if(optionLoad)
138
						writeToFile(rasterResult,path,i);	
141
						outputRassterLayers[i] = createLayers(path,i);	
139 142
					}
140 143
			} 
141 144
	
142 145
		}catch (Exception e2) {		
143 146
			RasterToolsUtil.messageBoxError(PluginServices.getText(this, "filter_error"), this, e2);		
144
		}	
147
		}
148
		finally{
149
			externalActions.end(outputRassterLayers);
150
		}
151
		
145 152
	}
146 153
	
147 154
	
......
164 171
	}
165 172
	
166 173
	
167
	public void writeToFile(RasterBuffer rb, String path,int i){
174
	public FLyrRasterSE createLayers(String path,int i){
168 175

  
176
		FLyrRasterSE lyr = null;  
169 177
		try{
170 178
			if(path==null)
171
				return;
179
				return null;
172 180
			GeoRasterWriter grw = null;
173 181
			writerBufferServer = new WriterBufferServer(rasterResult);
174
			grw = GeoRasterWriter.getWriter(writerBufferServer, path, rasterResult.getBandCount(),layers[i].getAffineTransform(), rasterResult.getWidth(), rasterResult.getHeight(), rasterResult.getDataType(), GeoRasterWriter.getWriter(path).getParams(), null);
182
			grw = GeoRasterWriter.getWriter(writerBufferServer, path, rasterResult.getBandCount(),inputRasterLayers[i].getAffineTransform(), rasterResult.getWidth(), rasterResult.getHeight(), rasterResult.getDataType(), GeoRasterWriter.getWriter(path).getParams(), null);
175 183
			
176 184
			grw.dataWrite();
177
			grw.setWkt(layers[i].getWktProjection());
185
			grw.setWkt(inputRasterLayers[i].getWktProjection());
178 186
			grw.writeClose();
179 187
			rasterResult.free();
180 188
			
181 189
			int endIndex = path.lastIndexOf(".");
182 190
			if (endIndex < 0)
183 191
				endIndex = path.length();
184
			FLyrRasterSE lyr = FLyrRasterSE.createLayer(
192
			lyr = FLyrRasterSE.createLayer(
185 193
					path.substring(path.lastIndexOf(File.separator) + 1, endIndex),
186 194
					path,
187 195
					view.getMapControl().getProjection()
188 196
					);
189
			
190
			view.getMapControl().getMapContext().getLayers().addLayer(lyr);
197
			//Eliminar:
198
			/*view.getMapControl().getMapContext().getLayers().addLayer(lyr);
191 199
			view.getMapControl().getMapContext().endAtomicEvent();
192
			view.getMapControl().getMapContext().invalidate();
200
			view.getMapControl().getMapContext().invalidate();*/
193 201
			
194 202
		} catch (NotSupportedExtensionException e) {
195 203
			RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_writer_notsupportedextension"), this, e);		
......
202 210
		} catch (LoadLayerException e) {
203 211
			RasterToolsUtil.messageBoxError("error_cargar_capa", this, e);
204 212
		}
205
			
213
		return lyr;		
206 214
	}
207 215

  
216

  
217
	public Object getResult() {
218
		return outputRassterLayers;
219
	}
220

  
208 221
}
trunk/extensions/extRemoteSensing/src/org/gvsig/remotesensing/mosaic/process/MosaicProcess.java
58 58
import org.gvsig.raster.grid.Grid;
59 59
import org.gvsig.raster.grid.GridExtent;
60 60
import org.gvsig.raster.grid.OutOfGridException;
61
import org.gvsig.raster.util.RasterNotLoadException;
62 61
import org.gvsig.raster.util.RasterToolsUtil;
63 62

  
64 63
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
65 64
import com.iver.andami.PluginServices;
66 65
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
66
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException;
67 67
import com.iver.cit.gvsig.fmap.layers.FLayers;
68 68
import com.iver.cit.gvsig.project.documents.view.gui.View;
69 69

  
......
77 77
public class MosaicProcess extends RasterProcess {
78 78

  
79 79
	// Layers que intervienen en el proceso
80
	private FLayers layers = null;
80
	private FLyrRasterSE inputRasterLayers[] = null;
81
	
82
	//Layer de salida
83
	private FLyrRasterSE outputRasterLayer = null;
81 84

  
82 85
	// Extend completo del mosaico
83 86
	private GridExtent fullExtend= null;
......
115 118
	 * */
116 119
	public void init() {
117 120
		
118
		layers= (FLayers)getParam("layers");
121
		inputRasterLayers= (FLyrRasterSE[])getParam("layers");
119 122
		codOp= getIntParam("codOp");
120 123
		numbands= getIntParam("numbands");
121 124
		fileName = getStringParam("filename");
122 125
		
123 126
		view = (View)getParam("vista");	
124 127
// 		Calculo del extend resultante
125
		fullExtend= calculateExtend(layers);
128
		fullExtend= calculateExtend(inputRasterLayers);
126 129
		
127 130
		int bands[]= new int[numbands];
128 131
		for(int i=0; i<numbands;i++)
......
141 144
	public void process() throws InterruptedException {
142 145
		
143 146
		// Parte de carga de los datos
144
		buffers= new RasterBuffer[layers.getLayersCount()];
147
		buffers= new RasterBuffer[inputRasterLayers.length];
145 148
		IRasterDataSource dsetCopy = null; 
146 149
		try {
147 150
		
......
151 154
			double maxY=  fullExtend.getMax().getY();
152 155
			// Se cargan todos los raster en los grid correspondientes
153 156
			percent=1;
154
			for(int i=0; i< layers.getLayersCount();i++)
157
			for(int i=0; i< inputRasterLayers.length;i++)
155 158
			{	
156
				dsetCopy = ((FLyrRasterSE)layers.getLayer(i)).getDataSource().newDataset();
159
				dsetCopy = ((FLyrRasterSE)inputRasterLayers[i]).getDataSource().newDataset();
157 160
				BufferFactory bufferFactory = new BufferFactory(dsetCopy);
158 161
				bufferFactory.setAdjustToExtent(false);
159 162
				if (!RasterBuffer.loadInMemory(dsetCopy))
......
162 165
				bufferFactory.setAllDrawableBands();
163 166
				bufferFactory.setAreaOfInterest(minX,minY,maxX,maxY,fullExtend.getNX(),fullExtend.getNY());
164 167
				buffers[i]= (RasterBuffer) bufferFactory.getRasterBuf();
165
				percent=(int)((i+1)*100/layers.getLayersCount());
168
				percent=(int)((i+1)*100/inputRasterLayers.length);
166 169

  
167 170
			
168 171
			}
......
263 266
		}
264 267
		
265 268
		// Se liberan los buffers
266
		for(int i=0; i<layers.getLayersCount();i++)
269
		for(int i=0; i<inputRasterLayers.length;i++)
267 270
			buffers[i].free();
268 271
		
269 272
		// Escritura en fichero
270 273
		proceso=2;
271
		writeToFile();
272

  
274
		createLayer();
275
		if (externalActions != null)
276
			externalActions.end(outputRasterLayer);
273 277
	}
274 278

  
275 279
	
......
410 414
	 * @return GridExtend del mosaico
411 415
	 * */
412 416
	
413
	private GridExtent calculateExtend (FLayers layers){
417
	private GridExtent calculateExtend (FLyrRasterSE layers[]){
414 418
		
415 419
		GridExtent result= null;
416 420
		IRasterDataSource dsetCopy = null; 
417 421
		double cellSize=0;
418 422
		double minX=0,maxX=0,minY=0,maxY=0;
419
		try {
423
		// Se obtiene el tama?o de celda mayor
424
		for(int i=0; i< layers.length;i++)
425
		{	
426
			dsetCopy = ((FLyrRasterSE)layers[i]).getDataSource().newDataset();
427
			BufferFactory bufferFactory = new BufferFactory(dsetCopy);
428
			bufferFactory.setAdjustToExtent(false);
429
			cellSize= Math.max(cellSize,bufferFactory.getDataSource().getCellSize());
430
		}
420 431
		
421
			// Se obtiene el tama?o de celda mayor
422
			for(int i=0; i< layers.getLayersCount();i++)
423
			{	
424
				dsetCopy = ((FLyrRasterSE)layers.getLayer(i)).getDataSource().newDataset();
425
				BufferFactory bufferFactory = new BufferFactory(dsetCopy);
426
				bufferFactory.setAdjustToExtent(false);
427
				cellSize= Math.max(cellSize,bufferFactory.getDataSource().getCellSize());
428
			}
432
		minX = layers[0].getFullExtent().getMinX();
433
		minY = layers[0].getFullExtent().getMinY();
434
		maxX = layers[0].getFullExtent().getMaxX();
435
		maxY = layers[0].getFullExtent().getMaxY();
436
		
437
		for(int i=1; i<layers.length;i++){
429 438
			
430
			minX = layers.getLayer(0).getFullExtent().getMinX();
431
			minY = layers.getLayer(0).getFullExtent().getMinY();
432
			maxX = layers.getLayer(0).getFullExtent().getMaxX();
433
			maxY = layers.getLayer(0).getFullExtent().getMaxY();
434
			
435
			for(int i=1; i<layers.getLayersCount();i++){
436
				
437
				minX= Math.min(minX,layers.getLayer(i).getFullExtent().getMinX());
438
				minY= Math.min(minY,layers.getLayer(i).getFullExtent().getMinY());
439
				maxX= Math.max(maxX,layers.getLayer(i).getFullExtent().getMaxX());
440
				maxY= Math.max(maxY,layers.getLayer(i).getFullExtent().getMaxY());
441
			}
442
			
443
		} catch (ExpansionFileReadException e) {
444
			e.printStackTrace();
445
		} catch (ReadDriverException e) {
446
			e.printStackTrace();
439
			minX= Math.min(minX,layers[i].getFullExtent().getMinX());
440
			minY= Math.min(minY,layers[i].getFullExtent().getMinY());
441
			maxX= Math.max(maxX,layers[i].getFullExtent().getMaxX());
442
			maxY= Math.max(maxY,layers[i].getFullExtent().getMaxY());
447 443
		}
448 444
		
449 445
		result = new GridExtent(minX,minY,maxX,maxY,cellSize);
......
453 449
	/**
454 450
	 * Escritura del resultado en disco y carga en la vista 
455 451
	 */
456
	public void writeToFile(){
452
	public void createLayer(){
457 453
		try{
458 454
			// Escritura de los datos a fichero temporal
459 455
			int endIndex = fileName.lastIndexOf(".");
......
464 460
			AffineTransform aTransform = new AffineTransform(fullExtend.getCellSize(),0.0,0.0,-fullExtend.getCellSize(),fullExtend.getMin().getX(),fullExtend.getMax().getY());
465 461
			grw = GeoRasterWriter.getWriter(writerBufferServer, fileName, mosaicGrid.getBandCount(),aTransform, mosaicGrid.getRasterBuf().getWidth(), mosaicGrid.getRasterBuf().getHeight(), mosaicGrid.getRasterBuf().getDataType(), GeoRasterWriter.getWriter(fileName).getParams(), null);
466 462
			grw.dataWrite();
467
			grw.setWkt((String)((FLyrRasterSE)layers.getLayer(0)).getWktProjection());
463
			grw.setWkt((String)((FLyrRasterSE)inputRasterLayers[0]).getWktProjection());
468 464
			grw.writeClose();
469 465
			mosaicGrid.getRasterBuf().free();
470
			RasterToolsUtil.loadLayer(PluginServices.getMDIManager().getWindowInfo(view).getTitle(), fileName, null);
466
			outputRasterLayer = FLyrRasterSE.createLayer("outputLayer",
467
					fileName, null);
468
			
469
			//Borrar sin preguntar:
470
			//RasterToolsUtil.loadLayer(PluginServices.getMDIManager().getWindowInfo(view).getTitle(), fileName, null);
471 471
	
472 472
		} catch (NotSupportedExtensionException e) {
473 473
			RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_writer_notsupportedextension"), this, e);
......
475 475
			RasterToolsUtil.messageBoxError(PluginServices.getText(this, "error_writer"), this, e);
476 476
		} catch (InterruptedException e) {
477 477
				Thread.currentThread().interrupt();
478
		} catch (RasterNotLoadException e) {
479
				RasterToolsUtil.messageBoxError("error_cargar_capa", this, e);
480 478
		} catch (RasterDriverException e) {
481 479
			RasterToolsUtil.messageBoxError(PluginServices.getText(this, "raster_buffer_invalid_extension"), this, e);
480
		} catch (LoadLayerException e) {
481
			RasterToolsUtil.messageBoxError("error_cargar_capa", this, e);
482 482
		}
483 483

  
484 484
	}
485 485
	
486
	public Object getResult() {
487
		return outputRasterLayer;
488
	}
489

  
490

  
486 491
	/**
487 492
	 * @return descripcion
488 493
	 * */

Also available in: Unified diff