Skip to content

Commit

Permalink
Add (intended-to-fail) test for #45352
Browse files Browse the repository at this point in the history
(cherry picked from commit 9ce1664)
  • Loading branch information
strk authored and nyalldawson committed Jan 31, 2022
1 parent d8f223d commit e291d7b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/src/python/featuresourcetestbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def testGetFeaturesDistanceWithinTests(self):
request = QgsFeatureRequest().setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:3857'), QgsProject.instance().transformContext()).setDistanceWithin(QgsGeometry.fromWkt('LineString (-7035391 11036245, -7622045 11023301, -7763421 15092839)'), 250000)
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([2, 5]), 'Got {} instead'.format(features)
self.assertEqual(set(features), {2, 5})
self.assertTrue(all_valid)

# point geometry
Expand Down Expand Up @@ -682,6 +682,15 @@ def testGetFeaturesDistanceWithinTests(self):
for f in self.source.getFeatures():
self.assertEqual(request.acceptFeature(f), f['pk'] in set([1, 2, 4]))

# test with linestring whose bounding box overlaps all query
# points but being only within one of them, which we hope will
# be returned NOT as the first one.
# This is a test for https://github.com/qgis/QGIS/issues/45352
request = QgsFeatureRequest().setDistanceWithin(
QgsGeometry.fromWkt('LINESTRING(-100 80, -100 66, -30 66, -30 80)'), 0.5)
features = {f['pk'] for f in self.source.getFeatures(request)}
self.assertEqual(features, {1}, "Unexpected return from QgsFeatureRequest with DistanceWithin filter")

def testGeomAndAllAttributes(self):
"""
Test combination of a filter which requires geometry and all attributes
Expand Down

0 comments on commit e291d7b

Please sign in to comment.