Skip to content

Commit 2e6c8dd

Browse files
author
mhugent
committed
Fix for ticket #562 small bug in WMS getFeatureInfo handling
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6986 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5e1ec04 commit 2e6c8dd

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/app/qgsmaptoolidentify.cpp

+38-1
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,45 @@ void QgsMapToolIdentify::identifyRasterWmsLayer(QgsRasterLayer* layer, const Qgs
165165
return;
166166
}
167167

168-
QString text = layer->identifyAsText(point);
168+
//if WMS layer does not cover the view origin,
169+
//we need to map the view pixel coordinates
170+
//to WMS layer pixel coordinates
171+
QgsRect viewExtent = mCanvas->extent();
172+
double mupp = mCanvas->mupp();
173+
if(mupp == 0)
174+
{
175+
return;
176+
}
177+
double xMinView = viewExtent.xMin();
178+
double yMaxView = viewExtent.yMax();
179+
180+
QgsRect layerExtent = layer->extent();
181+
double xMinLayer = layerExtent.xMin();
182+
double yMaxLayer = layerExtent.yMax();
183+
184+
double i, j;
185+
186+
if(xMinView < xMinLayer)
187+
{
188+
i = (int)(point.x() - (xMinLayer - xMinView) / mupp);
189+
}
190+
else
191+
{
192+
i = point.x();
193+
}
169194

195+
if(yMaxView > yMaxLayer)
196+
{
197+
j = (int)(point.y() - (yMaxView - yMaxLayer) / mupp);
198+
}
199+
else
200+
{
201+
j = point.y();
202+
}
203+
204+
205+
QString text = layer->identifyAsText(QgsPoint(i, j));
206+
170207
if (text.isEmpty())
171208
{
172209
showError(layer);

0 commit comments

Comments
 (0)