Revision 8281

View differences:

trunk/libraries/libCq CMS for java.old/.project
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<projectDescription>
3
	<name>Cq CMS for Java</name>
3
	<name>libCq CMS for java</name>
4 4
	<comment></comment>
5 5
	<projects>
6 6
		<project>CIT MapView</project>
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/GdalFile.java
30 30
import java.awt.image.BufferedImage;
31 31
import java.awt.image.DataBuffer;
32 32
import java.io.IOException;
33
import java.util.Date;
33 34
import java.util.Vector;
34 35

  
35 36
import org.cresques.cts.ICoordTrans;
......
65 66
	/**
66 67
	 * Contorno en coordenadas geogr?ficas. (y Extent del raster).
67 68
	 */
68
	public Contour 				esq = new Contour();
69
	public Contour 				bBoxRot = new Contour();
70
	/**
71
	 * Contorno en coordenadas geogr?ficas sin rotaci?n aplicada. Esto es util para poder
72
	 * calcular los pixeles necesarios que se van a leer del raster. Cuando el raster no tiene 
73
	 * rotaci?n coincide con esq. 
74
	 */
75
	public Contour				bBoxWithoutRot = new Contour();
69 76
	public int 					width = 0, height = 0;
70 77
	public double 				originX = 0D, originY = 0D;
71 78
	public String 				version = "";
......
101 108
		init(fName);
102 109
	}
103 110
	
111
	/**
112
	 * <P>
113
	 * Calcula la bounding box en la que est? metido el raster teniendo en cuenta
114
	 * el tama?o de pixel y la rotaci?n. Esto lo hace con los valores de transformaci?n 
115
	 * leidos por gdal en el vector de 6 elementos adfGeoTransform donde cada elemento
116
	 * del vector represnta los siguientes valores
117
	 * </P>
118
	 * <UL>
119
	 * <LI>0-origen X</LI>
120
	 * <LI>1-tama?o de pixel X</LI>
121
	 * <LI>2-shear en X</LI>
122
	 * <LI>3-origen Y</LI>
123
	 * <LI>4-shear en Y</LI>
124
	 * <LI>5-Tama?o de pixel Y</LI>
125
	 * </UL>
126
	 * <P>
127
	 * Para el calculo de una esquina aplicamos la formula siguiente:<BR>
128
	 * PtoX = originX + pixelSizeX * x + shearX * y;<BR>
129
	 * PtoY = originY + shearY * x + pixelSizeY * y;<BR>
130
	 * Aplicandolo a las cuatro esquinas sustituimos en cada una de ellas por.
131
	 * </P>
132
	 * <UL> 
133
	 * <LI>Esquina superior izquierda: x = 0; y = 0;</LI>
134
	 * <LI>Esquina superior derecha: x = MaxX; y = 0;</LI>
135
	 * <LI>Esquina inferior izquierda: x = 0; y = MaxY;</LI>
136
	 * <LI>Esquina inferior derecha: x = MaxX; y = MaxY;</LI>
137
	 * </UL> 
138
	 * <P>
139
	 * quedandonos en los cuatro casos:
140
	 * </P>
141
	 * <UL> 
142
	 * <LI>Esquina superior izquierda: originX; originY;</LI>
143
	 * <LI>Esquina superior derecha: PtoX = originX + pixelSizeX * x; PtoY = originY + shearY * x;</LI>
144
	 * <LI>Esquina inferior izquierda:  PtoX = originX + shearX * y; PtoY = originY + pixelSizeY * y;</LI>
145
	 * <LI>Esquina inferior derecha: PtoX = originX + pixelSizeX * x + shearX * y; PtoY = originY + shearY * x + pixelSizeY * y;</LI>
146
	 * </UL>
147
	 * 
148
	 */
149
	private void boundingBoxFromGeoTransform(){
150
		double geoX = 0D, geoY = 0D;
151

  
152
		//Upper left corner
153
		bBoxRot.add(new Point2D.Double(trans.adfgeotransform[0], trans.adfgeotransform[3]));
154

  
155
		//Lower left corner
156
		geoX = trans.adfgeotransform[0] +  trans.adfgeotransform[2] * height;
157
		geoY = trans.adfgeotransform[3] +  trans.adfgeotransform[5] * height;
158
		bBoxRot.add(new Point2D.Double(geoX, geoY));
159
		
160
		//Upper right corner
161
		geoX = trans.adfgeotransform[0] + trans.adfgeotransform[1] * width;
162
		geoY = trans.adfgeotransform[3] + trans.adfgeotransform[4] * width;
163
		bBoxRot.add(new Point2D.Double(geoX, geoY));
164
		
165
		//Lower right corner
166
		geoX = trans.adfgeotransform[0] + trans.adfgeotransform[1] * width + trans.adfgeotransform[2] * height;
167
		geoY = trans.adfgeotransform[3] + trans.adfgeotransform[4] * width + trans.adfgeotransform[5] * height;
168
		bBoxRot.add(new Point2D.Double(geoX, geoY));
169
		
170
		//TODO: ?OJO! con coordenadas geogr?ficas
171
	}
172
	
173
	/**
174
	 * Calcula la bounding box en la que est? metido el raster teniendo en cuenta
175
	 * el tama?o de pixel y la rotaci?n. 
176
	 */
177
	private void boundingBoxWithoutRotation(){
178
		double ox = trans.adfgeotransform[0];
179
		double oy = trans.adfgeotransform[3];
180
		double resx = trans.adfgeotransform[1];
181
		double resy = trans.adfgeotransform[5];
182
				
183
		bBoxWithoutRot.add(new Point2D.Double(ox, oy));
184
		bBoxWithoutRot.add(new Point2D.Double(ox + resx * width, oy));
185
		bBoxWithoutRot.add(new Point2D.Double(ox, oy + resy * height));
186
		bBoxWithoutRot.add(new Point2D.Double(ox + resx * width, oy + resy * height));
187

  
188
		//TODO: ?OJO! con coordenadas geogr?ficas
189
	}
190
	
104 191
	private void init(String fName) throws GdalException, IOException {
105 192
		open(fName,GA_ReadOnly);
106 193
		ext = fName.toLowerCase().substring(fName.lastIndexOf('.')+1);
......
134 221
		double ox=0D, oy=0D, resx=0D, resy=0D;
135 222
		try{
136 223
			trans = getGeoTransform();
137
			ox = trans.adfgeotransform[0];
138
			oy = trans.adfgeotransform[3];
139
			resx = trans.adfgeotransform[1];
140
			resy = trans.adfgeotransform[5];
141 224
			
142
			esq.add(new Point2D.Double(ox, oy));
143
			esq.add(new Point2D.Double(ox+resx*width, oy));
144
			esq.add(new Point2D.Double(ox, oy+resy*height));
225
			boundingBoxWithoutRotation();
226
			boundingBoxFromGeoTransform();
227
						
145 228
			this.georeferenced = true;
146
			esq.add(new Point2D.Double(ox+resx*width, oy+resy*height));
147 229
		}catch(GdalException exc){
148
			esq.add(new Point2D.Double(0, 0));
149
			esq.add(new Point2D.Double(width, 0));
150
			esq.add(new Point2D.Double(0, height));
151
			esq.add(new Point2D.Double(width, height));
230
			bBoxRot.add(new Point2D.Double(0, 0));
231
			bBoxRot.add(new Point2D.Double(width, 0));
232
			bBoxRot.add(new Point2D.Double(0, height));
233
			bBoxRot.add(new Point2D.Double(width, height));
234
			bBoxWithoutRot = bBoxRot;
152 235
			this.georeferenced = false;
153 236
		}
154 237
	}
......
174 257
	
175 258
	protected GdalRasterBand bandR = null, bandG = null, bandB = null, bandA = null;
176 259
	
260
	private boolean[] orientation;
261
	
177 262
	/**
178 263
	 * Devuelve la banda actualmente en uso para el color especificado.
179 264
	 * @param color 0=Rojo, 1=Green, 2=Blue.
......
186 271
			return bandG;
187 272
		return bandB;
188 273
	}
189
	// Supone rasters no girados
274
	
275
	//Supone rasters no girados
190 276
	public Point2D worldToRaster(Point2D pt) {
191
		double x = (((double) currentFullWidth)/(esq.maxX-esq.minX))*(pt.getX()-esq.minX);
192
		double y = (((double) currentFullHeight)/(esq.maxY-esq.minY))*(esq.maxY-pt.getY());
277
		double x = (((double) currentFullWidth) / (bBoxWithoutRot.maxX - bBoxWithoutRot.minX)) * (pt.getX() - bBoxWithoutRot.minX);
278
		double y = (((double) currentFullHeight) / (bBoxWithoutRot.maxY - bBoxWithoutRot.minY)) * (bBoxWithoutRot.maxY - pt.getY());
193 279
		Point2D ptRes = new Point2D.Double(x, y);
194 280
		return ptRes;
195 281
	}
196 282
	
283
	/**
284
	 * Si el tama?o de pixel en X es menor que 0 entonces la imagen se orienta al contrario en X por lo que en los zooms
285
	 * habr? que invertir la petici?n de la parte derecha a la izquierda y viceversa. Esto lo detectamos con la 
286
	 * variable orientation , si orientation[0] es false entonces el punto inicial del zoom lo invertimos de la 
287
	 * siguiente forma:
288
	 * Nuevo_punto_inicialX = (Ancho_total_raster - punto_inicial_del_zoomX) - Ancho_de_petici?n
289
	 *
290
	 * Si el tama?o de pixel en Y es mayor que 0 entonces la imagen se orienta al contrario en Y por 
291
	 * lo que en los zooms habr? que invertir la petici?n de abajo a arriba y viceversa. Esto lo detectamos con la 
292
	 * variable orientation , si orientation[1] es true entonces el punto inicial del zoom lo invertimos de la 
293
	 * siguiente forma:
294
	 * Nuevo_punto_inicialY = (Alto_total_raster - punto_inicial_del_zoomY) - Alto_de_petici?n
295
	 * 
296
	 * @param dWorldTLX
297
	 * @param dWorldTLY
298
	 * @param dWorldBRX
299
	 * @param dWorldBRY
300
	 * @param nWidth
301
	 * @param nHeight
302
	 * @param orientation array de dos elementos que representa la orientaci?n de la petici?n en
303
	 * X e Y. El primer elemento representa el signo de pixelSize en X, true si es positivo y false
304
	 * si es negativo. El segundo elemento representa el signo de pixelSize en Y
305
	 * @return
306
	 */
