Revision 3901

View differences:

branches/v05/extensions/extWMS/src/com/iver/cit/gvsig/fmap/drivers/wms/FMapWMSDriver.java
140 140
	 * @throws UnsupportedVersionException
141 141
	 * @throws IOException
142 142
	 */
143
	private WMSClient getClient(URL url) throws ConnectException, IOException {
143
	public WMSClient getClient(URL url) throws ConnectException, IOException {
144 144
		if (client == null) {
145 145
			client = new WMSClient(url.toString());
146 146
		}
branches/v05/extensions/extWMS/src/com/iver/cit/gvsig/fmap/layers/FLyrWMS.java
40 40
*/
41 41
package com.iver.cit.gvsig.fmap.layers;
42 42

  
43
import java.awt.Component;
44
import java.awt.Dimension;
45 43
import java.awt.Graphics2D;
46 44
import java.awt.Point;
47 45
import java.awt.Rectangle;
......
63 61
import java.net.URL;
64 62
import java.util.ArrayList;
65 63
import java.util.HashMap;
66
import java.util.Hashtable;
67 64
import java.util.Vector;
68 65

  
69
import javax.swing.JOptionPane;
70

  
71 66
import org.cresques.geo.ViewPortData;
72 67
import org.cresques.io.GdalFile;
73 68
import org.cresques.io.GeoRasterFile;
......
80 75
import org.gvsig.remoteClient.wms.WMSStatus;
81 76

  
82 77
import com.devx.io.TempFileManager;
83
import com.iver.andami.PluginServices;
84 78
import com.iver.cit.gvsig.fmap.DriverException;
85 79
import com.iver.cit.gvsig.fmap.ViewPort;
86 80
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
......
89 83
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver;
90 84
import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint;
91 85
import com.iver.cit.gvsig.fmap.operations.Cancellable;
92
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities;
93 86
import com.iver.utiles.StringUtilities;
94 87
import com.iver.utiles.XMLEntity;
95 88

  
......
353 346
			
354 347
		}
355 348
	}
356
	
357
	/*public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
358
			Cancellable cancel,double scale) throws DriverException {
359
		if (isWithinScale(scale)){	
360
	        _draw(null, g, viewPort, cancel,scale);
361
		}
362
	}*/
363
	
349
		
364 350
	/**
365 351
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#draw(java.awt.image.BufferedImage,
366 352
	 * 		java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort,
......
382 368
				wmsStatus.setStyles(styles);
383 369
                wmsStatus.setDimensions(dimensions);
384 370
                wmsStatus.setTransparency(wmsTransparency);
385
				if (wmsPreviousStatus == null || !wmsPreviousStatus.equals(wmsStatus)){
386
                    wmsPreviousStatus = (WMSStatus) wmsStatus.clone();
387
                    // TODO eliminar bytes y usar directamente ficheros
388
				    bytes = getDriver().getMap(wmsStatus);
389
				}
390
				ByteArrayInputStream inbytes = new ByteArrayInputStream(bytes);
391
				//BufferedImage tempImg = ImageIO.read(inbytes);
392
				// LWS Cambio de estrategia en el posicionado para la impresi?n.
393
				Point2D p2=new Point2D.Double(viewPort.getAdjustedExtent().getX(), viewPort.getAdjustedExtent().getMaxY()); //viewPort.getOffset();
371
                
372
                Point2D p2=new Point2D.Double(viewPort.getAdjustedExtent().getX(), viewPort.getAdjustedExtent().getMaxY()); //viewPort.getOffset();
394 373
				viewPort.getAffineTransform().transform(p2, p2);
395
				// g.drawImage(tempImg,(int)p2.getX(),(int)p2.getY(), null);
396
				rasterProcess(g, viewPort, createTemp(inbytes, "wms_Query", viewPort));
374
				URL request = new URL(getDriver().getClient(null).getHandler().buildMapRequest(wmsStatus));
375
				File f = com.iver.andami.Utilities.downloadFile(request, "wmsDownload");
376
				String nameWordFile = f.getPath() + getExtensionWordFile();
377
				com.iver.andami.Utilities.createTemp(nameWordFile, this.getDataWordFile(viewPort));
378
				rasterProcess(g, viewPort, f);
379
								
397 380
				if(status!=null && firstLoad){
398 381
					status.applyStatus(this);
399 382
					firstLoad = false;
......
407 390
			throw new DriverException("Conflicto de versiones", e);
408 391
		} catch (IOException e) {
409 392
			throw new DriverException("Error en la conexi?n", e);
410
		} catch (WMSException e) {
393
		} /*catch (WMSException e) {
411 394
            JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), e.getMessage());
412 395
			this.setVisible(false);
413 396
            wmsPreviousStatus = null;
414
		}
397
		}*/
415 398
		
416 399
	}
417 400
	
418 401
	/**
402
	 * Obtiene la extensi?n del fichero de georreferenciaci?n
403
	 * @return String con la extensi?n del fichero de georreferenciaci?n dependiendo
404
	 * del valor del formato obtenido del servidor. Por defecto asignaremos un .wld 
405
	 */
406
	private String getExtensionWordFile(){
407
		String extWorldFile = ".wld";
408
    	if(m_Format.equals("image/tif") || m_Format.equals("image/tiff"))
409
    		extWorldFile = ".tfw";
410
    	if(m_Format.equals("image/jpeg"))
411
    		extWorldFile = ".jpgw";
412
    	return extWorldFile;
413
	}
414
	
415
	/**
416
	 * Obtiene el contenido del fichero de georreferenciaci?n
417
	 * @param vp ViewPort para el calculo de los datos de georreferenciaci?n.
418
	 * @return datos del fichero world file
419
	 * @throws IOException
420
	 */
421
	public String getDataWordFile(ViewPort vp) throws IOException{
422
    	StringBuffer data = new StringBuffer();
423
    	data.append((vp.getAdjustedExtent().getMaxX() - vp.getAdjustedExtent().getMinX())/(vp.getImageWidth() - 1)+"\n");
424
    	data.append("0.0\n");
425
    	data.append("0.0\n");
426
    	data.append((vp.getAdjustedExtent().getMaxY() - vp.getAdjustedExtent().getMinY())/(vp.getImageHeight() - 1)+"\n");
427
    	data.append(""+vp.getAdjustedExtent().getMinX()+"\n");
428
    	data.append(""+vp.getAdjustedExtent().getMinY()+"\n");
429
    	return data.toString();
430
	}
431
	
432
	/**
419 433
	 * Crea un fichero temporal con los datos obtenidos
420 434
	 * @param img
421 435
	 * @param name
422 436
	 * @return
423 437
	 * @throws IOException
424 438
	 */
425
	public File createTemp(ByteArrayInputStream is, String name, ViewPort vp) throws IOException{
439
	/*public File createTemp(ByteArrayInputStream is, String name, ViewPort vp) throws IOException{
426 440
    	File f = null;
427 441
    	File tfw = null;
428 442
	    try{
......
461 475
	    }
462 476
	    bos.close();
463 477
	    return f;
464
	}
478
	}*/
465 479
		
466 480
	/**
467 481
	 * Draws using PxRaster

Also available in: Unified diff