Bug report #2658

QgsVectorLayer.select( QgsVectorLayer.extent(), true) does not return all features

Added by ersts - about 14 years ago. Updated almost 14 years ago.

Status:Closed
Priority:Low
Assignee:nobody -
Category:Vectors
Affected QGIS version: Regression?:No
Operating System:Linux Easy fix?:No
Pull Request or Patch supplied: Resolution:wontfix
Crashes QGIS or corrupts data: Copied to github as #:12718

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

History

#1 Updated by Martin Dobias almost 14 years ago

  • Resolution set to wontfix
  • Status changed from Open to Closed

Peter,


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

#2 Updated by ersts - almost 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.

#3 Updated by Martin Dobias almost 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

#4 Updated by Donkagen2 - almost 14 years ago

Replying to [comment:3 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"?

#5 Updated by ersts - almost 14 years ago

no no. There are other ways to select all the features, all is not lost!

Also available in: Atom PDF