Skip to content
Permalink
Browse files

IndexExtent fix

This fixes a problem with the "IndexExtent" snapping indexing strategy.
I got a strange behaviour where all indexes were continuously rebuilt
when the mouse was close to the mapcanvas border.

Proposed solution:
- use QgsMapSettings::visibleExtent() instead of
QgsMapSettings::extent() for the definition of the index extent
- do not try to index features that are beyond the current extent
  • Loading branch information
Hugo Mercier
Hugo Mercier committed Jan 14, 2019
1 parent c263750 commit 63429686cf72cde49a9574b87d9a2d617b28ceb8
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/core/qgssnappingutils.cpp
@@ -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 )
@@ -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();
}

0 comments on commit 6342968

Please sign in to comment.
You can’t perform that action at this time.