I'm writing a photo grouping plugin. My current problem can be broken up into "end goal" and "baby steps", because I think that's what I want. But if there's a way to get to the end by a different means, that's what I really need.
End goal: given 2 different QGIS layers, 'nodes' and 'sections', and given a bunch of groups of photos, mouse over a 'node' > click to assign photos to node. mouse over a 'section' > click to assign. Repeat indefinitely, not necessarily in order. Without toggling active layer back and forth and making selection(s) first.
Baby Step #1: find out what feature(s) on which vector layer(s) is under the mouse position.
I found the "Value Tool" plugin last night, read through the code, and it reports values from multiple raster layers based on the mouse position. I was super excited! Unfortunately, it seems that QgsVectorDataProvider doesn't have anything analogous to the QgsRasterDataProvider's identify(position) method, which is how that plugin works.
So I've been playing around with QgsVectorDataProvider.select(), but can't get it working. Probably doing something stupid. This post: https://gis.stackexchange.com/a/22919/6690 makes it sound like it's possible.
Can anyone tell me what I'm doing wrong?
Steps (in Python console for now):
- load vector layer in QGIS
- iface = qgis.utils.iface; canvas = iface.mapCanvas(); layer = canvas.layer(0)
- layer.dataProvider().attributeIndexes() >> [0,1,2,3,4,5]
- A = layer.dataProvider.select((0,1,2,3,4,5),canvas.extent())
- checks: A >> nothing; type(A) >> 'type 'NoneType''
Once I can get a selection by position, I think I can get the list of layers I want to check, iterate through them with position, check & flag on overlaps, and we're off...