Skip to content

Commit

Permalink
Fix the show visible feature(s) action with reprojected layers
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jul 10, 2023
1 parent df2bfc0 commit 1c5f416
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/core/multifeaturelistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,26 @@ void MultiFeatureListModel::setFeatures( QgsVectorLayer *vl, const QString &filt
}
if ( !extent.isEmpty() )
{
request.setFilterRect( extent );
QgsRectangle filterExtent = extent;
if ( QgsProject::instance()->crs() != vl->crs() )
{
QgsCoordinateTransform transform( QgsProject::instance()->crs(), vl->crs(), QgsProject::instance()->transformContext() );
try
{
filterExtent = transform.transform( extent );
}
catch ( const QgsException &e )
{
Q_UNUSED( e )
return;
}
catch ( ... )
{
// catch any other errors
return;
}
}
request.setFilterRect( filterExtent );
}
QMap<QgsVectorLayer *, QgsFeatureRequest> requests( { { vl, request } } );
mSourceModel->setFeatures( requests );
Expand Down

1 comment on commit 1c5f416

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.