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
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to