Feature request #3243

Spatial bookmarks do not take into account CRS

Added by Alister Hood almost 9 years ago. Updated over 7 years ago.

Status:Closed
Priority:Low
Assignee:Richard Duivenvoorde
Category:GUI
Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:13303

Description

The spatial bookmarks system does not take CRS into account - zooming to a bookmark takes you to the same coordinates regardless of the project CRS.
So zooming to a bookmark takes you to the wrong location, unless the project CRS is the same as it was when the bookmark was created.

screenshot.jpg (71.8 KB) Richard Duivenvoorde, 2011-12-26 01:28 PM

Associated revisions

Revision 3c45355e
Added by Richard Duivenvoorde over 7 years ago

fix #3243
Richard Duivenvoorde (from pull request #78)
- crs taking into account, bookmarklist is now editable qtreeview
- set better column names the column names from the table

Juergen Fischer added refactoring:
- move adding bookmarks into QgsBookmarks
- make QgsBookmarks a singleton
- delete multiple entries at once

History

#1 Updated by Anne Ghisla over 8 years ago

Spatial bookmarks indeed save the extent from project CRS; I agree that it would be nice to enable bookmark reprojection, and we consider it more as an enhancement than a bug.

Patches are welcome!

#2 Updated by Giovanni Manghi almost 8 years ago

  • Target version changed from Version 1.7.0 to Version 1.7.4

#3 Updated by Alister Hood almost 8 years ago

  • Assignee deleted (nobody -)
  • Pull Request or Patch supplied set to No

Also see and #3742 and #3856, which are similar issues for the print composer extents and main map canvas.

#4 Updated by Richard Duivenvoorde almost 8 years ago

I want to give this a try, but I am wondering what the best way would be to do this:

1) when creating a bookmark: store current crs int current bookmark, and upon choosing a bookmark reproject from bookmark crs to mapcanvas crs

2) when creating a bookmark: reproject it to wgs84, so we now all bookmarks are in wgs84 and upon choosing a bookmark we now that (if it is not a wgs84 project) we have to reproject the box from wgs84 to mapcanvas crs

Another thing: I see in the bookmark dialog that there is a column 'project' in the gui. Although I have a lot of bookmarks, none of them has that cell filled ??

#5 Updated by Alister Hood almost 8 years ago

I want to give this a try, but I am wondering what the best way would be to do this:

1) when creating a bookmark: store current crs int current bookmark, and upon choosing a bookmark reproject from bookmark crs to mapcanvas crs

2) when creating a bookmark: reproject it to wgs84, so we now all bookmarks are in wgs84 and upon choosing a bookmark we now that (if it is not a wgs84 project) we have to reproject the box from wgs84 to mapcanvas crs

I think option (1) is much more preferable - the coordinates stored/displayed are more likely to mean something to the user, as they will be in a CRS they are used to working in. I also think this is the method already intended to be used (see below).

Another thing: I see in the bookmark dialog that there is a column 'project' in the gui. Although I have a lot of bookmarks, none of them has that cell filled ??

