[QGIS-Developer] QgsFeatureRequest spatial filter reprojection
Sandro Santilli
strk at kbt.io
Wed Oct 20 03:01:19 PDT 2021
I've finally found the bug I've been chasing for two weeks now [1]
What's happening is that a QgsFeatureRequest object initialized
with a DistanceWithin spatial filter, switches to a Rectangle spatial
filter when used to construct a QgsVectorLayerFeatureIterator.
This is because QgsVectorLayerFeatureIterator constructor tries to
reproject the QgsFeatureRequest's rectangle filter from destination
CRS to source CRS, probably aiming at improving performance from
vector layers which may have indices.
Such attempt to reproject is done using methods of QgsFeatureRequest
which *change* the spatial filter (setFilterRect).
Now I've a few questions:
1. Shouldn't such optimizations be performed by each specific
provider's class rather than by the base class ?
(projecting the Request filters to the source CRS)
2. Shall we see a need to reproject spatial filter references,
shouldn't this be done by a method of QgsFeatureRequest class
directly ?
Note that QgsFeatureRequest doesn't ONLY possibly have a QgsRectangle
as a reference, but could also have a QgsGeometry and a *distance*,
"reprojecting" which is not really obvious...
[1] https://github.com/qgis/QGIS/pull/45384
--strk;
Libre GIS consultant/developer
https://strk.kbt.io/services.html
More information about the QGIS-Developer
mailing list