Navigation Menu

Skip to content

Commit

Permalink
add test for QgsPointLocator::nearestArea
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Feb 19, 2018
1 parent 9e2e99f commit 1d0043e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/src/core/testqgspointlocator.cpp
Expand Up @@ -130,6 +130,30 @@ class TestQgsPointLocator : public QObject
QCOMPARE( pt2, QgsPointXY( 1, 1 ) );
}

void testNearestArea()
{
QgsPointLocator loc( mVL );
QgsPointXY pt1( 1.1, 0.5 );
QgsPointLocator::Match m1 = loc.nearestArea( pt1, 0 );
QVERIFY( !m1.isValid() );

QgsPointXY pt2( 0.9, 0.9 );
QgsPointLocator::Match m2 = loc.nearestArea( pt2, 0 );
QVERIFY( m2.isValid() );
QVERIFY( m2.hasArea() );
QCOMPARE( m2.layer(), mVL );
QCOMPARE( m2.featureId(), ( QgsFeatureId )1 );
QCOMPARE( m2.point(), QgsPointXY( 0.9, 0.9 ) );

QgsPointXY pt3( 1.1, 1.1 );
QgsPointLocator::Match m3 = loc.nearestArea( pt3, 999 );
QVERIFY( m3.isValid() );
QVERIFY( m3.hasArea() );
QCOMPARE( m3.layer(), mVL );
QCOMPARE( m3.featureId(), ( QgsFeatureId )1 );
QCOMPARE( m3.point(), QgsPointXY( 1.0, 1 - 0 ) );
}

void testPointInPolygon()
{
QgsPointLocator loc( mVL );
Expand Down

0 comments on commit 1d0043e

Please sign in to comment.