nextgis / quickmapservices

QGIS plugin to find and add map services to a project in one click
http://plugins.qgis.org/plugins/quick_map_services/
GNU General Public License v2.0
169 stars 49 forks source link

Adding a QMS layer changes destination SRS and not project CRS, which is extremely confusing #214

Closed AlisterH closed 3 years ago

AlisterH commented 3 years ago
  1. I'm not sure if the map canvas destination SRS actually needs to be changed when adding a quick map services layer. Does it?
  2. Assuming it does, wouldn't it be far less confusing to either change it back after loading the layer, or change the project CRS instead of just changing the map canvas destination SRS?
AlisterH commented 3 years ago

It seems to me that the destination SRS doesn't need to be changed - I can just comment out this line in qgis_map_helpers.py:


iface.mapCanvas().setDestinationCrs(TileLayer.CRS_3857)
simgislab commented 3 years ago

Can't reproduce (understand) it here. Here is my scenario:

  1. Start QGIS
  2. Load a layer in 4326
  3. Coords are in degrees, CRS selector shows 4326
  4. Search for Mapnik, add it
  5. OSM Standard shows, Coords are in degrees, CRS selector shows 4326

can you be more specific?

I'm using QGIS 3.18.

AlisterH commented 3 years ago

I have just tested with QGIS 3.16 and 3.18.

  1. I load the attached file in. QGIS displays the correct coordinates in EPSG:2105
  2. I load Google satellite layer using QMS. Then as soon as I move the mouse QGIS starts displaying the wrong coordinates.
  3. I change to EPSG:2193 and QGIS displays the correct coordinates for that system.
  4. I change back to EPSG:2105 and it starts displaying the correct coordinates again. Desktop.zip
AlisterH commented 3 years ago

Unfortunately the Windows screen recorder won't record context menus and dialogs, so I'm not sure it's worth it, but here is a recording showing the coordinate display changing. The empty memory layer is in EPSG:2193 I load the Google satellite layer then use "set project CRS from layer" to change to EPSG:2193 and back to EPSG:2105. https://user-images.githubusercontent.com/714600/119962138-d9b24400-bffa-11eb-8de2-13da02bdd199.mp4

simgislab commented 3 years ago

please check this and may be try to replicate it

http://m-d.me/img/ss/zQz4vpqGC4.gif

does it produce correct behavior for you?

AlisterH commented 3 years ago

I see - the problem only occurs when I load the layer using the menu (Web>Quickmapservices). There is no problem if I use the "Search QMS" panel to load the layer.

simgislab commented 3 years ago

that's it then, marking it as a bug

the behavior from the catalog should be the same as behavior from the QMS search

PS: for the future reference, we'll be retiring catalog gradually in favor of search panel

AlisterH commented 3 years ago

PS: for the future reference, we'll be retiring catalog gradually in favor of search panel

That's a shame because it's nice to not have to use a panel.

simgislab commented 3 years ago

no difference, same number of clicks

simgislab commented 3 years ago

ok, I was to quick to call it a bug.

It's just a option that apparently is turned on for you:

If you don't like your CRS to change to 3857 on adding a basemap - just turn it off. It should fix everything.

We'll:

514ckw4r3 commented 3 years ago

Fixed in 0.19.19

AlisterH commented 3 years ago

Sorry, there is still a bug (or arguably two), it is just different now. If "Enable EPSG:3857 (OTF) on adding TMS:" setting is disabled, both the menu and the panel work as expected. But if the setting is enabled:

  1. when I add a QMS layer using the menu it doesn't enable EPSG:3857, and
  2. when I add a QMS layer using the search panel it has the same problem that I was originally complaining about with the menu. The Coordinate display now displays a "current map coordinate" that is in EPSG:3857, but the "current CRS" button is the same coordinate system it was before adding the layer. Surely this is not right - it should say EPSG:3857.
simgislab commented 3 years ago

did you update to latest version of QMS plugin (0.19.17)?

just tested with this option ON and both scenarios change project CRS to 3857 like expected

AlisterH commented 3 years ago

0.19.19, and I have just double-checked that the behaviour is as per my last comment.

Also, I checked that after adding the QMS layer using the search panel, the problem isn't just that the "current CRS" button displays the wrong CRS. In some sense QGIS really believes that it is still using the original CRS, e.g. if I use the nominatum location filter to find an address, I get taken to completely the wrong place (the displayed coordinates would be correct for the original CRS).

