Bug report #4375
Zoom to layer extent does not work for a point layer with a single point.
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||fixed/implemented|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||14307|
Just what the title says.
It does not matter whether or not on-the-fly projection is enabled.
But note that "Zoom full" does work if this is the only layer.
#1 Updated by Steven Mizuno about 9 years ago
Also occurs on two (or more) points having the same x- or y-coordinate, or a line that is exactly vertical or horizontal.
The reason is that Legend zoom to function bails on an empty extent, where it really ought to check the width/height individually and set an appropriate extent. And it should set some reasonable extent for a single point.
It has occurred to me that the map canvas should have a setExtent sort of function that handles zero-width or -height and adds in the 5% buffer for the various zoom to ... actions as this is a common behavior. This would make for uniform handling of such zoom requests and eliminate duplicate coding of the extent calculations especially for these special cases.
#7 Updated by Antonio Locandro over 6 years ago
Can't you do something like add a percentage around the point so the zoom actually works, it shouldn't be a difficult fix for developers to do yet it seems to be left out for some future release which I suspect will never come considering this issue was first reported 2011. This frustrates a lots of users which expect it to work.
#9 Updated by Sandro Santilli over 5 years ago
Sorry, the "apply a scale" wont work to zoom to a single layer if others also exist. Ideally for a single-point layer "zoom to layer" would just set center, not changing existing scale. The "apply an arbitrary scale" work for when no scale was set yet (ie: single point layer is the first layer being loaded).
#10 Updated by Médéric RIBREUX about 5 years ago
- Status changed from Open to Feedback
Hello, bug triage...
it seems to be fixed: in QGIS 2.13 master, I can "zoom" on a layer with only a point. If the point layer is the only layer loaded in QGIS, the map canvas is then centered to the point but the scale is not changed. When there is another layer (tested with another polygon layer), zooming on the point layer change the scale and put the point in the view. It is not centered on the point but the point is displayed.
I think this is a good compromise. Having to zoom on only one layer loaded with only one point is far from being a common use case, so we don't really care about the scale that we can change by ourself as far as the point is visible. And when there is another layer, the point is not centered (it is up) but it is visible at a decent scale.