197 307
	public int setView(double dWorldTLX, double dWorldTLY,
198 308
            double dWorldBRX, double dWorldBRY,
199
            int nWidth, int nHeight) {
309
            int nWidth, int nHeight, boolean[] orientation) {
200 310
		int err = 0;
311
		this.orientation = orientation;
201 312
		currentFullWidth = width;
202 313
		currentFullHeight = height;
203 314
		Point2D tl = worldToRaster(new Point2D.Double(dWorldTLX, dWorldTLY));
......
207 318
		currentViewHeight = nHeight;
208 319
		wcWidth = Math.abs(br.getX() - tl.getX());
209 320
		
210
		currentViewX = tl.getX();
321
		if(!orientation[0]) //Invierte la orientaci?n en X
322
			currentViewX = (width - tl.getX()) - (br.getX()-tl.getX());
323
		else
324
			currentViewX = tl.getX();
325
		
211 326
		viewportScaleX = (double) currentViewWidth/(br.getX()-tl.getX());
212 327
		viewportScaleY = (double) currentViewHeight/(br.getY()-tl.getY());
213 328
		stepX = 1D/viewportScaleX;
214 329
		stepY = 1D/viewportScaleY;
215
		lastReadLine = tl.getY();
330

  
331
		if(orientation[1])//Invierte la orientaci?n en Y
332
			lastReadLine = (height - tl.getY()) - (br.getY()-tl.getY());
333
		else
334
			lastReadLine = tl.getY();
335
		
216 336
		try {
217 337
			// calcula el overview a usar
218 338
			bandR = getRasterBand(1);
......
230 350
	            		currentFullWidth = ovb.getRasterBandXSize();
231 351
	            		currentFullHeight = ovb.getRasterBandYSize();
232 352
	            		tl = worldToRaster(new Point2D.Double(dWorldTLX, dWorldTLY));
233
	            		currentViewX = tl.getX();
234
	            		lastReadLine = tl.getY();
353
	            		if(!orientation[0])//Invierte la orientaci?n en X
354
	            			currentViewX = (width - tl.getX()) - (br.getX()-tl.getX());
355
	            		else
356
	            			currentViewX = tl.getX();
357
	            		if(orientation[1])//Invierte la orientaci?n en Y
358
	            			lastReadLine = (height - tl.getY()) - (br.getY()-tl.getY());
359
	            		else
360
	            			lastReadLine = tl.getY();
235 361
	            		break;
236 362
					}
237 363
				}
......
245 371
				bandG = getRasterBand(gBandNr);
246 372
				bandB = getRasterBand(bBandNr);				
247 373
				if(metadata.isAlphaBand())
248
				//if(this.getRasterCount() == 4 && shortName.equals("PNG"))
249 374
					bandA = getRasterBand(aBandNr); 
250 375
			}
251 376
			if (currentOverview > 0) {
......
254 379
					bandG = bandG.getOverview(currentOverview);
255 380
					bandB = bandB.getOverview(currentOverview);
256 381
					if(metadata.isAlphaBand())
257
					//if(this.getRasterCount() == 4 && shortName.equals("PNG"))
258 382
						bandA = bandA.getOverview(currentOverview);
259 383
				}
260 384
			}
261 385

  
262
			//System.out.println(band.)
263 386
		} catch (GdalException e) {
264
			// TODO Auto-generated catch block
265 387
			e.printStackTrace();
266 388
		}
267

  
268
		System.out.println("GdalFile: TL=("+dWorldTLX+","+dWorldTLY+
269
			"); BR=("+dWorldBRX+","+dWorldBRY+")\n"+
270
			"GdalFile: escala="+viewportScaleX+"; lastReadLine="+lastReadLine+"\n"+
271
		    "Actual Raster Size="+currentFullWidth+"x"+currentFullHeight+
272
			"\nDataType="+dataType);
273 389
		return err;
274 390
	}
275 391
	
......
303 419
			if (bandB != null)
304 420
	    		b = bandB.readRaster(x, y, w, 1, w, 1, dataType);
305 421
        }
306
          		
307
        lastReadLine += stepY;
422
          
423
		lastReadLine += stepY;
308 424
        
309 425
  		int i=0;
310 426
  		double j = 0D;
......
347 463
		return;
348 464
	}
349 465
	
466
	//int liney = 0;
350 467
	int readLineRGBA(int [] line) throws GdalException {
351 468
		int err = 0;
352 469
		
......
362 479
        //if (alpha > 0) a = alpha << 24;
363 480
        if (x+w > bandR.getRasterBandXSize()) 
364 481
        	w = bandR.getRasterBandXSize()-x;
365
        
482
                       
366 483
        if(bandR.getRasterColorTable() != null){
367 484
        	p = bandR.readRasterWithPalette(x, y, w, 1, w, 1, dataType);
368 485
        	a.buffByte = p.buffAPalette;
......
372 489
        	g.buffByte = p.buffGPalette;
373 490
        	b = new GdalBuffer();
374 491
        	b.buffByte = p.buffBPalette;
375
        }else{
376
        	
492
        }else{			
377 493
        	r = bandR.readRaster(x, y, w, 1, w, 1, dataType);
378 494
			if (bandG != null)
379 495
	    		g = bandG.readRaster(x, y, w, 1, w, 1, dataType);
......
389 505
    				a.buffByte[i] = (byte)255;
390 506
        	}
391 507
        }
392
  		lastReadLine += stepY;
508
       
509
        lastReadLine += stepY;
393 510
  	
394 511
  		int i=0;
395 512
  		double j =  Math.abs(currentViewX - ((int)currentViewX));
396 513
		int alpha = (this.alpha & 0xff) << 24;
397
		//try{
398
  		if (dataType == GDT_Byte){
399
	  		if (g != null)
400
	      		for (i=0; i<currentViewWidth && j<r.getSize(); i++, j+=stepX) {
401
	      			int jInt = (int)(j);
402
	      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) + ((r.buffByte[jInt] & 0xff) << 16) + ((g.buffByte[jInt] & 0xff) << 8) + (b.buffByte[jInt] & 0xff);
403
	      		}
404
	      	else
405
	      		for (i=0; i<currentViewWidth && j<r.getSize(); i++, j+=stepX) {
406
	      			int jInt = (int)(j);
407
	      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) + ((r.buffByte[jInt] & 0xff) << 16) + ((r.buffByte[jInt] & 0xff) << 8) + (r.buffByte[jInt] & 0xff);
408
	      		}
409
  		}else if (dataType == GDT_CInt16 || dataType == GDT_Int16  || dataType == GDT_UInt16){
410
  			if (g == null) // Sibgle Band (Typical DEM)
411
	      		/*for (i=0, j=0F, i2 = 1; i<currentViewWidth && i2<r.length;
412
	      			i++, j+=step, i2 = (((int) j)*2)+1) {
413
	      			line[i] = a + ((r[i2-1]) << 8) + r[i2];
414
	      		}*/
415
  		  		for (i=0; i<currentViewWidth && j<r.getSize(); i++, j+=stepX) {
416
  		  			int jInt = (int)(j);
417
	      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) + r.buffShort[jInt];
418
	      		}
419
  			else { // Multiband
420
  				// System.err.println("Raster 16bits multibanda");
421
	      		for (i=0; i<currentViewWidth && j<r.getSize(); i++, j+=stepX) {
422
	      			int jInt = (int)(j);
423
	      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) | (((r.buffShort[jInt] & 0xfff0) << 12) & 0xff0000 ) | 
424
									  						 (((g.buffShort[jInt] & 0xfff0) << 4 ) & 0xff00 ) |
425
									  						 (((b.buffShort[jInt] & 0xfff0) >> 4 ) & 0xff );
426
	      		}
427
  			}
428
  		}
429
		//}catch(ArrayIndexOutOfBoundsException ex){}
