Skip to content

Commit

Permalink
Merge pull request #8852 from mhugo/fix_index_extent
Browse files Browse the repository at this point in the history
IndexExtent fix
  • Loading branch information
Hugo Mercier authored Jan 18, 2019
2 parents eb256e9 + 6342968 commit cd1f316
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/qgssnappingutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ bool QgsSnappingUtils::isIndexPrepared( QgsVectorLayer *vl, const QgsRectangle &
if ( mStrategy == IndexAlwaysFull && loc->hasIndex() )
return true;

if ( mStrategy == IndexExtent && loc->hasIndex() && loc->extent()->intersects( areaOfInterest ) )
return true;

QgsRectangle aoi( areaOfInterest );
aoi.scale( 0.999 );
return ( mStrategy == IndexHybrid || mStrategy == IndexExtent ) && loc->hasIndex() && ( !loc->extent() || loc->extent()->contains( aoi ) ); // the index - even if it exists - is not suitable
return mStrategy == IndexHybrid && loc->hasIndex() && ( !loc->extent() || loc->extent()->contains( aoi ) ); // the index - even if it exists - is not suitable
}

static QgsPointLocator::Match _findClosestSegmentIntersection( const QgsPointXY &pt, const QgsPointLocator::MatchList &segments )
Expand Down Expand Up @@ -370,7 +373,7 @@ void QgsSnappingUtils::prepareIndex( const QList<LayerAndAreaOfInterest> &layers

if ( mStrategy == IndexExtent )
{
QgsRectangle rect( mMapSettings.extent() );
QgsRectangle rect( mMapSettings.visibleExtent() );
loc->setExtent( &rect );
loc->init();
}
Expand Down

0 comments on commit cd1f316

Please sign in to comment.