Skip to content

Commit

Permalink
Don't allow selection of invisible features due to temporal filters
Browse files Browse the repository at this point in the history
Fixes #40818

(cherry picked from commit 7a3feac)
  • Loading branch information
nyalldawson committed Jan 15, 2021
1 parent 85ef809 commit 645b583
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/app/qgsmaptoolselectutils.cpp
Expand Up @@ -31,6 +31,7 @@ email : jpalmer at linz dot govt dot nz
#include "qgsproject.h"
#include "qgsexpressioncontextutils.h"
#include "qgsmessagelog.h"
#include "qgsvectorlayertemporalproperties.h"

#include <QMouseEvent>
#include <QApplication>
Expand Down Expand Up @@ -250,6 +251,17 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas,
r->startRender( context, vlayer->fields() );
}

QString temporalFilter;
if ( canvas->mapSettings().isTemporal() )
{
if ( !vlayer->temporalProperties()->isVisibleInTemporalRange( canvas->temporalRange() ) )
return newSelectedFeatures;

QgsVectorLayerTemporalContext temporalContext;
temporalContext.setLayer( vlayer );
temporalFilter = qobject_cast< const QgsVectorLayerTemporalProperties * >( vlayer->temporalProperties() )->createFilterString( temporalContext, canvas->temporalRange() );
}

QgsFeatureRequest request;
request.setFilterRect( selectGeomTrans.boundingBox() );
request.setFlags( QgsFeatureRequest::ExactIntersect );
Expand All @@ -258,6 +270,17 @@ QgsFeatureIds QgsMapToolSelectUtils::getMatchingFeatures( QgsMapCanvas *canvas,
else
request.setNoAttributes();

if ( !temporalFilter.isEmpty() )
request.setFilterExpression( temporalFilter );
if ( r )
{
const QString filterExpression = r->filter( vlayer->fields() );
if ( !filterExpression.isEmpty() )
{
request.combineFilterExpression( filterExpression );
}
}

QgsFeatureIterator fit = vlayer->getFeatures( request );

QgsFeature f;
Expand Down

0 comments on commit 645b583

Please sign in to comment.