#2658 closed bug (wontfix)
QgsVectorLayer.select( QgsVectorLayer.extent(), true) does not return all features
Reported by: | ersts | Owned by: | nobody |
---|---|---|---|
Priority: | major: does not work as expected | Milestone: | Version 1.5.0 |
Component: | Vectors | Version: | Trunk |
Keywords: | Cc: | ||
Must Fix for Release: | Yes | Platform: | Linux |
Platform Version: | Ubuntu 10.04 | Awaiting user input: | no |
Description
select() does is not returning all features, when using the layer's extent as the input rectangle.
This can be reproduced by grabbing the data provided with ticket #2621. Load the shadefile ( 12 points ) and enter the following in to the python console
lvActiveLayer = qgis.utils.iface.activeLayer() lvExtent = lvActiveLayer.extent() lvActiveLayer.select(lvExtent, True)
The western, northern, and southern most points are not selected. I get the same result using the c++ api
However, I have check another point layer ( also a shapefile ) and get similar but inconsistent results. From the python console the southern most point is not selected, but through the c++ api all points are selected.
I am running on stock Ubuntu 10.04, trunk r13316
Change History (5)
comment:1 by , 14 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 by , 14 years ago
Howdy Martin, I also think it has to do with comparing floats/doubles.
The example I gave happens to be from the same layer. It could just as easily been the extent from layer A being used to select features from layer B. Even if there are other ways to select everything from a layer, it seems that using the layer's extent should always give you all the features.
I am not sure this should just be ignored.
follow-up: 4 comment:3 by , 14 years ago
Well, I am not sure what can we do here apart from expanding the extent with some small deltas when doing the select, because the spatial filtering is typically done in third-party libraries.
CGAL library has an interesting article on the topic: http://www.cgal.org/philosophy.html
follow-up: 5 comment:4 by , 14 years ago
Replying to wonder:
The original bug #2621 was that eVis Event Browser misses records, sometimes a lot of them.
If a solution isn't found then, for all practical purposes, the Event Browser is terminally broken. Are there not also likely to be many other applications of this function where this bug will cause similar problems because the function doesn't do "what it says on the box"?
comment:5 by , 14 years ago
no no. There are other ways to select all the features, all is not lost!
Peter,
you should use empty extent
QgsRectangle()
to tell the layer that you need all features. That is not only safer, but can be also faster as there is no spatial filtering going on.I believe the problem is caused by some subtle differences among the values of floating point numbers of coordinates. For example, extent passed to PostGIS database is first encoded as a string and then decoded back to double value, so there is obvious space for loosing the precision.
Martin