Revision 30187 branches/v2_0_0_prep/extensions/extWMS/src/org/gvsig/wms/fmap/layers/FLyrWMS.java

View differences:

FLyrWMS.java
40 40
*/
41 41
package org.gvsig.wms.fmap.layers;
42 42

  
43
import java.awt.Component;
44 43
import java.awt.Dimension;
45 44
import java.awt.Graphics2D;
46 45
import java.awt.Image;
......
69 68

  
70 69
import javax.print.attribute.PrintRequestAttributeSet;
71 70
import javax.swing.ImageIcon;
72
import javax.swing.JOptionPane;
73 71

  
74 72
import org.cresques.cts.ICoordTrans;
75 73
import org.cresques.geo.ViewPortData;
......
78 76
import org.gvsig.andami.PluginServices;
79 77
import org.gvsig.andami.messages.NotificationManager;
80 78
import org.gvsig.fmap.crs.CRSFactory;
79
import org.gvsig.fmap.dal.exception.DataException;
81 80
import org.gvsig.fmap.dal.exception.ReadException;
82 81
import org.gvsig.fmap.geom.GeometryLocator;
83 82
import org.gvsig.fmap.geom.GeometryManager;
......
89 88
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
90 89
import org.gvsig.fmap.mapcontext.exceptions.URLLayerException;
91 90
import org.gvsig.fmap.mapcontext.exceptions.UnsupportedVersionLayerException;
92
import org.gvsig.fmap.mapcontext.exceptions.XMLLayerException;
93 91
import org.gvsig.fmap.mapcontext.layers.FLayer;
94 92
import org.gvsig.fmap.mapcontext.layers.Tiling;
95 93
import org.gvsig.fmap.mapcontext.layers.operations.ComposedLayer;
96 94
import org.gvsig.fmap.mapcontext.layers.operations.IHasImageLegend;
97
import org.gvsig.fmap.mapcontext.layers.operations.StringXMLItem;
98
import org.gvsig.fmap.mapcontext.layers.operations.XMLItem;
99 95
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
100 96
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
101 97
import org.gvsig.fmap.raster.layers.IRasterLayerActions;
......
580 576
		firstLoad = true;
581 577
	}
582 578

  
583
	/**
584
	 * @throws ReadDriverException
585
	 * @throws LoadLayerException
586
	 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#queryByPoint(com.iver.cit.gvsig.fmap.operations.QueriedPoint)
587
	 */
588
	public XMLItem[] getInfo(Point p, double tolerance, Cancellable cancellable)