AlisterH commented 3 years ago

Testing with a clean QGIS profile the behaviour is the same as I have described. Interestingly the "Search QMS" panel remembered the "Last used" services that were used in the original profile.

simgislab commented 3 years ago

Ok, I'm confused. Please try to be very specific and omit any side information such as nominatim usage etc. Stick to the bare scenario.

I'm doing this:

Enable 3857 option in QMS is on.

  1. Open new QGIS project, EPSG 4326 is default
  2. Search for Mapnik in search panel
  3. Add found geoservice
  4. Project CRS changes to 3857.

does this work for you?

AlisterH commented 3 years ago

That only works if I start with a new empty project and with QGIS itself configured to change the CRS to match the first layer added (Scenario B below). Scenario C below demonstrates the problem.

Scenario A: "Settings>Options>CRS for Projects>When a new project is created" is set to "Use CRS from first layer added", and "Enable EPSG:3857 (OTF) on adding TMS" is OFF. I follow your steps 1 to 3 and the CRS is changed to EPSG:3857, presumably because of the QGIS setting. This behaviour seems correct.

Scenario B: "Settings>Options>CRS for Projects>When a new project is created" is set to "Use CRS from first layer added", and "Enable EPSG:3857 (OTF) on adding TMS" is ON. I follow your steps 1 to 3 and the CRS is changed to EPSG:3857. This behaviour seems correct.

Scenario C: "Settings>Options>CRS for Projects>When a new project is created" is set to "Use a default CRS", and "Enable EPSG:3857 (OTF) on adding TMS" is ON. I follow your steps 1 to 3 and the map and coordinates display in EPSG:3857 (correct behaviour), but the "current CRS" button still says the CRS is EPSG:4326 (incorrect behaviour).

Scenario D: "Settings>Options>CRS for Projects>When a new project is created" is set to "Use a default CRS", and "Enable EPSG:3857 (OTF) on adding TMS" is OFF. I follow your steps 1 to 3 and the map and coordinates display in EPSG:4326 (correct behaviour).

AlisterH commented 3 years ago

Sorry, fixed my description of scenario D.

simgislab commented 3 years ago

thanks so much for working on that, now it is clear

@514ckw4r3 lets work on Scenario C below, I believe we should override QGIS setting in this case and boil down Scenario C to Scenario B

514ckw4r3 commented 3 years ago

@AlisterH, the setting "CMS for Projects->When a new project is created" only affects new projects. You need to create a new project and then the Project CRS will be set correctly.

AlisterH commented 3 years ago

? That setting works fine, I don't know why you think I have a problem with it. The problem is with the QMS setting.

AlisterH commented 3 years ago

I believe we should override QGIS setting in this case and boil down Scenario C to Scenario B

Note that the issue is actually unrelated to the initial setting of a project CRS - it is just that your settings for that were masking the problem in your testing. The QMS layer would usually not be the first layer added, and the QMS setting should work regardless of whether or not it is.

AlisterH commented 3 years ago

Personally I don't understand why QMS needs this setting - people don't normally seem to need the CRS changed every time a new layer is added, so I'm not sure why they would need that when using QMS. I imagine your code would be a lot simpler without this option...

simgislab commented 3 years ago

good question, we've been discussing to remove it altogether too

simgislab commented 3 years ago

the current plan is to first fix Scenario C to make behavior consistent and then rethink it completely may be removing settings altogether

514ckw4r3 commented 3 years ago

Scenario C fixed in version 0.19.20. Now the 'Enable EPSG:3857 (OTF) on adding TMS' option also changes the project CRS. The fix will be available in the next release.

AlisterH commented 3 years ago

OK, that works properly when adding from the search panel But please be aware that it doesn't attempt to enable EPSG:3857 when adding from the menu.

simgislab commented 3 years ago

behavior should be the same

simgislab commented 3 years ago

turns out that catalog geoservices don't even declare CRS, so adding from catalog behavior is OK, since 3857 option should work only for TMS with 3857 declared explicitly

once declared, all works as expected https://github.com/nextgis/quickmapservices/blob/master/src/data_sources/osm_mapnik/metadata.ini#L23