Skip to content

Commit

Permalink
Fix broken select/identify by polygon when layer CRS <> canvas CRS
Browse files Browse the repository at this point in the history
Fixes #20786
  • Loading branch information
nyalldawson committed Dec 18, 2018
1 parent 7d648e5 commit 7c0b68a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/app/qgsmaptoolselectionhandler.cpp
Expand Up @@ -264,8 +264,10 @@ void QgsMapToolSelectionHandler::selectPolygonPressEvent( QgsMapMouseEvent *e )
auto vectorLayer = static_cast<QgsVectorLayer *>( layer );
if ( vectorLayer->geometryType() == QgsWkbTypes::PolygonGeometry )
{
QgsRectangle r = mCanvas->mapSettings().mapToLayerCoordinates( layer, QgsRectangle( x - sr, y - sr, x + sr, y + sr ) );
QgsFeatureIterator fit = vectorLayer->getFeatures( QgsFeatureRequest().setFilterRect( r ).setFlags( QgsFeatureRequest::ExactIntersect ) );
QgsFeatureIterator fit = vectorLayer->getFeatures( QgsFeatureRequest()
.setDestinationCrs( mCanvas->mapSettings().destinationCrs(), mCanvas->mapSettings().transformContext() )
.setFilterRect( QgsRectangle( x - sr, y - sr, x + sr, y + sr ) )
.setFlags( QgsFeatureRequest::ExactIntersect ) );
QgsFeature f;
while ( fit.nextFeature( f ) )
{
Expand Down

0 comments on commit 7c0b68a

Please sign in to comment.