Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rename intersect to intersects for consistency with QgsSpatialIndex
  • Loading branch information
nyalldawson committed Jul 7, 2018
1 parent 38251cb commit 05368e4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion python/core/auto_generated/qgsspatialindexkdbush.sip.in
Expand Up @@ -66,7 +66,7 @@ Copy constructor

~QgsSpatialIndexKDBush();

QList<QgsSpatialIndexKDBushData> intersect( const QgsRectangle &rectangle ) const;
QList<QgsSpatialIndexKDBushData> intersects( const QgsRectangle &rectangle ) const;
%Docstring
Returns the list of features which fall within the specified ``rectangle``.
%End
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsspatialindexkdbush.cpp
Expand Up @@ -73,7 +73,7 @@ qgssize QgsSpatialIndexKDBush::size() const
return d->index->size();
}

QList<QgsSpatialIndexKDBushData> QgsSpatialIndexKDBush::intersect( const QgsRectangle &rectangle ) const
QList<QgsSpatialIndexKDBushData> QgsSpatialIndexKDBush::intersects( const QgsRectangle &rectangle ) const
{
QList<QgsSpatialIndexKDBushData> result;
d->index->range( rectangle.xMinimum(),
Expand All @@ -83,7 +83,7 @@ QList<QgsSpatialIndexKDBushData> QgsSpatialIndexKDBush::intersect( const QgsRect
return result;
}

void QgsSpatialIndexKDBush::intersect( const QgsRectangle &rectangle, const std::function<void( QgsSpatialIndexKDBushData )> &visitor ) const
void QgsSpatialIndexKDBush::intersects( const QgsRectangle &rectangle, const std::function<void( QgsSpatialIndexKDBushData )> &visitor ) const
{
d->index->range( rectangle.xMinimum(),
rectangle.yMinimum(),
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsspatialindexkdbush.h
Expand Up @@ -87,14 +87,14 @@ class CORE_EXPORT QgsSpatialIndexKDBush
/**
* Returns the list of features which fall within the specified \a rectangle.
*/
QList<QgsSpatialIndexKDBushData> intersect( const QgsRectangle &rectangle ) const;
QList<QgsSpatialIndexKDBushData> intersects( const QgsRectangle &rectangle ) const;

/**
* Calls a \a visitor function for all features which fall within the specified \a rectangle.
*
* \note Not available in Python bindings
*/
void intersect( const QgsRectangle &rectangle, const std::function<void( QgsSpatialIndexKDBushData )> &visitor ) const SIP_SKIP;
void intersects( const QgsRectangle &rectangle, const std::function<void( QgsSpatialIndexKDBushData )> &visitor ) const SIP_SKIP;

/**
* Returns the list of features which are within the given search \a radius
Expand Down
12 changes: 6 additions & 6 deletions tests/src/core/testqgsspatialindexkdbush.cpp
Expand Up @@ -87,11 +87,11 @@ class TestQgsSpatialIndexKdBush : public QObject
QgsSpatialIndexKDBush index( *vl->dataProvider() );
QVERIFY( index.size() == 4 );

QList<QgsSpatialIndexKDBushData> fids = index.intersect( QgsRectangle( 0, 0, 10, 10 ) );
QList<QgsSpatialIndexKDBushData> fids = index.intersects( QgsRectangle( 0, 0, 10, 10 ) );
QVERIFY( fids.count() == 1 );
QVERIFY( testContains( fids, 1, QgsPointXY( 1, 1 ) ) );

QList<QgsSpatialIndexKDBushData> fids2 = index.intersect( QgsRectangle( -10, -10, 0, 10 ) );
QList<QgsSpatialIndexKDBushData> fids2 = index.intersects( QgsRectangle( -10, -10, 0, 10 ) );
QCOMPARE( fids2.count(), 2 );
QVERIFY( testContains( fids2, 2, QgsPointXY( -1, 1 ) ) );
QVERIFY( testContains( fids2, 3, QgsPointXY( -1, -1 ) ) );
Expand Down Expand Up @@ -128,7 +128,7 @@ class TestQgsSpatialIndexKdBush : public QObject
QVERIFY( index->d->ref == 2 );

// test that copied index works
QList<QgsSpatialIndexKDBushData> fids = indexCopy->intersect( QgsRectangle( 0, 0, 10, 10 ) );
QList<QgsSpatialIndexKDBushData> fids = indexCopy->intersects( QgsRectangle( 0, 0, 10, 10 ) );
QVERIFY( fids.count() == 1 );
QVERIFY( testContains( fids, 1, QgsPointXY( 1, 1 ) ) );

Expand All @@ -139,7 +139,7 @@ class TestQgsSpatialIndexKdBush : public QObject
index.reset();

// test that copied index still works
fids = indexCopy->intersect( QgsRectangle( 0, 0, 10, 10 ) );
fids = indexCopy->intersects( QgsRectangle( 0, 0, 10, 10 ) );
QVERIFY( fids.count() == 1 );
QVERIFY( testContains( fids, 1, QgsPointXY( 1, 1 ) ) );
QVERIFY( indexCopy->d->ref == 1 );
Expand All @@ -148,14 +148,14 @@ class TestQgsSpatialIndexKdBush : public QObject
std::unique_ptr< QgsVectorLayer > vl2 = qgis::make_unique< QgsVectorLayer >( "Point", QString(), QStringLiteral( "memory" ) );
QgsSpatialIndexKDBush index3( *vl2->dataProvider() );
QVERIFY( index3.size() == 0 );
fids = index3.intersect( QgsRectangle( 0, 0, 10, 10 ) );
fids = index3.intersects( QgsRectangle( 0, 0, 10, 10 ) );
QVERIFY( fids.count() == 0 );
QVERIFY( index3.d->ref == 1 );

index3 = *indexCopy;
QVERIFY( index3.d == indexCopy->d );
QVERIFY( index3.d->ref == 2 );
fids = index3.intersect( QgsRectangle( 0, 0, 10, 10 ) );
fids = index3.intersects( QgsRectangle( 0, 0, 10, 10 ) );
QVERIFY( fids.count() == 1 );
QVERIFY( testContains( fids, 1, QgsPointXY( 1, 1 ) ) );

Expand Down

0 comments on commit 05368e4

Please sign in to comment.