Bug report #8192

Zoom to Layer zooms to a far too large area

Added by Aren Cambre over 11 years ago. Updated about 11 years ago.

Status:Closed
Priority:Low
Assignee:-
Category:GUI
Affected QGIS version:master Regression?:No
Operating System:Windows 7 x64 Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:17010

Description

I have a point layer with a filter applied. If I use the Zoom to Layer feature with that layer selected, it zooms as if the filter was not applied.

The attached image shows the result of Zoom to Layer. You can clearly see that the layer's green dots are only in a band along I-45 in Texas, with a couple more towards the Gulf Coast. If I had no filter applied, you'd see green dots all over the state.

To be clear, I don't know if the problem is because of the filter. It seems that if QGIS is working correctly, it should apply the filter using SQL and should not have knowledge of the filtered out points, so it may be possible that Zoom to Layer may be zooming to the largest layer on the screen instead of just to the selected layer. If that is true, then Zoom to Layer is either misnamed or broken.

I am on 1.9 c8d3fa7.

zoom_to_layer.png (603 KB) Aren Cambre, 2013-06-28 09:49 AM

ScreenCapture_7-7-2013_9.20.08_AM.wmv (1.32 MB) Aren Cambre, 2013-07-07 06:22 PM

Associated revisions

Revision 7608faf6
Added by Nyall Dawson over 11 years ago

Skip missing geometries when calculating extent (fixes #8192, #8194)

Revision 6149b3a6
Added by Nyall Dawson about 11 years ago

Merge pull request #789 from nyalldawson/bug8192

Fix bounding box calculation for features with NULL geometry (fixes #8192, #8194)

History

#1 Updated by Giovanni Manghi over 11 years ago

  • Status changed from Open to Feedback

It works as expected here.

What datasource are you using? I tested shapes and postgis on qgis/master on Linux.

#2 Updated by Aren Cambre over 11 years ago

I am using a datasource that shows events along roadways. Doesn't matter what filter I apply, the zoom extent for Zoom to Layer is hugely greater than what is needed.

Do you have any "point" datasets with where you can filter to a small area?

I tried on a PostGIS multiline datasource and couldn't reproduce.

#3 Updated by Giovanni Manghi over 11 years ago

Aren Cambre wrote:

Do you have any "point" datasets with where you can filter to a small area?

any point layer, of any datasource, I tested works fine here. Unless you can share a sample of the problematic data, it will be hard to prove it is a qgis issue and not a data one.

#4 Updated by Aren Cambre over 11 years ago

I have a SQL dump of the PostGIS datasource handy, so I can share it with you. Please email me at to get it.

#5 Updated by Giovanni Manghi over 11 years ago

  • Resolution set to worksforme
  • Status changed from Feedback to Closed

Aren Cambre wrote:

I have a SQL dump of the PostGIS datasource handy, so I can share it with you. Please email me at to get it.

I tested your sample data and query/filter, and the zoom to layer works as expected, zooming only/exactly to filtered features. Please try a clean installation and/or on another machine. Reopen if you will find the culprit.

#6 Updated by Aren Cambre over 11 years ago

OK, I tried it on another computer and couldn't reproduce. So I went back to the original computer, removed the install by doing these (was installed using osgeo4w):
  • Delete C:\\OSGeo4W.
  • Delete Start Menu entries.
  • Delete the .gis2 directory in my home directory.
  • Delete the corresponding entries in the Windows Registry under HKCU.

Then I reinstalled.

Despite this, I still get the same problem. See the attached video, where I only open the problem layer from a clean install.

#7 Updated by Giovanni Manghi over 11 years ago

  • Priority changed from Normal to Low
  • Target version deleted (Version 2.0.0)
  • Resolution deleted (worksforme)

Aren Cambre wrote:

OK, I tried it on another computer and couldn't reproduce. So I went back to the original computer, removed the install by doing these (was installed using osgeo4w):
  • Delete C:\\OSGeo4W.
  • Delete Start Menu entries.
  • Delete the .gis2 directory in my home directory.
  • Delete the corresponding entries in the Windows Registry under HKCU.

Then I reinstalled.

Despite this, I still get the same problem. See the attached video, where I only open the problem layer from a clean install.

Well, you really cleaned your machine, so I don't what to say. I tested 3 machines (two Windows and 1 Linux) and got no issue. You also tested another machine and no issue. My gut feeling is that is a (weird) local issue. If you agree I would close this ticket until you will find the eventual culprit.

#8 Updated by Aren Cambre over 11 years ago

One other fact: both computers were using the same PostGIS database instance. I.e., the computer that worked was connected to PostGIS on the computer that didn't work.

I guess it could be closed and I can reopen if I find something meaningful to add. Or we could leave it open as low priority for a while?

#9 Updated by Nyall Dawson over 11 years ago

Ok, I've figured this one out. It's caused when a filter is applied to a table which returns records with NULL geometry. The offending lines are around 1164-1167 of qgsvectorlayer.cpp:

if ( fet.geometry() ) {
QgsRectangle bb = fet.geometry()->boundingBox();
rect.combineExtentWith( &bb );

for features with NULL geometry, fet.geometry->boundingBox() was returning QgsRectangle(0,0,0,0). Combining this extent causes the bounding box min x and y to be set incorrectly to 0.

Pull request #789 fixes this bug, and incidentally fixes #8194 too.

#10 Updated by Nyall Dawson about 11 years ago

  • Status changed from Reopened to Closed

Also available in: Atom PDF