Revision 10934

View differences:

trunk/extensions/extWMS/src/com/iver/cit/gvsig/fmap/layers/FLyrWMS.java
65 65
import java.util.Map;
66 66
import java.util.Vector;
67 67

  
68
import javax.imageio.ImageIO;
69 68
import javax.print.attribute.PrintRequestAttributeSet;
70 69
import javax.swing.ImageIcon;
71 70
import javax.swing.JOptionPane;
......
83 82
import org.gvsig.remoteClient.wms.WMSStatus;
84 83

  
85 84
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
85
import com.hardcode.gdbms.engine.data.driver.DriverException;
86 86
import com.iver.andami.PluginServices;
87 87
import com.iver.andami.messages.NotificationManager;
88 88
import com.iver.cit.gvsig.exceptions.layers.ConnectionErrorLayerException;
......
91 91
import com.iver.cit.gvsig.exceptions.layers.UnsupportedVersionLayerException;
92 92
import com.iver.cit.gvsig.exceptions.visitors.VisitorException;
93 93
import com.iver.cit.gvsig.fmap.ConnectionErrorExceptionType;
94
import com.iver.cit.gvsig.fmap.UnknownResponseFormatExceptionType;
95
import com.iver.cit.gvsig.fmap.UnsuportedProtocolVersionExceptionType;
96 94
import com.iver.cit.gvsig.fmap.ViewPort;
97 95
import com.iver.cit.gvsig.fmap.WMSDriverExceptionType;
98 96
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
......
100 98
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriverFactory;
101 99
import com.iver.cit.gvsig.fmap.drivers.wms.WMSException;
102 100
import com.iver.cit.gvsig.fmap.layers.WMSLayerNode.FMapWMSStyle;
101
import com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer;
103 102
import com.iver.cit.gvsig.fmap.layers.layerOperations.IHasImageLegend;
104 103
import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint;
105 104
import com.iver.cit.gvsig.fmap.layers.layerOperations.StringXMLItem;
......
546 545
				wmsStatus.setHeight(vp.getImageHeight());
547 546
				wmsStatus.setWidth(vp.getImageWidth());
548 547
				wmsStatus.setOnlineResource((String) onlineResources.get("GetFeatureInfo"));
548
				
549
				
550
				wmsStatus.setFormat( m_Format );
551
				wmsStatus.setLayerNames(Utilities.createVector(layerQuery,","));
552
				wmsStatus.setSrs(m_SRS);
553
				wmsStatus.setStyles(styles);
554
				wmsStatus.setDimensions(dimensions);
555
				wmsStatus.setTransparency(wmsTransparency);
556
				wmsStatus.setSrs(m_SRS);
549 557
				MyCancellable c = new MyCancellable(cancellable);
550 558
				item[0] = new StringXMLItem(new String(getDriver()
551 559
						.getFeatureInfo(wmsStatus, (int) tiledPoint.getX(), (int) tiledPoint.getY(), Integer.MAX_VALUE, c)),this);
......
1484 1492
     * @param styles
1485 1493
     */
1486 1494
    public void setStyles(Vector styles) {
1495
    	this.styles = styles;
1487 1496
    	//laura:
1488 1497
    	//layer query is built with the layer in reverse order
1489 1498
    	// so here we build the styles upside-down.
1490
    	if (styles != null)
1491
    	{
1492
    		this.styles = new Vector();
1493
    		for(int i = styles.size()-1; i>=0; i--)
1494
    		{
1495
    			this.styles.add(styles.elementAt(i));
1496
    		}
1497
    	}
1499
//    	if (styles != null)
1500
//    	{
1501
//    		this.styles = new Vector();
1502
//    		for(int i = styles.size()-1; i>=0; i--)
1503
//    		{
1504
//    			this.styles.add(styles.elementAt(i));
1505
//    		}
1506
//    	}
1498 1507
    }
1499 1508

  
1500 1509
    /**
......
1765 1774
		}
1766 1775
	}
1767 1776

  
1777
	/* (non-Javadoc)
1778
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#newComposedLayer()
1779
	 */
1780
	public ComposedLayer newComposedLayer() {		
1781
		return new ComposedLayerWMS();
1782
//		return null;
1783
	}
1784
	
1785
    /**
1786
     * @param styles
1787
     */
1788
    public Vector getStyles() {
1789
    	return this.styles;
1790
    }
1791
	
1792
	
1793
	/* Checks if can make a single petition for
1794
	 * the two layers to the server
1795
	 *   
1796
	 * @see com.iver.cit.gvsig.fmap.layers.ComposedLayerWMS#canAdd(com.iver.cit.gvsig.fmap.layers.FLayer)
1797
	 */
