Skip to content
Permalink
Browse files

[ogr] Fix ExactIntersection flag should be ignored if filter rect

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 13a888d2f8b7c67a99bcb8691a9efaa62476edab
Showing with 9 additions and 1 deletion.
  1. +1 −1 src/providers/ogr/qgsogrfeatureiterator.cpp
  2. +8 −0 tests/src/python/featuresourcetestbase.py
@@ -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 )
{
@@ -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)

0 comments on commit 13a888d

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