Try this:
- drag and drop the [user's home directory]/.qgis/qgis.db file into QGIS.
- choose to open the tbl_bookmarks table.
- open the attributes table, enable editing, add something in the project_name field, and save the changes.
- restart QGIS. Your added value(s) will now show up in the "Project" column in the bookmarks dialogue.
(So it looks like setting/editing these values is just something else that is waiting to be implemented in the user interface. What might be really interesting would be to try replacing the bookmarks dialogue with an implementation using the standard attribute table window...)

I'm pretty sure that the project_name field is intended to store a description of a project/job that a bookmark relates to - not anything to do with the CRS.

As you can see, there is another field called "projection_srid", which I'm guessing is intended to store an ID for the CRS.

I guess this would be the internal ID QGIS uses for each CRS (which I believe used to be displayed in the CRS selection dialogue, but isn't in Trunk anymore).
Try dragging-and-dropping [qgis installation directory]/resources/srs.db into QGIS, and loading the tbl_srs table. This table has a column called "srid". It looks to me like the values in this column are those internal CRS IDs. The same field exists in the tbl_srs table in qgis.db, which I presume would store an ID for any custom CRS that a user has defined.

#6 Updated by Gary Sherman over 7 years ago

The "project" field was originally designed to contain the name of the QGIS project that the bookmark originated from.

As you have guessed, it hasn't been implemented. Bookmarks that are spatially aware and able to be transformed so they work regardless of the map CRS would be a nice feature...

#7 Updated by Richard Duivenvoorde over 7 years ago

I agree with Alister's point. From the 3 srs's I use often I know the bboxes and reckognize them by the coordinate numbers...

The 'project' columns IS filled if you gave the Project a 'Project title' in the General tab of the Project Properties.

But... apperently I never give my projects a title, so I end up with an empty column.

I do always add the epsg-number to the bookmark name though...

So what I want to propose: is rename the 'project' column to 'Authority ID' and fill it with that (epsg:4326 etc)...

#8 Updated by Alister Hood over 7 years ago

Oh, so it has been implemented. It would still be good to enable the user to edit it.

So what I want to propose: is rename the 'project' column to 'Authority ID' and fill it with that (epsg:4326 etc)...

What!? But you just found out that the project column is currently working. Even if you and I don't typically set the project name, there might be other people that do.
And even if QGIS was changed to remove the "project name" feature, it would definitely be useful to have a column in the bookmarks dialogue to describe what job (or area, or subject) a bookmark relates to.

It would be best to store the CRS ID in the projection_srid field, and show a new column in the dialogue, translating the CRS ID into the name of the CRS.

#9 Updated by Nathan Woodrow over 7 years ago

I agree don't remove the project column. I use it a lot.

What would be nice, but I can open this as another ticket, would be project dependent bookmarks e.g stored in the project file and loaded when it's loaded. This way I can have global bookmarks stored in QGIS, stuff that is common to most projects e.g all the towns in my area and then have ones just for that project when it is loaded. I could then give anyone my project file and they would have the bookmarks but not my global ones.

BTW I have made the bookmark UI dockable, so I will push it up to GitHub as a pull request soon.

#10 Updated by Alister Hood over 7 years ago

What would be nice, but I can open this as another ticket, would be project dependent bookmarks

There is already at least one ticket for that (#1635).

#11 Updated by Alister Hood over 7 years ago

BTW I have made the bookmark UI dockable, so I will push it up to GitHub as a pull request soon.

Great, that will be #1636 done.

#12 Updated by Richard Duivenvoorde over 7 years ago

What!? But you just found out that the project column is currently working.

Oops sorry... no offence :-( I just never used that and wanted to see if at least one person was... and it is. So I will try to add a column, or at least make the storing and using of the crs working.

Oh, so it has been implemented. It would still be good to enable the user to edit it.

Mmm, meaning you are actually changing the 'project title' via the bookmark? Or is it the bookmark 'name' that you want to be editable?

BTW I have made the bookmark UI dockable, so I will push it up to GitHub as a pull request soon.

@Nathan: please do (another closed ticket: yeah!), do not wait for me. This will probably be a weekend project for me,

#13 Updated by Alister Hood over 7 years ago

Richard Duivenvoorde wrote:

Oh, so it has been implemented. It would still be good to enable the user to edit it.

Mmm, meaning you are actually changing the 'project title' via the bookmark? Or is it the bookmark 'name' that you want to be editable?

I just think the name in the project field should be (easily) editable - it shouldn't be permanently connected to a project name specified in a particular .qgs project file.

#14 Updated by Alister Hood over 7 years ago

But actually, I think the bookmark name should should be (easily) editable too. If I remember correctly (I'm away from QGIS right now) it is not yet.

#15 Updated by Richard Duivenvoorde over 7 years ago

currently there is an 'update' button in the dialog with the list of bookmarks. If you click that one only the bbox is updated, what about modifing the little alert dialog which is shown when you add a bookmark.

Eg with 3 line-edits (instead of one (for name) now), so you can when you create and/or edit a bookmark not only update the name, but also the 'bbox', the 'name' and the 'project title'. EG for our national crs, I do not need the 8 decimal places...

Idea?

#16 Updated by Alister Hood over 7 years ago

Sounds good to me. But will you be able to change the name or project title without updating the extent?

#17 Updated by Richard Duivenvoorde over 7 years ago

I would think: Yes.
Just 3 (text) Line edits which will update the record (instead of the one lineedit there is now in the little dialog)

#18 Updated by Richard Duivenvoorde over 7 years ago

  • Assignee set to Richard Duivenvoorde
  • Target version changed from Version 1.7.4 to Version 1.8.0

#19 Updated by Richard Duivenvoorde over 7 years ago

Need some input: after looking into the code, the easiest way to make stuff editable was to change the Bookmarkslist from a QTreeWidget to a QTreeView with a qtmodel behind it (instead of what I proposed here...)

So that is what I did now. Plus offcourse changes to make setting a bookmark also setting the srsid, and using it when . It makes a lot of old code unneccesary, BUT also some little 'issues' (see my branch issue3243 (will do so...), and the screenshot attached):

- ok to see and make editable xmin, xmax, ymin, ymax (instead of some input with 'x y:x y')?
- still have some trouble with the formatting (don't want the scientific notation for coordinates)
- in the old code you could double click on a row to zoom to it, but now clicking or double clicking puts you in edit mode (ok? of work out something for this)?
- one of the 'wishes' is to show the epsg-code or readable name of the crs. But at this moment I use the simplest model available (which just reflects the underlying table), ok or use a 'custom model'...
- code needs more cleanup

Somebody some input (please feel free to criticise my ccp also!)

#20 Updated by Nathan Woodrow over 7 years ago

Here is my feedback. Once you have your code up somewhere I will merge it in with the changes I have made to make the widget dockable.

in the old code you could double click on a row to zoom to it, but now clicking or double clicking puts you in edit mode (ok? of work out something for this)?

-1 from me for this. Zooming is the primary function of the bookmark widget and double clicking is the normal, and best, way to handle this. Editing the bookmark is a secondary function of the widget so it should not interfere with the primary. I would disable double and single click editing and add editing on F2 like the Layer List.

I'm currently working on refactoring out QgsBookmarkItem and QgsBookmarks to remove any database work and move it into a class QgsBookmarkManager which handles saving, loading from the database and projects. QgsBookmarkManager would have stuff like getDatabaseBookmarks(), saveBookmarkToDatabase(bookmark), getProjectBookmarks(project) etc. etc.

#21 Updated by Richard Duivenvoorde over 7 years ago

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

Also available in: Atom PDF