589
			throws ReadException {
590
		XMLItem[] item = new XMLItem[1];
591
		try {
592
			if (queryable) 	{
593
				//TODO
594
				// check if there are layers which are not queryable
595
				ViewPort viewPort = getMapContext().getViewPort();
579
//	/**
580
//	 * @throws ReadDriverException
581
//	 * @throws LoadLayerException
582
//	 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#queryByPoint(com.iver.cit.gvsig.fmap.operations.QueriedPoint)
583
//	 */
584
//	public XMLItem[] getInfo(Point p, double tolerance, Cancellable cancellable)
585
//			throws ReadException {
586
//		XMLItem[] item = new XMLItem[1];
587
//		try {
588
//			if (queryable) 	{
589
//				//TODO
590
//				// check if there are layers which are not queryable
591
//				ViewPort viewPort = getMapContext().getViewPort();
592
//
593
//				Point tiledPoint = new Point((int) p.getX() % maxTilePrintWidth, (int) p.getY() % maxTilePrintHeight);
594
//				Rectangle rect = new Rectangle(0, 0, viewPort.getImageWidth() - 1, viewPort.getImageHeight() - 1);
595
//				Tiling tiles = new Tiling(maxTilePrintWidth, maxTilePrintHeight, rect);
596
//				tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
597
//				int nCols = tiles.getNumCols();
598
//
599
//				int col = (int) p.getX() / maxTilePrintWidth;
600
//				int row = (int) p.getY() / maxTilePrintHeight;
601
//				int tileIndex = (row*nCols) + col;
602
//
603
//				ViewPort vp = tiles.getTileViewPort(viewPort, tileIndex);
604
//				wmsStatus.setExtent(this.getRectable2DFromEnvelope(vp
605
//						.getAdjustedExtent()));
606
//				wmsStatus.setHeight(vp.getImageHeight());
607
//				wmsStatus.setWidth(vp.getImageWidth());
608
//				wmsStatus.setOnlineResource((String) onlineResources.get("GetFeatureInfo"));
609
//
610
//
611
//				wmsStatus.setFormat( m_Format );
612
//				wmsStatus.setLayerNames(Utilities.createVector(layerQuery,","));
613
//				wmsStatus.setSrs(m_SRS);
614
//				wmsStatus.setStyles(styles);
615
//				wmsStatus.setDimensions(dimensions);
616
//				wmsStatus.setTransparency(wmsTransparency);
617
//				wmsStatus.setSrs(m_SRS);
618
//				MyCancellable c = new MyCancellable(cancellable);
619
//				try {
620
//					item[0] = new StringXMLItem(new String(getDriver()
621
//							.getFeatureInfo(wmsStatus, (int) tiledPoint.getX(), (int) tiledPoint.getY(), Integer.MAX_VALUE, c)),this);
622
//				} catch (UnsupportedVersionLayerException e) {
623
//					throw new ReadException(FMapWMSDriver.class.getName()
624
//							+ "::" + getName()
625
//							+ " - UnsupportedVersionLayerException", e);
626
//				} catch (IllegalStateException e) {
627
//					throw new ReadException(FMapWMSDriver.class.getName()
628
//							+ "::" + getName() + " - IllegalStateException", e);
629
//				}
630
//				return item;
631
//			}
632
//			else
633
//			{
634
//				JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),this.getName() + " " +
635
//						PluginServices.getText(this,"layer_not_queryable"));
636
//				item[0] =  new StringXMLItem("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><info></info>",this);
637
//				return item;
638
//				//return null;
639
//			}
640
//		} catch (WMSException  e) {
641
//			item[0] = new StringXMLItem("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><exception>" +
642
//			e.getMessage() + "</exception>", this);
643
//			return item;
644
//		} catch (ValidationException e) {
645
//			throw new ReadException(FMapWMSDriver.class.getName() + "::"
646
//					+ getName() + " - ValidationException", e);
647
//		} catch (IOException e) {
648
//			throw new ReadException(FMapWMSDriver.class.getName() + "::"
649
//					+ getName() + " - IOException", e);
650
//		} catch (NoninvertibleTransformException e) {
651
//			NotificationManager.addError("NotinvertibleTransform", e);
652
//		}
653
//		return null;
654
//	}
596 655

  
597
				Point tiledPoint = new Point((int) p.getX() % maxTilePrintWidth, (int) p.getY() % maxTilePrintHeight);
598
				Rectangle rect = new Rectangle(0, 0, viewPort.getImageWidth() - 1, viewPort.getImageHeight() - 1);
599
				Tiling tiles = new Tiling(maxTilePrintWidth, maxTilePrintHeight, rect);
600
				tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
601
				int nCols = tiles.getNumCols();
602

  
603
				int col = (int) p.getX() / maxTilePrintWidth;
604
				int row = (int) p.getY() / maxTilePrintHeight;
605
				int tileIndex = (row*nCols) + col;
606

  
607
				ViewPort vp = tiles.getTileViewPort(viewPort, tileIndex);
608
				wmsStatus.setExtent(this.getRectable2DFromEnvelope(vp
609
						.getAdjustedExtent()));
610
				wmsStatus.setHeight(vp.getImageHeight());
611
				wmsStatus.setWidth(vp.getImageWidth());
612
				wmsStatus.setOnlineResource((String) onlineResources.get("GetFeatureInfo"));
613

  
614

  
615
				wmsStatus.setFormat( m_Format );
616
				wmsStatus.setLayerNames(Utilities.createVector(layerQuery,","));
617
				wmsStatus.setSrs(m_SRS);
618
				wmsStatus.setStyles(styles);
619
				wmsStatus.setDimensions(dimensions);
620
				wmsStatus.setTransparency(wmsTransparency);
621
				wmsStatus.setSrs(m_SRS);
622
				MyCancellable c = new MyCancellable(cancellable);
623
				try {
624
					item[0] = new StringXMLItem(new String(getDriver()
625
							.getFeatureInfo(wmsStatus, (int) tiledPoint.getX(), (int) tiledPoint.getY(), Integer.MAX_VALUE, c)),this);
626
				} catch (UnsupportedVersionLayerException e) {
627
					throw new ReadException(FMapWMSDriver.class.getName()
628
							+ "::" + getName()
629
							+ " - UnsupportedVersionLayerException", e);
630
				} catch (IllegalStateException e) {
631
					throw new ReadException(FMapWMSDriver.class.getName()
632
							+ "::" + getName() + " - IllegalStateException", e);
633
				}
634
				return item;
635
			}
636
			else
637
			{
638
				JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),this.getName() + " " +
639
						PluginServices.getText(this,"layer_not_queryable"));
640
				item[0] =  new StringXMLItem("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><info></info>",this);
641
				return item;
642
				//return null;
643
			}
