Bug report #9160

if only one point is selected "zoom to selected" does not zoom

Added by Bernhard Ströbl over 10 years ago. Updated over 5 years ago.

Status:Closed
Priority:Normal
Assignee:Denis Rouzaud
Category:Map Canvas
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

Description

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.

Associated revisions

Revision edc03030
Added by Denis Rouzaud over 5 years ago

Properly zoom to feature for single point selected

fix #9160
this will fetch the canvas content and combine selected point with closest point and scale it 5 times

History

#1 Updated by Matthias Kuhn over 10 years ago

Hi Bernhard,

How would you imagine this relation?
Would that work on e.g. an OSM dataset?

#2 Updated by Richard Duivenvoorde over 10 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 10 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%

#4 Updated by Matthias Kuhn over 10 years ago

Considering your example: If you load Europe and want to zoom to an address in Berlin Kreuzberg but you are currently zoomed into Berlin Mitte. Would triggering this action zoom out?

#5 Updated by Bernhard Ströbl over 10 years ago

Good point Matthias, maybe in a case where the new scale would be larger than the current scale the map should only pan.

#6 Updated by Giovanni Manghi almost 7 years ago

  • Regression? set to No
  • Easy fix? set to No

#7 Updated by Giovanni Manghi about 6 years ago

  • Status changed from Open to Feedback

Please test with a recent QGIS release (2.18 or 3), if the issue/request is still valid change the affected version accordingly, if is fixed/implemented then close the ticket. Thanks!

#8 Updated by Giovanni Manghi over 5 years ago

  • Resolution set to not reproducable
  • Description updated (diff)
  • Status changed from Feedback to Closed

Closing for lack of feedback.

#9 Updated by Bernhard Ströbl over 5 years ago

  • Affected QGIS version changed from 2.0.1 to 3.2
  • Resolution deleted (not reproducable)
  • 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.

#10 Updated by Giovanni Manghi over 5 years ago

  • Operating System deleted (any)
  • Status changed from Reopened to Open

#11 Updated by Denis Rouzaud over 5 years ago

what about zoom in up to the point that the feature's symbol is not overlapping others or is sufficiently distant (in pixels)

#12 Updated by Andreas Neumann over 5 years 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 5 years ago

I did not receive a notification for your reply and did not see before implementing the solution I had in mind.
see https://github.com/qgis/QGIS/pull/8330/files

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 5 years 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.

Thanks,
Andreas

#15 Updated by Denis Rouzaud over 5 years ago

ok, thanks for the feedbck!

#16 Updated by Denis Rouzaud over 5 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

#17 Updated by Andreas Neumann over 5 years ago

Thaks Denis!

It works fine for me. For our purpose we don't need an extra per project scale setting, I think.

Bernhard - can you please also test if this solves your issue?

#18 Updated by Bernhard Ströbl over 5 years ago

@Andreas:
I confirm it works now, problem solved. Thank you everybody.

Also available in: Atom PDF