514

  
515
		if(orientation[0]){ //Pixel size en X positivo
516
	  		if (dataType == GDT_Byte){
517
		  		if (g != null)
518
		      		for (i=0; i<currentViewWidth && j<r.getSize(); i++, j+=stepX) {
519
		      			int jInt = (int)(j);
520
		      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) + ((r.buffByte[jInt] & 0xff) << 16) + ((g.buffByte[jInt] & 0xff) << 8) + (b.buffByte[jInt] & 0xff);
521
		      		}
522
		      	else
523
		      		for (i=0; i<currentViewWidth && j<r.getSize(); i++, j+=stepX) {
524
		      			int jInt = (int)(j);
525
		      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) + ((r.buffByte[jInt] & 0xff) << 16) + ((r.buffByte[jInt] & 0xff) << 8) + (r.buffByte[jInt] & 0xff);
526
		      		}
527
	  		}else if (dataType == GDT_CInt16 || dataType == GDT_Int16  || dataType == GDT_UInt16){
528
	  			if (g == null) // Sibgle Band (Typical DEM)
529
	  		  		for (i=0; i<currentViewWidth && j<r.getSize(); i++, j+=stepX) {
530
	  		  			int jInt = (int)(j);
531
		      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) + r.buffShort[jInt];
532
		      		}
533
	  			else { // Multiband - Raster 16bits multibanda
534
		      		for (i=0; i<currentViewWidth && j<r.getSize(); i++, j+=stepX) {
535
		      			int jInt = (int)(j);
536
		      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) | (((r.buffShort[jInt] & 0xfff0) << 12) & 0xff0000 ) | 
537
										  						 (((g.buffShort[jInt] & 0xfff0) << 4 ) & 0xff00 ) |
538
										  						 (((b.buffShort[jInt] & 0xfff0) >> 4 ) & 0xff );
539
		      		}
540
	  			}
541
	  		}
542
		}else{ //Pixel size en X negativo
543
			if (dataType == GDT_Byte){
544
		  		if (g != null)
545
		      		for (i=currentViewWidth - 1; i>=0 && j<r.getSize(); i--, j+=stepX) {
546
		      			int jInt = (int)(j);
547
		      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) + ((r.buffByte[jInt] & 0xff) << 16) + ((g.buffByte[jInt] & 0xff) << 8) + (b.buffByte[jInt] & 0xff);
548
		      		}
549
		      	else
550
		      		for (i=currentViewWidth - 1; i>=0 && j<r.getSize(); i--, j+=stepX) {
551
		      			int jInt = (int)(j);
552
		      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) + ((r.buffByte[jInt] & 0xff) << 16) + ((r.buffByte[jInt] & 0xff) << 8) + (r.buffByte[jInt] & 0xff);
553
		      		}
554
	  		}else if (dataType == GDT_CInt16 || dataType == GDT_Int16  || dataType == GDT_UInt16){
555
	  			if (g == null) // Sibgle Band (Typical DEM)
556
	  				for (i=currentViewWidth - 1; i>=0 && j<r.getSize(); i--, j+=stepX) {
557
	  		  			int jInt = (int)(j);
558
		      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) + r.buffShort[jInt];
559
		      		}
560
	  			else { // Multiband - Raster 16bits multibanda;
561
	  				for (i=currentViewWidth - 1; i>=0 && j<r.getSize(); i--, j+=stepX) {
562
		      			int jInt = (int)(j);
563
		      			line[i] = (alpha & ((a.buffByte[jInt])& 0xff) << 24) | (((r.buffShort[jInt] & 0xfff0) << 12) & 0xff0000 ) | 
564
										  						 (((g.buffShort[jInt] & 0xfff0) << 4 ) & 0xff00 ) |
565
										  						 (((b.buffShort[jInt] & 0xfff0) >> 4 ) & 0xff );
566
		      		}
567
	  			}
568
	  		}
569
			
570
		}
571

  
430 572
		return err;
431 573
	}
432 574
		
......
476 618
    				a.buffByte[i] = (byte)255;
477 619
        	}
478 620
        }
479
  		lastReadLine += ((double)bandH)*stepY;
621
        
622
        lastReadLine += ((double)bandH)*stepY;
480 623
  		
481 624
  		// TODO Acabar de implementarlo
482 625
  		float k=0F;
......
540 683
public class GdalFile extends GeoRasterFile {
541 684
	public final static int 	BAND_HEIGHT = 64;
542 685
	protected GdalNative 		file = null;
543
	/**
544
	 * Tama?o de pixel para las imagenes con fichero RMF. No podemos salvarlo en file porque es necesario conocer el
545
	 * tama?o de pixel asignado por rl .rmf y el tama?o de pixel real.
546
	 */
547
	private double				pixelSizeX = 0D, pixelSizeY = 0D;
548 686

  
549 687
	private Extent v = null;
550 688
	
......
588 726
	 * Obtenemos o calculamos el extent de la imagen.
589 727
	 */
590 728
	public GeoFile load() {
591
		extent = new Extent(file.esq.minX, file.esq.minY, file.esq.maxX, file.esq.maxY);	
729
		extent = new Extent(file.bBoxRot.minX, file.bBoxRot.minY, file.bBoxRot.maxX, file.bBoxRot.maxY);
730
		requestExtent = new Extent(file.bBoxWithoutRot.minX, file.bBoxWithoutRot.minY, file.bBoxWithoutRot.maxX, file.bBoxWithoutRot.maxY);
592 731
		return this;
593 732
	}
594 733
	
......
624 763
	 */
625 764
	public void setView(Extent e) { 
626 765
		if(rmfExists){
627
			//Trasladamos la petici?n al origen
766
												
628 767
			Point2D.Double petInit = null, petEnd = null;
629 768
			try{
630 769
				petInit = new Point2D.Double(e.minX(),  e.maxY());
631 770
				petEnd = new Point2D.Double(e.maxX(), e.minY());
632
				transformNewExtent.inverseTransform(petInit, petInit);
633
				transformNewExtent.inverseTransform(petEnd, petEnd);
771
				transformRMF.inverseTransform(petInit, petInit);
772
				transformRMF.inverseTransform(petEnd, petEnd);
773
				transformTFW.transform(petInit, petInit);
774
				transformTFW.transform(petEnd, petEnd);
634 775
			}catch(NoninvertibleTransformException ex){}
776
			double h = file.bBoxWithoutRot.maxY - file.bBoxWithoutRot.minY;
777
			if(!file.isGeoreferenced())
778
				v = new Extent(	petInit.getX(), h - petInit.getY(), petEnd.getX(), h - petEnd.getY()); 
779
			else
780
				v = new Extent(	petInit.getX(), petInit.getY(), petEnd.getX(), petEnd.getY());
635 781
			
636
			//Redimensionamos la petici?n al tama?o de caja del destino
637
			double originX = (petInit.getX() * getExtentRatio().getX()) / extent.width();
638
			double originY = (petInit.getY() * getExtentRatio().getY()) / extent.height();
639
			double endX = (petEnd.getX() * getExtentRatio().getX()) / extent.width();
640
			double endY = (petEnd.getY() * getExtentRatio().getY()) / extent.height();
641
			
642
			//Trasladamos a su sistema de coordenadas
643
			Point2D.Double destInit = new Point2D.Double(originX, originY);
644
			Point2D.Double destEnd = new Point2D.Double(endX, endY);
645
			
646
			transformOldExtent.transform(destInit, destInit);
647
			transformOldExtent.transform(destEnd, destEnd);
648
			if(file.trans == null){
649
				destInit.y = getExtentRatio().getY() + destInit.y; 
650
				destEnd.y = getExtentRatio().getY() + destEnd.y;
651
			}
652
			v = new Extent(	destInit.getX(), destInit.getY(), destEnd.getX(), destEnd.getY());
653
						
654 782
		}else
655 783
			v = new Extent(e.minX(), e.minY(), e.maxX(), e.maxY());	
656 784
	}
785
	
786
	 /**
787
	 * Calcula la transformaci?n que se produce sobre la vista cuando la imagen tiene un fichero .rmf
788
	 * asociado. En Gdal el origen de coordenadas en Y es el valor m?nimo y crece hasta el m?ximo. De la
789
	 * misma forma calcula la matriz de transformaci?n de la cabecera del fichero o del world file asociado
790
	 * @param originX Origen de la imagen en la coordenada X
791
	 * @param originY Origen de la imagen en la coordenada Y
792
	 */
793
	public void setExtentTransform(double originX, double originY, double w, double h, double psX, double psY) {		
794
		transformRMF.setToTranslation(originX, originY);
795
		transformRMF.scale(psX, psY);
657 796
		
797
		if(file.trans != null){	
798
			transformTFW.setToTranslation(file.trans.adfgeotransform[0], file.trans.adfgeotransform[3]);
799
			transformTFW.scale(file.trans.adfgeotransform[1], file.trans.adfgeotransform[5]);
800
		}
801
	}
802
		
658 803
	/**
659 804
	 * Obtiene extent de la vista actual
660 805
	 */
......
683 828
		// TODO Auto-generated method stub
684 829
	}
685 830
	
