Bug report #9160
if only one point is selected "zoom to selected" does not zoom
|Affected QGIS version:||3.2||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||17793|
To reproduce: load a point layer, select one feature in the table and click "Zoom to selection"; the map is panned but not zoomed.
Reason: the bounding box of the selected feature is undefined in its size (width and height are 0)
Proposed solution: zoom to a certain scale that is related to the size of the bounding box of the layer (i.e. a certain fraction of the scale needed to display the whole layer). Thus this scale would be different for a layer containing global disaster points compared to one containing local addresses.
#2 Updated by Richard Duivenvoorde over 6 years ago
Well, on a osm dataset, or another huge dataset you would not so easily select one point to pan to it (I think). So in most case I think say: 10% (??) of the layer extent would be usefull.
IF we make the 10% not hard coded, but a QSettings variable an advanced user can change it on the fly if it is better for him/her to zoom to 0.1% (I'm promoting my advanced QSettings dialog here ;-) )..
#3 Updated by Bernhard Ströbl over 6 years ago
H Matthias and Richard,
I had 1% in mind and was thinking of having a user-setting for this, if this setting is not obvoius but kinda hidden like Richard proposes (in Mozilla firefox style if I recall correctly) this would be great.
Considering OSM: The default percentage would only be a best guess anyway. So if you load Europe and want to zoom to an address, you are not worse off than now, i.e. you need to manually zoom in or set a reasonable scale. If a user uses local layers and OSM Europe in different projects he needs to configure the setting appropriately, e.g. 1% vs 0.001%
#9 Updated by Bernhard Ströbl over 1 year ago
- Affected QGIS version changed from 2.0.1 to 3.2
- Resolution deleted (
- Operating System set to any
- Status changed from Closed to Reopened
Sorry, slipped my attention. I would like to still have this open, a possible solution has been described in the discussion.
#12 Updated by Andreas Neumann over 1 year ago
@Denis: not sure if I fully understand you. Overlapping other points? That might result in a very deep zoom in, probably too deep.
Personally, I would like to see a solution where the user can specify a "per project" setting (zoom scale for "zoom to points", e.g. 1:500) and a fallback mechanism (maybe 0.5% or 1% of the width of the concerned layer - or if there is something better, replace it with that better idea how to define the best zoom level without a user setting)
#13 Updated by Denis Rouzaud over 1 year ago
I did not receive a notification for your reply and did not see before implementing the solution I had in mind.
Basically, it takes the closest point, combine with selected one and scale 5 times.
Of course, if there is no points around it doesn't zoom out, it just keeps current scale.
I have tried this and find this works well.
I can still implement the preferred scale approach as an option (but really an option, as there is good chance that nobody sets it, and having a default value is very likely to not cover all use cases),
#14 Updated by Andreas Neumann over 1 year ago
- Assignee set to Denis Rouzaud
Denis: perhaps you did not receive notification because you haven't been assigned to this issue? I assigned you now.
Thanks a lot. Let's test it with some data and see how it works, before we alternatively implement a project settings. If it works fine for most cases, the project setting probably won't be needed.