Bug report #3998

Zoom to selected don't work with point layers and OTF reprojection

Added by Alexander Bruy almost 13 years ago. Updated about 10 years ago.

Assignee:Magnus Homann
Category:Projection Support
Affected QGIS version:master Regression?:No
Operating System:All Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:13986


  • open any point layer in WGS84
  • open attribute table, select some records (features)
  • press "Zoom map to the selected rows" button
  • all works fine and map zoomed to the selected features
  • now turn on "on the fly" reprojection and select any projected CRS, for example WGS84/UTM Zone 39N
  • zoom to full extent
  • again open attribute table and selecy some features
  • press "Zoom map to the selected rows" button
  • canvas was zoomed to blank area

This issue affects only point layers, with polygon or line layers all works as expected

patch_for_3998.diff Magnifier (568 Bytes) Steven Mizuno, 2011-08-22 11:28 AM


#1 Updated by Paolo Cavallini almost 13 years ago

  • Pull Request or Patch supplied set to No
  • Tracker changed from Bug report to 4

#2 Updated by Steven Mizuno over 12 years ago

Here is a possible fix for the bug.

What happens is the area zoomed to is the latitude/longitude values used in the UTM projection with no transformation, in the example given.

In Identify Results, the Zoom to feature also has the same behavior.

Actually any feature(s) that have no width or height (an empty extent) will do the same. Points along a line of either longitude or latitude (but not both), for example.

In QgsCoordinateTransform::transformBoundingBox(rect,direction) returns immediately when rect is empty, so there is no transformation done.

I tried eliminating the test

|| rect.isEmpty()

in the first line of the function. Now zoom to a point works. And zooming to points along a line of longitude also works, with the extent of the points setting the zoom factor.

Looking through the function I see no place where divide by width or height of the input rect is used, so a 0 value won't cause a divide by zero error.

I have tried a point layer in UTM zone 15, map in WGS84 geog. and zooming to a selected or identified point works as well.

#3 Updated by Giovanni Manghi over 12 years ago

  • Target version set to Version 1.7.4

#4 Updated by Giovanni Manghi about 12 years ago

  • Tracker changed from 4 to Bug report
  • Crashes QGIS or corrupts data set to No
  • Affected QGIS version set to master

#5 Updated by Paolo Cavallini about 12 years ago

  • Target version changed from Version 1.7.4 to Version 1.8.0

#6 Updated by Paolo Cavallini over 11 years ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

#7 Updated by Magnus Homann over 11 years ago

  • Assignee set to Magnus Homann

#8 Updated by Alexander Bruy about 10 years ago

  • Resolution set to fixed/implemented
  • Status changed from Open to Closed

Seems fixed in master

Also available in: Atom PDF