831
	/**
832
	 * Obtiene la orientaci?n de la imagen a partir del signo del tama?o de pixel para poder
833
	 * asignarlo en el setView. Esto es util para poder conocer como debe leerse la image, 
834
	 * de abajo a arriba, de arriba a abajo, de izquierda a derecha o de derecha a izquierda. 
835
	 * La posici?n habitual es la que el pixel size en X es positivo y en Y negativo leyendose 
836
	 * en este caso las X de menor a mayor y las Y de mayor a menor. Los casos posibles son:
837
	 * <UL>
838
	 * <LI><B>X > 0; Y < 0;</B> {true, false}</LI>
839
	 * <LI><B>X > 0; Y > 0;</B> {true, true}</LI>
840
	 * <LI><B>X < 0; Y > 0;</B> {false, true}</LI>
841
	 * <LI><B>X < 0; Y < 0;</B> {false, false}</LI>
842
	 * </UL>
843
	 *  
844
	 * @return
845
	 */
846
	private boolean[] getOrientation(){
847
		boolean[] orientation = {true, false};
848
		if(!rmfExists){
849
			if(file.trans != null && file.trans.adfgeotransform != null && file.trans.adfgeotransform[5] > 0)
850
				orientation[1] = true;
851
			if(file.trans != null && file.trans.adfgeotransform != null && file.trans.adfgeotransform[1] < 0)
852
				orientation[0] = false;
853
		}else{
854
			if(pixelSizeY > 0)
855
				orientation[1] = true;
856
			if(pixelSizeX < 0)
857
				orientation[0] = false;
858
		}
859
		return orientation;
860
	}
861
	
686 862
	/* (non-Javadoc)
687 863
	 * @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans)
688 864
	 */
......
701 877
			  width = (int)((double)height*dFileAspect);
702 878
			}
703 879
		}
704
		
705
		// Set the view
880
						
881
		// Set the view				
706 882
		file.setView(v.minX(), v.maxY(), v.maxX(), v.minY(),
707
			width, height);
883
			width, height, getOrientation());
708 884
		
709 885
		if(width<=0)width=1;
710 886
		if(height<=0)height=1;
......
749 925
		}
750 926
		
751 927
		// Set the view
928
		boolean[] orientation = getOrientation();
752 929
		file.setView(v.minX(), v.maxY(), v.maxX(), v.minY(),
753
			width, height);
930
			width, height, orientation);
754 931
		
755 932
		raster = new RasterBuf(DataBuffer.TYPE_INT, width, height, 4, new Point(0,0));
756 933
		try {
757
			//int nLin = height % BAND_HEIGHT;
934

  
758 935
			file.setAlpha(getAlpha());
759 936
			setBand(RED_BAND,   rBandNr);
760 937
			setBand(GREEN_BAND, gBandNr);
......
905 1082
		}
906 1083
		
907 1084
		// Set the view
1085
		boolean[] orientation = getOrientation();
908 1086
		file.setView(v.minX(), v.maxY(), v.maxX(), v.minY(),
909
			width, height);
1087
			width, height, orientation);
910 1088
		
911 1089
		if(width<=0)width=1;
912 1090
		if(height<=0)height=1;
913 1091
		
914
		pRGBArray = new int[width/**BAND_HEIGHT*/];
1092
		pRGBArray = new int[width];
915 1093
		try {
916 1094
			setBand(RED_BAND,   rBandNr);
917 1095
			setBand(GREEN_BAND, gBandNr);
918 1096
			setBand(BLUE_BAND,  bBandNr);
919 1097
			file.setAlpha(getAlpha());
920 1098
			if(img!=null){
921
				for (line=0; line < height; line++) { 
922
					file.readLineRGBA(pRGBArray);
923
					setRGBLine((BufferedImage) img, 0, line, width, 1/*bandH*/, pRGBArray, 0, width, origBand, destBandFlag);
1099
				if(orientation[1]){
1100
					for (line=0; line < height; line++) {
1101
						file.readLineRGBA(pRGBArray);
1102
						setRGBLine((BufferedImage) img, 0, height - 1 - line, width, 1, pRGBArray, 0, width, origBand, destBandFlag);
1103
					}	
1104
				}else{
1105
					for (line=0; line < height; line++) {
1106
						file.readLineRGBA(pRGBArray);
1107
						setRGBLine((BufferedImage) img, 0, line, width, 1, pRGBArray, 0, width, origBand, destBandFlag);
1108
					}
924 1109
				}
925 1110
				return img;
926 1111
			}else{
927 1112
				Image image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
928
				for (line=0; line < height; line++) { 
929
					file.readLineRGBA(pRGBArray);
930
					setRGBLine((BufferedImage) image, 0, line, width, 1/*bandH*/, pRGBArray, 0, width);
1113
				if(orientation[1]){
1114
					for (line=0; line < height; line++) {
1115
						file.readLineRGBA(pRGBArray);
1116
						setRGBLine((BufferedImage) image, 0, height - 1 - line, width, 1, pRGBArray, 0, width);
1117
					}	
1118
				}else{
1119
					for (line=0; line < height; line++) {
1120
						file.readLineRGBA(pRGBArray);
1121
						setRGBLine((BufferedImage) image, 0, line, width, 1, pRGBArray, 0, width);
1122
					}
931 1123
				}
932 1124
				return image;
933 1125
			}
......
996 1188
	public int getBlockSize(){
997 1189
	  return file.getBlockSize();
998 1190
	}
999
	
1000
	 /**
1001
	 * Calcula la transformaci?n que se produce sobre la vista cuando la imagen tiene un fichero .rmf
1002
	 * asociado. En Gdal el origen de coordenadas en Y es el valor m?nimo y crece hasta el m?ximo.
1003
	 * @param originX Origen de la imagen en la coordenada X
1004
	 * @param originY Origen de la imagen en la coordenada Y
1005
	 */
1006
	public void setExtentTransform(double originX, double originY, double w, double h, double psX, double psY) {
1007
		pixelSizeX = psX;
1008
    	pixelSizeY = psY;
1009
    	
1010
		double oldOriginX = 0D;
1011
		double oldOriginY = 0D;
1012
		if(file.trans != null){
1013
			oldOriginX = file.trans.adfgeotransform[0];
1014
			oldOriginY = file.trans.adfgeotransform[3];
1015
		}
1016 1191
		
1017
		transformNewExtent.translate(originX, originY);
1018
		transformOldExtent.translate(oldOriginX, oldOriginY);
1019
		extentsRatio.setLocation(extent.width(), extent.height());
1020
	}
1021
	
1022 1192
	/**
1023 1193
	 * Obtiene el objeto que contiene los metadatos
1024 1194
	 */
......
1037 1207
		return file.isGeoreferenced();
1038 1208
	}
1039 1209
    
1210
	/**
1211
	 * Obtiene los par?metros de la transformaci?n af?n que corresponde con los elementos de
1212
	 * un fichero tfw.
1213
	 * <UL> 
1214
	 * <LI>[1]tama?o de pixel en X</LI>
1215
	 * <LI>[2]rotaci?n en X</LI>
1216
	 * <LI>[4]rotaci?n en Y</LI>
1217
	 * <LI>[5]tama?o de pixel en Y</LI>
1218
	 * <LI>[0]origen en X</LI>
1219
	 * <LI>[3]origen en Y</LI>
1220
	 * </UL>
1221
	 * Este m?todo debe ser reimplementado por el driver si tiene esta informaci?n. En principio
1222
	 * Gdal es capaz de proporcionarla de esta forma.
1223
	 * 
1224
	 * En caso de que exista fichero .rmf asociado al raster pasaremos de la informaci?n de georreferenciaci?n
1225
	 * del .tfw y devolveremos la que est? asociada al rmf
1226
	 * @return vector de double con los elementos de la transformaci?n af?n.
1227
	 */
1228
	public double[] getTransform(){
1229
		if(file != null && file.trans != null && !this.rmfExists())
1230
			return file.trans.adfgeotransform;
1231
		else{
1232
			if(this.rmfExists){
1233
				double[] rmfGeoref = {originX, pixelSizeX, shearX, originY, shearY, pixelSizeY};
1234
				return rmfGeoref;
1235
			}
1236
			return null;
1237
		}
1238
		
1239
	}
1040 1240
}
1041 1241

  
1042 1242

  
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/GeoFile.java
41 41
 */
42 42
public abstract class GeoFile implements Projected, Extent.Has {
43 43
    IProjection proj = null;
44
    /**
45
     * Extent completo del raster. Este contiene las coordenadas reales tanto
46
     * para un raster rotado como sin rotar. Este extent coincide con requestExtent
47
     * cuando el raster no tiene rotaci?n. 
48
     */
44 49
    protected Extent extent = null;
45
    
46 50
    /**
51
     * Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el 
52
     * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
53
     * pero para un raster rotado ser? igual al extent del raster como si no 
54
     * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
55
     * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
56
     * aplicado.
57
     */
58
    protected Extent requestExtent = null;
59
    /**
47 60
     * Esto corresponde a la transformaci?n del extent de la imagen. Se calcula a partir del extent
48 61
     * guardado en el fichero .rmf asociado a la imagen.  En caso de que no exista este fichero no habr?
49 62
     * transformaci?n
50 63
     */
51
    protected AffineTransform	transformNewExtent = null;
52
    protected AffineTransform	transformOldExtent = null;
53
    protected Point2D 			extentsRatio = null;
64
    protected AffineTransform	transformRMF = null;
65
    /**
66
     * Esto corresponde a la transformaci?n del extent de la imagen. Se calcula a partir del extent
67
     * guardado en el fichero .tfw asociado a la imagen o en la cabecera de la misma.
68
     */
69
    protected AffineTransform	transformTFW = null;
54 70
    
55 71
    
56 72
    protected boolean			rmfExists = false;
......
70 86
            name = DataSource.normalize(name);
71 87
        }
72 88
        extent = new Extent();
73
        extentsRatio = new Point2D.Double();
74
    	transformNewExtent = new AffineTransform();
75
    	transformOldExtent = new AffineTransform();
89
      	transformRMF = new AffineTransform();
90
    	transformTFW = new AffineTransform();
76 91
    }
