I'm trying to get the closest line to a point using PyQGIS in a plugin. The active code file is this: http://pastebin.com/TDzmsKVM
When I request the closest line (only 1)
nearestIds = self.spIndex.nearestNeighbor(self.feat2.geometry().centroid().asPoint(),1)
I sometimes get a list with two lines and the first one is not the closest but as far as I can see the second one is. Why is this?
Does QgsSpatialIndex
use only boundingboxes for lines?
How do I get the real closest line always, not only most of the time?