1798
    boolean isComposedLayerCompatible(FLayer layer) {
1799
		FLyrWMS aLayer;
1800
		
1801
		if (!(layer instanceof FLyrWMS)) {
1802
			return false;
1803
		}
1804
		aLayer = (FLyrWMS)layer;
1805
		if (!this.getHost().equals(aLayer.getHost())) {
1806
			return false;
1807
		}
1808
		if (!this.getFormat().equals(aLayer.getFormat())) {
1809
			return false;
1810
		}
1811
		if (!this.getSRS().equals(aLayer.getSRS())) {
1812
			return false;
1813
		}
1814
		if (this.getInfoLayerQuery() != null) {
1815
			if (!this.getInfoLayerQuery().equals(aLayer.getInfoLayerQuery())) {
1816
				return false;
1817
			}
1818
		}else if (aLayer.getInfoLayerQuery() != null) {
1819
			return false;
1820
		}
1821
		
1822
		
1823
		// isFixedSize es privado		
1824
		if ((this.fixedSize != null) && 
1825
				(aLayer.fixedSize!= null)) {
1826
			if (this.fixedSize.equals(aLayer.fixedSize)) {
1827
				return false;
1828
			}
1829
		} else if ((this.fixedSize != null) != (aLayer.fixedSize != null)) {
1830
			return false;
1831
		}
1832
		
1833
		// time elevation (dimensions)
1834
		if ((this.dimensions != null) && 
1835
				(aLayer.dimensions != null)) {
1836
			if (this.dimensions.size() != aLayer.dimensions.size()) {
1837
				return false;
1838
			} else {
1839
				Iterator iter = this.dimensions.iterator();
1840
				while (iter.hasNext()) {
1841
					if (!aLayer.dimensions.contains(iter.next())) {
1842
						return false;
1843
					}
1844
				}
1845
			}
1768 1846

  
1847
		} else if ((this.dimensions != null) != (aLayer.dimensions != null)) {
1848
			return false;
1849
		}
1850
		
1851
		
1852
		return true;
1853

  
1854
	}
1855
    
1769 1856
}
trunk/extensions/extWMS/src/com/iver/cit/gvsig/fmap/layers/ComposedLayerWMS.java
1
/**
2
 * 
3
 */
4
package com.iver.cit.gvsig.fmap.layers;
5

  
6
import java.awt.Graphics2D;
7
import java.awt.image.BufferedImage;
8
import java.util.Vector;
9

  
10
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
11
import com.iver.cit.gvsig.fmap.ViewPort;
12
import com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer;
13
import com.iver.utiles.swing.threads.Cancellable;
14

  
15
/**
16
 * Group WMS layers for make a single petition to the
17
 * server for all layers.
18
 * 
19
 * It is posible only if almost all params are the same. For this
20
 * comparasion, ComposedLayerWMS uses the method 
21
 * {@link com.iver.cit.gvsig.fmap.layers.FLyrWMS#isComposedLayerCompatible(com.iver.cit.gvsig.fmap.layers.FLayer)}
22
 * 
23
 * 
24
 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer
25
 * @see com.iver.cit.gvsig.fmap.layers.FLyrWMS
26
 */
27
public class ComposedLayerWMS implements ComposedLayer {
28
	private FLyrWMS layer=null;
29

  
30
	/* (non-Javadoc)
31
	 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer#canAdd(com.iver.cit.gvsig.fmap.layers.FLayer)
32
	 */
33
	public boolean canAdd(FLayer layer) {
34
		if (this.layer != null) {
35
			return this.layer.isComposedLayerCompatible(layer);
36
		}
37
		return false;
38
	}
39

  
40
	/* (non-Javadoc)
41
	 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer#add(com.iver.cit.gvsig.fmap.layers.FLayer)
42
	 */
43
	public void add(FLayer layer) throws Exception {
44
		FLyrWMS aLayer =(FLyrWMS)layer;
45
		if (this.layer == null) {
46
			this.layer = new FLyrWMS();
47
			this.layer.setXMLEntity(aLayer.getXMLEntity());
48
			return;
49
		}			
50
		this.layer.setLayerQuery( this.layer.getLayerQuery() + ","+ aLayer.getLayerQuery());
51
		Vector aStyles = aLayer.getStyles();
52
		
53
		if (aStyles != null) {
54
			Vector myStyles = this.layer.getStyles();
55
			if (myStyles == null) {
56
				this.layer.setStyles(aStyles);
57
			} else {
58
				myStyles.addAll(aStyles);
59
				this.layer.setStyles(myStyles);
60
			}
61
		}
62
		
63
		//revisar el fullextend para ajustarlo a todas las capas
64
		this.layer.getFullExtent().add(aLayer.getFullExtent());
65

  
66
	}
67

  
68
	/* (non-Javadoc)
69
	 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.utiles.swing.threads.Cancellable, double)
70
	 */
71
	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
72
			Cancellable cancel, double scale) throws ReadDriverException {
73
		this.layer.draw(image,g,viewPort,cancel,scale);
74
	}
75

  
76
}
0 77

  

Also available in: Unified diff