77 92

  
78 93
    public String getName() {
......
101 116

  
102 117
    abstract public void reProject(ICoordTrans rp);
103 118

  
119
    /**
120
     * Extent completo del raster. Este contiene las coordenadas reales tanto
121
     * para un raster rotado como sin rotar. Este extent coincide con requestExtent
122
     * cuando el raster no tiene rotaci?n.
123
     * @return Extent 
124
     */
104 125
    public Extent getExtent() {
105 126
        return extent;
106 127
    }
107 128
    
108 129
    /**
109
     * Obtiene la relaci?n entre anchos y altos de la georreferenciaci?n de la imagen y la asignada
110
     * a trav?s del fichero .rmf. Esto se usa para poder realizar transformaciones entre ambos sistemas
111
     * al asignar una vista.
112
     * @return
130
     * Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el 
131
     * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
132
     * pero para un raster rotado ser? igual al extent del raster como si no 
133
     * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
134
     * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
135
     * aplicado.
136
     * @return Extent
113 137
     */
114
    public Point2D getExtentRatio() {
115
        return extentsRatio;
138
    public Extent getExtentForRequest() {
139
        return requestExtent;
116 140
    }
117

  
141
    
118 142
    abstract public GeoFile load();
119 143

  
120 144
    abstract public void close();
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/EcwFile.java
142 142
               ((double) (file.height - 1) * file.cellIncrementY);
143 143
        
144 144
        extent = new Extent(minX, minY, maxX, maxY);
145
        requestExtent = extent;
145 146
        return this;
146 147
    }
147 148

  
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/MrSidFile.java
574 574
    public GeoFile load() {
575 575
    	
576 576
   		extent = new Extent(file.esq.minX, file.esq.minY, file.esq.maxX, file.esq.maxY);
577
   		requestExtent = extent;
577 578
    	
578 579
    	/*if((this.assignedExtent == GeoRasterFile.IMAGE_EXTENT || this.assignedExtent == GeoRasterFile.ORDER ) 
579 580
    		&& file !=null	&& file.esq != null){
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/GeoRasterFile.java
120 120
	 */
121 121
	protected int 				bandCount = 1;
122 122
	private int 				dataType = DataBuffer.TYPE_BYTE;
123
	/**
124
	 * Par?metros de transformaci?n del fichero .rmf. Estas variables tendr?n valores distinto
125
	 * de 0 si la funci?n rmfExists() devuelve true.
126
	 */
127
	protected double originX = 0D, originY = 0D, w = 0D, h = 0D;
128
	protected double pixelSizeX = 0D, pixelSizeY = 0D;
129
	protected double imageWidth = 0D, imageHeight = 0D;
130
	protected double shearX = 0D, shearY = 0D;
123 131

  
124 132
	static {
125 133
		supportedExtensions = new TreeMap();
......
260 268
	private double[] parserExtent(KXmlParser parser) throws XmlPullParserException, IOException {		
261 269
		double originX = 0D, originY = 0D, w = 0D, h = 0D;
262 270
		double pixelSizeX = 0D, pixelSizeY = 0D;
271
		double shearX = 0D, shearY = 0D;
263 272
		
264 273
		boolean end = false;
265 274
    	int tag = parser.next();
......
275 284
							pixelSizeX = Double.parseDouble(parser.nextText());
276 285
						}else if (parser.getName().equals(RasterMetaFileTags.PX_SIZE_Y)){
277 286
							pixelSizeY = Double.parseDouble(parser.nextText());
287
						}else if (parser.getName().equals(RasterMetaFileTags.ROTX)){
288
							shearX = Double.parseDouble(parser.nextText());
289
						}else if (parser.getName().equals(RasterMetaFileTags.ROTY)){
290
							shearY = Double.parseDouble(parser.nextText());
278 291
						}else if (parser.getName().equals(RasterMetaFileTags.WIDTH)){
279 292
							w = Double.parseDouble(parser.nextText());
280 293
						}else if (parser.getName().equals(RasterMetaFileTags.HEIGHT)){
......
292 305
    		tag = parser.next();
293 306
    	}
294 307
		
295
    	double[] values = {originX, originY, w, h, pixelSizeX, pixelSizeY};
308
    	double[] values = {originX, originY, w, h, pixelSizeX, pixelSizeY, shearX, shearY};
296 309
		return values;
297 310
	}
298 311
	
......
309 322
			return;
310 323
		
311 324
		boolean georefOk = false;
312
		double originX = 0D, originY = 0D, w = 0D, h = 0D;
313
		double pixelSizeX = 0D, pixelSizeY = 0D;
314
		double imageWidth = 0D, imageHeight = 0D;
315 325
		
316 326
		FileReader fr = null;
317 327
		String v = null;
......
340 350
											h = values[3];
341 351
											pixelSizeX = values[4];
342 352
											pixelSizeY = values[5];
353
											shearX = values[6];
354
											shearY = values[7];
343 355
											georefOk = true;
344 356
										} else if (parser.getName().equals(RasterMetaFileTags.DIM)){
345 357
											boolean DimEnd = false;
......
373 385
			
374 386
			if(georefOk){
375 387
				rmfExists = true;
388
				
376 389
				setExtentTransform(originX, originY, w, h, pixelSizeX, pixelSizeY);
377
				extent = new Extent(originX, originY, originX + (pixelSizeX * imageWidth), originY + (pixelSizeY * imageHeight));
390
				createExtentsFromRMF(	originX, originY, pixelSizeX, pixelSizeY, 
391
										imageWidth, imageHeight, shearX, shearY);
378 392
			}
379 393
			
380 394
		} catch (FileNotFoundException fnfEx) {
......
391 405
	}
392 406

  
393 407
	/**
408
	 * <P>
409
	 * Calcula el extent de la imagen a partir del fichero rmf con y sin rotaci?n. El extent con rotaci?n corresponde
410
	 * a la variable extent que contiene el extent verdadero marcado por el fichero de georreferenciaci?n .rmf. El extent
411
	 * sin rotaci?n requestExtent es utilizado para realizar la petici?n ya que la petici?n al driver no se puede
412
	 * hacer con coordenadas rotadas.
413
	 * 
414
	 * El calculo de la bounding box rotada lo hace con los valores de transformaci?n leidos desde el fichero .rmf.
415
	 * </p>
416
	 * <P>
417
	 * Para el calculo de una esquina aplicamos la formula siguiente:<BR>
418
	 * PtoX = originX + pixelSizeX * x + shearX * y;<BR>
419
	 * PtoY = originY + shearY * x + pixelSizeY * y;<BR>
420
	 * Aplicandolo a las cuatro esquinas sustituimos en cada una de ellas por.
421
	 * </P>
422
	 * <UL> 
423
	 * <LI>Esquina superior izquierda: x = 0; y = 0;</LI>
424
	 * <LI>Esquina superior derecha: x = MaxX; y = 0;</LI>
425
	 * <LI>Esquina inferior izquierda: x = 0; y = MaxY;</LI>
426
	 * <LI>Esquina inferior derecha: x = MaxX; y = MaxY;</LI>
427
	 * </UL> 
428
	 * <P>
429
	 * quedandonos en los cuatro casos:
430
	 * </P>
431
	 * <UL> 
432
	 * <LI>Esquina superior izquierda: originX; originY;</LI>
433
	 * <LI>Esquina superior derecha: PtoX = originX + pixelSizeX * x; PtoY = originY + shearY * x;</LI>
434
	 * <LI>Esquina inferior izquierda:  PtoX = originX + shearX * y; PtoY = originY + pixelSizeY * y;</LI>
435
	 * <LI>Esquina inferior derecha: PtoX = originX + pixelSizeX * x + shearX * y; PtoY = originY + shearY * x + pixelSizeY * y;</LI>
436
	 * </UL>
437
	 * 
438
	 * <P>
439
	 * El calculo de la bounding box se realizar? de la misma forma pero anulando los parametros de shearing.
440
	 * </P>
441
	 * 
442
	 * @param originX Coordenada X de origen del raster
443
	 * @param originY Coordenada Y de origen del raster
444
	 * @param pixelSizeX Tama?o de pixel en X
445
	 * @param pixelSizeY Tama?o de pixel en Y
446
	 * @param imageWidth Ancho del raster en pixels
447
	 * @param imageHeight Alto del raster en pixels
448
	 * @param shearX Shearing en X
449
	 * @param shearY Shearing en Y
450
	 */
451
	private void createExtentsFromRMF(	double originX, double originY, double pixelSizeX, double pixelSizeY, 
452
										double imageWidth, double imageHeight, double shearX, double shearY){
453
				
454
		Point2D p1 = new Point2D.Double(originX, originY);
455
		Point2D p2 = new Point2D.Double(originX + shearX * imageHeight, originY + pixelSizeY * imageHeight);
456
		Point2D p3 = new Point2D.Double(originX + pixelSizeX * imageWidth, originY + shearY * imageWidth);
457
		Point2D p4 = new Point2D.Double(originX + pixelSizeX * imageWidth + shearX * imageHeight, originY + pixelSizeY * imageHeight + shearY * imageWidth);
458
		
459
		double minX = Math.min(Math.min(p1.getX(), p2.getX()), Math.min(p3.getX(), p4.getX()));
460
		double minY = Math.min(Math.min(p1.getY(), p2.getY()), Math.min(p3.getY(), p4.getY()));
461
		double maxX = Math.max(Math.max(p1.getX(), p2.getX()), Math.max(p3.getX(), p4.getX()));
462
		double maxY = Math.max(Math.max(p1.getY(), p2.getY()), Math.max(p3.getY(), p4.getY()));
463
		extent = new Extent(minX, minY, maxX, maxY);
464
		requestExtent = new Extent(originX, originY, originX + (pixelSizeX * imageWidth), originY + (pixelSizeY * imageHeight));
465
	}
466
	
467
	/**
394 468
	 * Calcula la transformaci?n que se produce sobre la vista cuando la imagen tiene un fichero .rmf
395 469
	 * asociado. Esta transformaci?n tiene diferencias entre los distintos formatos por lo que debe calcularla
396 470
	 * el driver correspondiente.
......
655 729
	public boolean isGeoreferenced(){
656 730
		return true;
657 731
	}
732
	
733
	/**
734
	 * M?todo que indica si existe un fichero .rmf asociado al GeoRasterFile.
735
	 * @return
736
	 */
737
	public boolean rmfExists(){
738
		return this.rmfExists;
739
	}
740
	
741
	/**
742
	 * Obtiene los par?metros de la transformaci?n af?n que corresponde con los elementos de
743
	 * un fichero tfw.
744
	 * <UL> 
745
	 * <LI>[1]tama?o de pixel en X</LI>
746
	 * <LI>[2]rotaci?n en X</LI>
747
	 * <LI>[4]rotaci?n en Y</LI>
748
	 * <LI>[5]tama?o de pixel en Y</LI>
749
	 * <LI>[0]origen en X</LI>
750
	 * <LI>[3]origen en Y</LI>
751
	 * </UL>
752
	 * Este m?todo debe ser reimplementado por el driver si tiene esta informaci?n. En principio
753
	 * Gdal es capaz de proporcionarla de esta forma.
754
	 * @return vector de double con los elementos de la transformaci?n af?n.
755
	 */
756
	public double[] getTransform(){return null;}
658 757
}
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/PxObj.java
28 28

  
29 29
public abstract class PxObj implements Drawable, Extent.Has {
30 30
    public Stroke stroke = null;
31
    /**
32
     * Extent completo del raster. Este contiene las coordenadas reales tanto
33
     * para un raster rotado como sin rotar. Este extent coincide con requestExtent
34
     * cuando el raster no tiene rotaci?n. 
35
     */
31 36
    protected Extent extent = null;
37
    /**
38
     * Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el 
39
     * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
40
     * pero para un raster rotado ser? igual al extent del raster como si no 
41
     * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
42
     * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
43
     * aplicado.
44
     */
45
    protected Extent requestExtent = null;
32 46

  
33 47
    public Extent getExtent() {
34 48
        return extent;
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/PxRaster.java
27 27
import java.awt.Component;
28 28
import java.awt.Graphics2D;
29 29
import java.awt.Image;
30
import java.awt.geom.AffineTransform;
30 31
import java.awt.geom.GeneralPath;
32
import java.awt.geom.NoninvertibleTransformException;
31 33
import java.awt.geom.Point2D;
32 34
import java.awt.image.BufferedImage;
33 35
import java.awt.image.DataBuffer;
......
88 90
    private RasterFilterStackManager stackManager = null;
89 91
    private Image geoImage = null;
90 92
    private ViewPortData lastViewPort = null;
93
    
94
    /**
95
     * Variable usada por el draw para calcular el n?mero de pixeles a leer de un
96
     * raster rotado. 
97
     */
98
    private double[] adjustedRotedExtent = null;
91 99

  
92 100
    /**
93 101
     * Constructor.
......
110 118
        this.proj = proj;
111 119
        this.component = component;
112 120
        setExtent(geoFile[0].getExtent());
121
        setExtentForRequest(geoFile[0].getExtentForRequest());
113 122
        geoFile[0].setView(geoFile[0].getExtent());
114 123
        extentOrig = extent;
115 124
        bandSwitch.addFile(geoFile[0]);
......
142 151
            geoFile[i] = GeoRasterFile.openFile(proj, fnames[i]); //loadECW(fname);
143 152
            geoFile[i].setUpdatable((Component) component);
144 153
            setExtent(geoFile[i].getExtent());
154
            setExtentForRequest(geoFile[i].getExtentForRequest());
145 155
            geoFile[i].setView(geoFile[i].getExtent());
146 156
            bandSwitch.addFile(geoFile[i]);
147 157
        }
......
167 177
        this.component = component;
168 178

  
169 179
        setExtent(geoFile[0].getExtent());
180
        setExtentForRequest(geoFile[0].getExtentForRequest());
170 181
        if(view != null){
171 182
	        geoFile[0].setView(view); //geoFile.getExtent());
172 183
	        extentOrig = extent;
......
203 214
            listFiles[geoFile.length] = GeoRasterFile.openFile(proj, fileName);
204 215
            listFiles[geoFile.length].setUpdatable((Component) component);
205 216
            setExtent(listFiles[geoFile.length].getExtent());
217
            setExtentForRequest(listFiles[geoFile.length].getExtentForRequest());
206 218
            listFiles[geoFile.length].setView(listFiles[geoFile.length].getExtent());
207 219
            bandSwitch.addFile(listFiles[geoFile.length]);
208 220
            geoFile = listFiles;
......
626 638
    }
627 639

  
628 640
    /**
641
     * Asigna el extent sobre el que se ajusta una petici?n para que esta no exceda el 
642
     * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
643
     * pero para un raster rotado ser? igual al extent del raster como si no 
644
     * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
645
     * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
646
     * aplicado.
647
     * @param Extent
648
     */
649
    public void setExtentForRequest(Extent e) {
650
        super.requestExtent = e;
651
        if(e != null){
652
	        pts = new Vector();
653
	        pts.add(proj.createPoint(e.minX(), e.minY()));
654
	        pts.add(proj.createPoint(e.maxX(), e.minY()));
655
	        pts.add(proj.createPoint(e.maxX(), e.maxY()));
656
	        pts.add(proj.createPoint(e.minX(), e.maxY()));
657
        }
658
    }
659
    
660
    /**
629 661
     * Cambia la vista (viewport) sobre el raster.
630 662
     *
631 663
     * @param v extent
......
668 700
    }
669 701

  
670 702
    /**
703
     * Transforma la petici?n que est? en coordenadas de la imagen sin rotar a coordenadas de la imagen rotada
704
     * para que sea posible el calculo de la caja m?nima de inclusi?n. La coordenada superior izquierda de esta
705
     * ser? la que se use para posicionar la imagen sobre el graphics aplicandole la transformaci?n de la la vista.
706
     * @param v
707
     * @return
708
     */
709
    private Point2D coordULRotateRaster(double[] v){
710
        double vx = v[0];
711
        double vy = v[1];
712
        double vx2 = v[2];
713
        double vy2 = v[3];
714
    	if (geoFile != null) {
715
        	double[] transf = geoFile[0].getTransform();
716
        	        	
717
           	if(transf != null && (transf[2] != 0 || transf[4] != 0)){
718
           		//La transformaci?n se hace en base a una esquina que varia con el signo del 
719
           		//pixel size. 
720
           		double ptoDesplX = (transf[1] > 0)?requestExtent.minX():requestExtent.maxX();
721
            	double ptoDesplY = (transf[5] < 0)?requestExtent.maxY():requestExtent.minY();
722
            
723
            	Point2D ul = new Point2D.Double(vx - ptoDesplX, vy2 - ptoDesplY);
724
            	Point2D ur = new Point2D.Double(vx2 - ptoDesplX, vy2 - ptoDesplY);
725
            	Point2D ll = new Point2D.Double(vx - ptoDesplX, vy - ptoDesplY);
726
            	Point2D lr = new Point2D.Double(vx2 - ptoDesplX, vy - ptoDesplY);
727
            	
728
           		double shearX = 0;
729
                double shearY = 0;
730
              
731
                if(transf[5] != 0)
732
                	shearX = transf[2] / transf[5];
733
                else
734
                	shearX = transf[2];
735
                if(transf[1] != 0)
736
                	shearY = transf[4] / transf[1];
737
                else
738
                	shearY = transf[4];
739
                
740
                
741
        		AffineTransform at = new AffineTransform();
742
        		at.setToShear(shearX, shearY);
743

  
744
        		at.transform(ul, ul);
745
        		at.transform(ur, ur);
746
        		at.transform(ll, ll);
747
        		at.transform(lr, lr);
748
        			
749
	        	ul = new Point2D.Double(ul.getX() + ptoDesplX, ul.getY() + ptoDesplY);
750
	        	ur = new Point2D.Double(ur.getX() + ptoDesplX, ur.getY() + ptoDesplY);
751
	        	ll = new Point2D.Double(ll.getX() + ptoDesplX, ll.getY() + ptoDesplY);
752
	        	lr = new Point2D.Double(lr.getX() + ptoDesplX, lr.getY() + ptoDesplY);
753
	        	
754
        		vx2 = Math.max(Math.max(ul.getX(), ur.getX()), Math.max(ll.getX(), lr.getX()));
755
        		vy2 = Math.max(Math.max(ul.getY(), ur.getY()), Math.max(ll.getY(), lr.getY()));
756
        		vx = Math.min(Math.min(ul.getX(), ur.getX()), Math.min(ll.getX(), lr.getX()));
757
        		vy = Math.min(Math.min(ul.getY(), ur.getY()), Math.min(ll.getY(), lr.getY()));
758
        		adjustedRotedExtent = new double[4];
759
        		adjustedRotedExtent[0] = vx;
760
        		adjustedRotedExtent[1] = vy;
761
        		adjustedRotedExtent[2] = vx2;
762
        		adjustedRotedExtent[3] = vy2;
763
        		return ul;
764
        	}
765
           	
766
        }
767
    	return null;
768
        
769
    }
770
    
771
    /**
671 772
     * Ajusta la extensi?n pasada por par?metro y que corresponde al extent de la vista donde
672 773
     * se va a dibujar a los valores m?ximos y m?nimos de la imagen. Esto sirve para que la
673 774
     * petici?n al driver nunca sobrepase los l?mites de la imagen tratada aunque la vista
674 775
     * donde se dibuje sea de mayor tama?o.
675 776
     * 
777
     * Antes de realizar este ajuste hay que transformar la petici?n que puede corresponder a 
778
     * una imagen rotada a las coordenadas de la imagen sin rotar ya que las peticiones al 
779
     * driver hay que hacerlas con estas coordenadas. Para esto trasladamos la petici?n al origen
780
     * de la imagen (esquina superior izquierda), aplicamos la transformaci?n inversa a las cuatro 
781
     * esquinas obtenidas y volvemos a trasladar a su posici?n original. 
782
     * 
783
     * Se usa la transformaci?n inversa para trasladar un punto del raster rotado al mismo sin 
784
     * rotar y la transformaci?n af?n normal para trasladar un punto sin rotar a uno rotado.
785
     * 
676 786
     * @param sz Extent completo de la vista donde se va a dibujar.
677 787
     */
678
    protected double[] calculateNewView(Extent sz) { 
788
    protected double[] calculateNewView(ViewPortData vp) {
789
    	Extent sz = vp.getExtent();
679 790
        double vx = sz.minX();
680 791
        double vy = sz.minY();
681 792
        double vx2 = sz.maxX();
682 793
        double vy2 = sz.maxY();
794
        
795
        //Trasladamos la petici?n si est? rotada a su posici?n sin rotar
796
        
797
        if (geoFile != null) {
798
        	double[] transf = geoFile[0].getTransform();
799
        	        	
800
           	if(transf != null && (transf[2] != 0 || transf[4] != 0)){
801
           		
802
           		//La transformaci?n se hace en base a una esquina que varia con el signo del 
803
           		//pixel size. 
804
           		double ptoDesplX = (transf[1] > 0)?requestExtent.minX():requestExtent.maxX();
805
            	double ptoDesplY = (transf[5] < 0)?requestExtent.maxY():requestExtent.minY();
806
            	
807
            	Point2D ul = new Point2D.Double(vx - ptoDesplX, vy2 - ptoDesplY);
808
            	Point2D ur = new Point2D.Double(vx2 - ptoDesplX, vy2 - ptoDesplY);
809
            	Point2D ll = new Point2D.Double(vx - ptoDesplX, vy - ptoDesplY);
810
            	Point2D lr = new Point2D.Double(vx2 - ptoDesplX, vy - ptoDesplY);
811
            	
812
           		double shearX = 0;
813
                double shearY = 0;
814
                if(transf[5] != 0)
815
                	shearX = transf[2] / transf[5];
816
                else
817
                	shearX = transf[2];
818
                if(transf[1] != 0)
819
                	shearY = transf[4] / transf[1];
820
                else
821
                	shearY = transf[4];
822
                
823
        		AffineTransform at = new AffineTransform();
824
        		at.setToShear(shearX, shearY);
825
        		
826
        		try {
827
        			at.inverseTransform(ul, ul);
828
        			at.inverseTransform(ur, ur);
829
        			at.inverseTransform(ll, ll);
830
        			at.inverseTransform(lr, lr);
831
				} catch (NoninvertibleTransformException e) {
832
					e.printStackTrace();
833
				}
834
				
835
	        	ul = new Point2D.Double(ul.getX() + ptoDesplX, ul.getY() + ptoDesplY);
836
	        	ur = new Point2D.Double(ur.getX() + ptoDesplX, ur.getY() + ptoDesplY);
837
	        	ll = new Point2D.Double(ll.getX() + ptoDesplX, ll.getY() + ptoDesplY);
838
	        	lr = new Point2D.Double(lr.getX() + ptoDesplX, lr.getY() + ptoDesplY);
839
	        	
840
        		vx2 = Math.max(Math.max(ul.getX(), ur.getX()), Math.max(ll.getX(), lr.getX()));
841
        		vy2 = Math.max(Math.max(ul.getY(), ur.getY()), Math.max(ll.getY(), lr.getY()));
842
        		vx = Math.min(Math.min(ul.getX(), ur.getX()), Math.min(ll.getX(), lr.getX()));
843
        		vy = Math.min(Math.min(ul.getY(), ur.getY()), Math.min(ll.getY(), lr.getY()));
844
        	}
845
        }
683 846

  
684
        if (sz.minX() < extent.minX())
685
            vx = extent.minX();
847
        if (vx < requestExtent.minX())
848
            vx = requestExtent.minX();
686 849
        
687
        if (sz.minY() < extent.minY()) 
688
            vy = extent.minY();
850
        if (vy < requestExtent.minY()) 
851
            vy = requestExtent.minY();
689 852
        
690
        if (sz.maxX() > extent.maxX()) 
691
            vx2 = extent.maxX();
853
        if (vx2 > requestExtent.maxX()) 
854
            vx2 = requestExtent.maxX();
692 855
        
693
        if (sz.maxY() > extent.maxY())
694
            vy2 = extent.maxY();
695
        
856
        if (vy2 > requestExtent.maxY())
857
            vy2 = requestExtent.maxY();
858
                
696 859
        if (geoFile != null) {
697 860
            for (int i = 0; i < geoFile.length; i++)
698
                geoFile[i].setView(new Extent(vx, vy, vx2, vy2));
861
            	geoFile[i].setView(new Extent(vx, vy, vx2, vy2));
699 862
        } else {
700 863
            System.err.println("PxRaster.calculateNewView(): Imagen no cargada.");
701 864
        }
......
729 892
        }
730 893
    }
731 894
    
732
    /**
733
     * Dibuja el raster sobre el Graphics. Para ello debemos de pasar el viewPort que corresponde a la
734
     * vista. Este viewPort es ajustado a los tama?os m?ximos y m?nimos de la imagen por la funci?n  
735
     * calculateNewView. Esta funci?n tambi?n asignar? la vista a los drivers. Posteriormente se calcula 
736
     * el alto y ancho de la imagen a dibujar (wImg, hImg), as? como el punto donde se va a pintar dentro 
737
     * del graphics (pt). Finalmente se llama a updateImage del driver para que pinte y una vez dibujado
738
     * se pasa a trav?s de la funci?n renderizeRaster que es la encargada de aplicar la pila de filtros
739
     * sobre el Image que ha devuelto el driver.
740
     * 
741
     * @param g Graphics sobre el que se pinta
742
     * @param vp ViewPort de la extensi?n a dibujar
743
     */
895
    /** Dibuja el raster sobre el Graphics. Para ello debemos de pasar el viewPort que corresponde a la
896
    * vista. Este viewPort es ajustado a los tama?os m?ximos y m?nimos de la imagen por la funci?n  
897
    * calculateNewView. Esta funci?n tambi?n asignar? la vista a los drivers. Posteriormente se calcula 
898
    * el alto y ancho de la imagen a dibujar (wImg, hImg), as? como el punto donde se va a pintar dentro 
899
    * del graphics (pt). Finalmente se llama a updateImage del driver para que pinte y una vez dibujado
900
    * se pasa a trav?s de la funci?n renderizeRaster que es la encargada de aplicar la pila de filtros
901
    * sobre el Image que ha devuelto el driver.
902
    * 
903
    * Para calcular en que coordenada pixel (pt) se empezar? a pintar el BufferedImage con el raster le?do
904
    * se aplica sobre la esquina superior izquierda de esta la matriz de transformaci?n del ViewPortData
905
    * pasado vp.mat.transform(pt, pt). Si el raster no est? rotado este punto es el resultante de la
906
    * funci?n calculateNewView que devuelve la petici?n ajustada al extent de la imagen (sin rotar). Si
907
    * el raster est? rotado necesitaremos para la transformaci?n el resultado de la funci?n coordULRotateRaster. 
908
    * Lo que hace esta ?ltima es colocar la petici?n que ha sido puesta en coordenadas de la imagen sin rotar
909
    * (para pedir al driver de forma correcta) otra vez en coordenadas de la imagen rotada (para calcular su 
910
    * posici?n de dibujado).
911
    * 
912
    * Para dibujar sobre el Graphics2D el raster rotado aplicaremos la matriz de transformaci?n con los 
913
    * par?metros de Shear sobre este Graphics de forma inversa. Como hemos movido el fondo tendremos que
914
    * recalcular ahora el punto donde se comienza a dibujar aplicandole la transformaci?n sobre este
915
    * at.inverseTransform(pt, pt);. Finalmente volcamos el BufferedImage sobre el Graphics volviendo a dejar
916
    * el Graphics en su posici?n original al acabar. 
917
    * 
918
    * @param g Graphics sobre el que se pinta
919
    * @param vp ViewPort de la extensi?n a dibujar
920
    */
744 921
    public synchronized void draw(Graphics2D g, ViewPortData vp) {
745 922
        geoImage = null;
746

  
923
    	double shearX = 0;
924
        double shearY = 0;
925
        double factor = 1;
926
        
747 927
        long t2;
748 928
        long t1 = new Date().getTime();
749 929
        lastViewPort = vp;
......
755 935
            return;
756 936
        }
757 937

  
758
        double[] adjustedExtent = calculateNewView(vp.getExtent());
759

  
938
        double[] adjustedExtent = calculateNewView(vp);
939
        Point2D p2d = coordULRotateRaster(adjustedExtent);
940
        
760 941
        Extent v = geoFile[0].getView();
761 942
        double x = v.minX();
762 943
        double y = v.minY();
......
770 951
        int hImg = (int) Math.round(Math.abs(h * scaley));*/
771 952
        int wImg = (int) Math.round(Math.abs((adjustedExtent[2] - adjustedExtent[0]) * scalex));
772 953
        int hImg = (int) Math.round(Math.abs((adjustedExtent[3] - adjustedExtent[1]) * scaley));
773

  
954
                
774 955
        if ((wImg <= 0) || (hImg <= 0))
775 956
            return;
776
        
957
                
777 958
        //Para la transformaci?n usamos el extent que ha ajustado la funci?n calculateNewView y no usamos 
778 959
        //el getView porque el getView puede haber  sufrido una transformaci?n en caso de que exista 
779 960
        //fichero .rmf. En caso de no existir este fichero ser?a lo mismo aplicar la funci?n:
780 961
        //Point2D.Double pt = new Point2D.Double(x, y + h);
781
        Point2D.Double pt = new Point2D.Double(adjustedExtent[0], adjustedExtent[3]);
962
        int wI = wImg, hI = hImg;
963
        double[] transf = bandSwitch.getBandR().getGeoRasterFile().getTransform();
964
        Point2D.Double pt = null;
965
       	if(transf != null && (transf[2] != 0 || transf[4] != 0)){ //Esta rotada
966
       		pt =  new Point2D.Double(p2d.getX(), p2d.getY());
967
       		wImg = (int) Math.round(Math.abs((adjustedRotedExtent[2] - adjustedRotedExtent[0]) * scalex));
968
            hImg = (int) Math.round(Math.abs((adjustedRotedExtent[3] - adjustedRotedExtent[1]) * scaley));
969
       	}else{	//No est? rotada
970
       			pt = new Point2D.Double(adjustedExtent[0], adjustedExtent[3]);
971
       	}
782 972
        
783 973
        try {
784 974
            vp.mat.transform(pt, pt);
......
851 1041

  
852 1042
                geoImage = renderizeRaster(geoImage, vp, v);
853 1043

  
854
                g.drawImage(geoImage, (int) (pt.getX()), (int) (pt.getY()), component);
1044
                AffineTransform at = new AffineTransform();
1045

  
1046
                if(transf != null && (transf[2] != 0 || transf[4] != 0)){
1047
                	                	
1048
                	//Obtenemos los par?metros de shearing
1049
	                if(transf[5] != 0)
1050
	                	shearX = transf[2] / transf[5];
1051
	                else
1052
	                	shearX = transf[2];
1053
	                if(transf[1] != 0)
1054
	                	shearY = transf[4] / transf[1];
1055
	                else
1056
	                	shearY = transf[4];
1057
	                
1058
	                //Aplicamos el shear a la vista
1059
	        		at.setToShear(-shearX, -shearY);
1060
	        		
1061
	        		//Escalamos en pixeles la misma cantidad que hemos le?do de m?s.  
1062
	        		at.scale(((double)wI/(double)wImg), ((double)hI/(double)hImg));
1063
	        			        		      			        		
1064
	        		g.transform(at);
1065
	        		
1066
	        		//Aplicamos el shear inverso al punto donde se comienza a dibujar
1067
	        		at.inverseTransform(pt, pt);
1068
	        		
1069
	        		g.drawImage(geoImage, (int) (pt.getX()), (int) (pt.getY()), component);
1070
	        		g.transform(at.createInverse());
1071
                }else
1072
                	g.drawImage(geoImage, (int) (pt.getX()), (int) (pt.getY()), component);
1073
                                
1074
                
855 1075
            } else { // no cargada
856 1076
                System.err.println("Dibujando PxRaster: Foto no cargada.");
857 1077
            }
trunk/libraries/libCq CMS for java.old/.cvsignore
1 1
doc-files
2 2
cms.jar
3 3
Thumbs.db
4
dist
4 5
bin-test
5 6

  
trunk/extensions/extGeoreferencing/src/org/gvsig/georeferencing/GeoOperations.java
181 181
	 * @param heightPx		Alto en pixeles de la imagen a georreferenciar
182 182
	 * @throws IOException
183 183
	 */
184
	private void serializeGeoreferencing(XmlSerializer serializer, double[] min, double[] max, int widthPx, int heightPx) throws IOException {
185
		double pixelSizeX = (max[0] - min[0])/(widthPx - 1);
186
		double pixelSizeY = (max[1] - min[1])/(heightPx - 1);
187
		
184
	private void serializeGeoreferencing(XmlSerializer serializer, double[] min, double[] max, int widthPx, int heightPx) throws IOException {		
188 185
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.PROJ).text("Projection").endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.PROJ).text("\n");
189 186
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.BBOX).text("\n");
190
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.POSX).text(""+min[0]).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.POSX).text("\n");
191
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.POSY).text(""+min[1]).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.POSY).text("\n");
192
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.ROTX).text(""+affine.getCofX(2)).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.ROTX).text("\n");
193
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.ROTY).text(""+affine.getCofY(1)).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.ROTY).text("\n");
194
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.PX_SIZE_X).text(""+pixelSizeX).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.PX_SIZE_X).text("\n");
195
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.PX_SIZE_Y).text(""+ pixelSizeY).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.PX_SIZE_Y).text("\n");		
187
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.POSX).text(""+affine.getCofX(0)).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.POSX).text("\n");
188
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.POSY).text(""+affine.getCofY(0)).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.POSY).text("\n");
189
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.ROTX).text(""+affine.getCofY(1)).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.ROTX).text("\n");
190
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.ROTY).text(""+affine.getCofX(2)).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.ROTY).text("\n");
191
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.PX_SIZE_X).text(""+affine.getCofX(1)).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.PX_SIZE_X).text("\n");
192
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.PX_SIZE_Y).text(""+ affine.getCofY(2)).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.PX_SIZE_Y).text("\n");		
196 193
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.WIDTH).text(""+(max[0] - min[0])).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.WIDTH).text("\n");
197 194
		serializer.startTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.HEIGHT).text(""+(max[1] - min[1])).endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.HEIGHT).text("\n");
198 195
		serializer.endTag(RasterMetaFileTags.NAMESPACE, RasterMetaFileTags.BBOX).text("\n");
trunk/extensions/extWCS/src/com/iver/cit/gvsig/fmap/layers/FLyrWCS.java
663 663
    	data.append((bBox.getMaxX() - bBox.getMinX())/(sz.getWidth() - 1)+"\n");
664 664
    	data.append("0.0\n");
665 665
    	data.append("0.0\n");
666
    	data.append((bBox.getMaxY() - bBox.getMinY())/(sz.getHeight() - 1)+"\n");
666
    	data.append("-"+(bBox.getMaxY() - bBox.getMinY())/(sz.getHeight() - 1)+"\n");
667 667
    	data.append(""+bBox.getMinX()+"\n");
668
    	data.append(""+bBox.getMinY()+"\n");
668
    	data.append(""+bBox.getMaxY()+"\n");
669 669
    	return data.toString();
670 670
	}
671 671

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff