Skip to content

Commit 9daa61b

Browse files
committedJan 1, 2017
allow limiting snapping to a given area
(cherry picked from commit c6fb253)
1 parent 84cdbff commit 9daa61b

File tree

6 files changed

+25
-14
lines changed

6 files changed

+25
-14
lines changed
 

‎python/core/qgssnappingutils.sip

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ class QgsSnappingUtils : QObject
5151
{
5252
IndexAlwaysFull, //!< For all layers build index of full extent. Uses more memory, but queries are faster.
5353
IndexNeverFull, //!< For all layers only create temporary indexes of small extent. Low memory usage, slower queries.
54-
IndexHybrid //!< For "big" layers using IndexNeverFull, for the rest IndexAlwaysFull. Compromise between speed and memory usage.
54+
IndexHybrid, //!< For "big" layers using IndexNeverFull, for the rest IndexAlwaysFull. Compromise between speed and memory usage.
55+
IndexExtent //!< For all layer build index of extent given in map settings
5556
};
5657

5758
/** Set a strategy for indexing geometry data - determines how fast and memory consuming the data structures will be */

‎src/core/qgspointlocator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ QgsPointLocator::Match QgsPointLocator::nearestVertex( const QgsPoint& point, do
848848
QgsRectangle rect( point.x() - tolerance, point.y() - tolerance, point.x() + tolerance, point.y() + tolerance );
849849
mRTree->intersectsWithQuery( rect2region( rect ), visitor );
850850
if ( m.isValid() && m.distance() > tolerance )
851-
return Match(); // // make sure that only match strictly within the tolerance is returned
851+
return Match(); // make sure that only match strictly within the tolerance is returned
852852
return m;
853853
}
854854

@@ -870,7 +870,7 @@ QgsPointLocator::Match QgsPointLocator::nearestEdge( const QgsPoint& point, doub
870870
QgsRectangle rect( point.x() - tolerance, point.y() - tolerance, point.x() + tolerance, point.y() + tolerance );
871871
mRTree->intersectsWithQuery( rect2region( rect ), visitor );
872872
if ( m.isValid() && m.distance() > tolerance )
873-
return Match(); // // make sure that only match strictly within the tolerance is returned
873+
return Match(); // make sure that only match strictly within the tolerance is returned
874874
return m;
875875
}
876876

‎src/core/qgssnappingutils.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ bool QgsSnappingUtils::isIndexPrepared( QgsVectorLayer* vl, const QgsRectangle&
9999
if ( mStrategy == IndexAlwaysFull && loc->hasIndex() )
100100
return true;
101101

102-
if ( mStrategy == IndexHybrid && loc->hasIndex() && ( !loc->extent() || loc->extent()->contains( areaOfInterest ) ) )
102+
QgsRectangle aoi( areaOfInterest );
103+
aoi.scale( 0.999 );
104+
if (( mStrategy == IndexHybrid || mStrategy == IndexExtent ) && loc->hasIndex() && ( !loc->extent() || loc->extent()->contains( aoi ) ) )
103105
return true;
104106

105107
return false; // the index - even if it exists - is not suitable
@@ -349,7 +351,13 @@ void QgsSnappingUtils::prepareIndex( const QList<LayerAndAreaOfInterest>& layers
349351
QTime tt;
350352
tt.start();
351353
QgsPointLocator* loc = locatorForLayer( vl );
352-
if ( mStrategy == IndexHybrid )
354+
if ( mStrategy == IndexExtent )
355+
{
356+
QgsRectangle rect( mMapSettings.extent() );
357+
loc->setExtent( &rect );
358+
loc->init();
359+
}
360+
else if ( mStrategy == IndexHybrid )
353361
{
354362
// first time the layer is used? - let's set an initial guess about indexing
355363
if ( !mHybridMaxAreaPerLayer.contains( vl->id() ) )
@@ -533,7 +541,7 @@ QString QgsSnappingUtils::dump()
533541
.arg( layer.layer->name() )
534542
.arg( layer.type ).arg( layer.tolerance ).arg( layer.unit );
535543

536-
if ( mStrategy == IndexAlwaysFull || mStrategy == IndexHybrid )
544+
if ( mStrategy == IndexAlwaysFull || mStrategy == IndexHybrid || mStrategy == IndexExtent )
537545
{
538546
if ( QgsPointLocator* loc = locatorForLayer( layer.layer ) )
539547
{

‎src/core/qgssnappingutils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ class CORE_EXPORT QgsSnappingUtils : public QObject
8888
{
8989
IndexAlwaysFull, //!< For all layers build index of full extent. Uses more memory, but queries are faster.
9090
IndexNeverFull, //!< For all layers only create temporary indexes of small extent. Low memory usage, slower queries.
91-
IndexHybrid //!< For "big" layers using IndexNeverFull, for the rest IndexAlwaysFull. Compromise between speed and memory usage.
91+
IndexHybrid, //!< For "big" layers using IndexNeverFull, for the rest IndexAlwaysFull. Compromise between speed and memory usage.
92+
IndexExtent //!< For all layer build index of extent given in map settings
9293
};
9394

9495
/** Set a strategy for indexing geometry data - determines how fast and memory consuming the data structures will be */

‎src/core/symbology-ng/qgscptcityarchive.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,13 +1084,15 @@ QMap< QString, QStringList > QgsCptCityDirectoryItem::rampsMap()
10841084
}
10851085

10861086
}
1087+
#if 0
10871088
//TODO what to do with other vars? e.g. schemeNames
1088-
// // add schemes to archive
1089-
// mSchemeMap[ path ] = schemeNames;
1090-
// schemeCount += schemeName.count();
1091-
// schemeNames.clear();
1092-
// listVariant.clear();
1093-
// prevName = "";
1089+
// add schemes to archive
1090+
mSchemeMap[ path ] = schemeNames;
1091+
schemeCount += schemeName.count();
1092+
schemeNames.clear();
1093+
listVariant.clear();
1094+
prevName = "";
1095+
#endif
10941096
return mRampsMap;
10951097
}
10961098

‎src/plugins/grass/qtermwidget/BlockArray.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ struct Block {
4040
size_t size;
4141
};
4242

43-
// ///////////////////////////////////////////////////////
4443

4544
class BlockArray {
4645
public:

0 commit comments

Comments
 (0)
Please sign in to comment.