|
@@ -521,6 +521,36 @@ def testRectAndExpression(self): |
|
|
for f in self.source.getFeatures(): |
|
|
self.assertEqual(request.acceptFeature(f), f['pk'] in expected) |
|
|
|
|
|
def testRectAndFids(self): |
|
|
""" |
|
|
Test the combination of a filter rect along with filterfids |
|
|
""" |
|
|
|
|
|
# first get feature ids |
|
|
ids = {f['pk']: f.id() for f in self.source.getFeatures()} |
|
|
|
|
|
extent = QgsRectangle(-70, 67, -60, 80) |
|
|
request = QgsFeatureRequest().setFilterFids([ids[3], ids[4]]).setFilterRect(extent) |
|
|
result = set([f['pk'] for f in self.source.getFeatures(request)]) |
|
|
all_valid = (all(f.isValid() for f in self.source.getFeatures(request))) |
|
|
expected = [4] |
|
|
assert set(expected) == result, 'Expected {} and got {} when testing for combination of filterRect and expression'.format(set(expected), result) |
|
|
self.assertTrue(all_valid) |
|
|
|
|
|
# shouldn't matter what order this is done in |
|
|
request = QgsFeatureRequest().setFilterRect(extent).setFilterFids([ids[3], ids[4]]) |
|
|
result = set([f['pk'] for f in self.source.getFeatures(request)]) |
|
|
all_valid = (all(f.isValid() for f in self.source.getFeatures(request))) |
|
|
expected = [4] |
|
|
assert set( |
|
|
expected) == result, 'Expected {} and got {} when testing for combination of filterRect and expression'.format( |
|
|
set(expected), result) |
|
|
self.assertTrue(all_valid) |
|
|
|
|
|
# test that results match QgsFeatureRequest.acceptFeature |
|
|
for f in self.source.getFeatures(): |
|
|
self.assertEqual(request.acceptFeature(f), f['pk'] in expected) |
|
|
|
|
|
def testGetFeaturesDestinationCrs(self): |
|
|
request = QgsFeatureRequest().setDestinationCrs(QgsCoordinateReferenceSystem('epsg:3785'), QgsProject.instance().transformContext()) |
|
|
features = {f['pk']: f for f in self.source.getFeatures(request)} |
|
|