644
		} catch (WMSException  e) {
645
			item[0] = new StringXMLItem("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><exception>" +
646
			e.getMessage() + "</exception>", this);
647
			return item;
648
		} catch (ValidationException e) {
649
			throw new ReadException(FMapWMSDriver.class.getName() + "::"
650
					+ getName() + " - ValidationException", e);
651
		} catch (IOException e) {
652
			throw new ReadException(FMapWMSDriver.class.getName() + "::"
653
					+ getName() + " - IOException", e);
654
		} catch (NoninvertibleTransformException e) {
655
			NotificationManager.addError("NotinvertibleTransform", e);
656
		}
657
		return null;
658
	}
659

  
660 656
	/*
661 657
	 *
662 658
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#draw(java.awt.image.BufferedImage,
......
2153 2149
		}
2154 2150
		return null;
2155 2151
	}
2152
	
2153
	public Iterator getInfo(Point p, double tolerance, Cancellable cancel)
2154
		throws LoadLayerException, DataException {
2155
		// TODO Auto-generated method stub
2156
//		XMLItem[] item = new XMLItem[1];
2157
//		try {
2158
//			if (queryable) 	{
2159
//				//TODO
2160
//				// check if there are layers which are not queryable
2161
//				ViewPort viewPort = getMapContext().getViewPort();
2162
//
2163
//				Point tiledPoint = new Point((int) p.getX() % maxTilePrintWidth, (int) p.getY() % maxTilePrintHeight);
2164
//				Rectangle rect = new Rectangle(0, 0, viewPort.getImageWidth() - 1, viewPort.getImageHeight() - 1);
2165
//				Tiling tiles = new Tiling(maxTilePrintWidth, maxTilePrintHeight, rect);
2166
//				tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone());
2167
//				int nCols = tiles.getNumCols();
2168
//
2169
//				int col = (int) p.getX() / maxTilePrintWidth;
2170
//				int row = (int) p.getY() / maxTilePrintHeight;
2171
//				int tileIndex = (row*nCols) + col;
2172
//
2173
//				ViewPort vp = tiles.getTileViewPort(viewPort, tileIndex);
2174
//				wmsStatus.setExtent(this.getRectable2DFromEnvelope(vp
2175
//						.getAdjustedExtent()));
2176
//				wmsStatus.setHeight(vp.getImageHeight());
2177
//				wmsStatus.setWidth(vp.getImageWidth());
2178
//				wmsStatus.setOnlineResource((String) onlineResources.get("GetFeatureInfo"));
2179
//
2180
//
2181
//				wmsStatus.setFormat( m_Format );
2182
//				wmsStatus.setLayerNames(Utilities.createVector(layerQuery,","));
2183
//				wmsStatus.setSrs(m_SRS);
2184
//				wmsStatus.setStyles(styles);
2185
//				wmsStatus.setDimensions(dimensions);
2186
//				wmsStatus.setTransparency(wmsTransparency);
2187
//				wmsStatus.setSrs(m_SRS);
2188
//				MyCancellable c = new MyCancellable(cancellable);
2189
//				try {
2190
//					item[0] = new StringXMLItem(new String(getDriver()
2191
//							.getFeatureInfo(wmsStatus, (int) tiledPoint.getX(), (int) tiledPoint.getY(), Integer.MAX_VALUE, c)),this);
2192
//				} catch (UnsupportedVersionLayerException e) {
2193
//					throw new ReadException(FMapWMSDriver.class.getName()
2194
//							+ "::" + getName()
2195
//							+ " - UnsupportedVersionLayerException", e);
2196
//				} catch (IllegalStateException e) {
2197
//					throw new ReadException(FMapWMSDriver.class.getName()
2198
//							+ "::" + getName() + " - IllegalStateException", e);
2199
//				}
2200
//				return item;
2201
//			}
2202
//			else
2203
//			{
2204
//				JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),this.getName() + " " +
2205
//						PluginServices.getText(this,"layer_not_queryable"));
2206
//				item[0] =  new StringXMLItem("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><info></info>",this);
2207
//				return item;
2208
//				//return null;
2209
//			}
2210
//		} catch (WMSException  e) {
2211
//			item[0] = new StringXMLItem("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><exception>" +
2212
//			e.getMessage() + "</exception>", this);
2213
//			return item;
2214
//		} catch (ValidationException e) {
2215
//			throw new ReadException(FMapWMSDriver.class.getName() + "::"
2216
//					+ getName() + " - ValidationException", e);
2217
//		} catch (IOException e) {
2218
//			throw new ReadException(FMapWMSDriver.class.getName() + "::"
2219
//					+ getName() + " - IOException", e);
2220
//		} catch (NoninvertibleTransformException e) {
2221
//			NotificationManager.addError("NotinvertibleTransform", e);
2222
//		}
2223
//		return null;
2224
		return null;
2225
	}
2156 2226

  
2157 2227
}

Also available in: Unified diff