Skip to content

Commit

Permalink
[ogr] Fix ExactIntersection flag should be ignored if filter rect
Browse files Browse the repository at this point in the history
is not set

And add provider test case to ensure no other providers have this
issue
  • Loading branch information
nyalldawson committed Dec 19, 2017
1 parent e678bfa commit 13a888d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ bool QgsOgrFeatureIterator::readFeature( gdal::ogr_feature_unique_ptr fet, QgsFe
feature.initAttributes( mSource->mFields.count() );
feature.setFields( mSource->mFields ); // allow name-based attribute lookups

bool useIntersect = mRequest.flags() & QgsFeatureRequest::ExactIntersect;
bool useIntersect = !mRequest.filterRect().isNull() && mRequest.flags() & QgsFeatureRequest::ExactIntersect;
bool geometryTypeFilter = mSource->mOgrGeometryTypeFilter != wkbUnknown;
if ( mFetchGeometry || useIntersect || geometryTypeFilter )
{
Expand Down
8 changes: 8 additions & 0 deletions tests/src/python/featuresourcetestbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,14 @@ def testGetFeaturesFilterRectTests(self):
assert set(features) == set([1, 2, 3, 4, 5]), 'Got {} instead'.format(features)
self.assertTrue(all_valid)

# ExactIntersection flag set, but no filter rect set. Should be ignored.
request = QgsFeatureRequest()
request.setFlags(QgsFeatureRequest.ExactIntersect)
features = [f['pk'] for f in self.source.getFeatures(request)]
all_valid = (all(f.isValid() for f in self.source.getFeatures(request)))
assert set(features) == set([1, 2, 3, 4, 5]), 'Got {} instead'.format(features)
self.assertTrue(all_valid)

def testRectAndExpression(self):
extent = QgsRectangle(-70, 67, -60, 80)
request = QgsFeatureRequest().setFilterExpression('"cnt">200').setFilterRect(extent)
Expand Down

0 comments on commit 13a888d

Please sign in to comment.