qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.35k stars 2.97k forks source link

XYZ Connection "Tile Resolution" partially functional #50385

Open m-kuhn opened 1 year ago

m-kuhn commented 1 year ago

What is the bug or the crash?

XYZ connections allow a user to specify the DPI of the source with "tile resolution". Changing this settings does not have any effect.

Tile Resolution XYZ

Steps to reproduce the issue

or

  1. Right click OpenStreetMap in the browser/XYZ Connections
  2. Set Tile Resolution to 96
  3. add layer
  4. Repeat, set resolution to 192 and add another layer

then

N.B. In the layer information, there's a different tilePixelRatio set in the datasource of the layer, it seems the issue is not in the configuration dialog but the provider

Versions

QGIS 3.26 and master

Supported QGIS version

New profile

Additional context

No response

domi4484 commented 1 year ago

I looked at this issue and could reproduce the same behaviour. Changing the value of the combobox doesn't change the rendering of the map. I tried with normal and high dpi (@2x) services. Since the actual resolution is given by the tile itself I don't understand what is the point of this settings? Edit: That on a not-hidpi screen

m-kuhn commented 1 year ago

I have added sample configurations in all combinations

for

XYZ provider

Results on a hidpi screen:

So it seems to have some effect, but it seems confusing.

@wonder-sk does this make sense to you?

wonder-sk commented 1 year ago

Hi @m-kuhn hmm that's strange. The DPI settings do not work correctly for me anymore, yet I get slightly different results: all 6 options (96/192/unknown vs lowres/highres tiles) have the same appearance for me.

The way this was supposed to work last time when I was touching the code was that for raster tiles with labels (e.g. openstreetmap), lowres tiles would be showing up with tiny labels (both on high dpi desktop or phone) by default - that's the "unknown" option. So I added the options for 96 DPI and 192 DPI to let the user specify for what resolution the tiles were made for, to scale them properly. As a result, for OSM tiles if I would set 96 DPI, then the labels would get readable no matter screen DPI was.

I was thinking whether to even keep the "unknown" option, but it seemed useful e.g. for satellite imagery that does not contain labels, so one gets very crisp map on any DPI.

Not sure what could be the cause of the change of the behavior...

nirvn commented 1 year ago

@m-kuhn , alright, I've spent more time thinking about this. I think the current behavior is fine. On a normal DPI screen (i.e. 96 DPI), all the settings end up with the same map output, and that's because setting the option to 192 DPI merely indicates the tiles can go up to 192DPI, but will be downscaled on a 96DPI to match the targeted 96 DPI screen (i.e. 256 x 256 tiles).

When you will see a difference is whenever you consume the tiles on a high DPI screen:

This is most likely the right behavior as it allows for renderings across multiple DPI density to look roughly the same (vs. rendering 512x512 tiles without downscaling on a low DPI making everything look huge).

I think we can close this one, and maybe insure documentation properly describes the logic so none of us end up thinking it's not working again :)

@wonder-sk , as author of the original code, do you concur?

wonder-sk commented 1 year ago

hi @nirvn sorry for the slow response times... Yes what you say in your comment is exactly how things were meant to work: to scale up 256x256 tiles on high DPI screens, and use 512x512 tiles as they are for sharp look. On low DPI screens, 256x256 tiles get used as they are (no need for scaling), and 512x512 tiles should get scaled down (ideally 512x512px tiles should not be used on low DPI screens).

So yeah it is maybe a bit of a documentation issue.

Maybe a nice small improvement to fix this would be to allow multiple URLs for XYZ connections - e.g. one for low-res tiles (256x256px) and one for high-res tiles (512x512px), so QGIS would pick automatically the right one. High-res tiles could be possibly even auto-detected by checking the @2x convention when adding a connection...

alexbruy commented 10 months ago

Can be closed or better to keep it open?

m-kuhn commented 10 months ago

Checking again.

On a high resolution screen I don't see any difference between specifying 96 and 192dpi. Based on the explanation by @nirvn on a high res screen I should be seeing a difference (whereas on low res screens the setting will be ignored).

@wonder-sk on the other hand says, that tiles should be scaled up or down on low or high res screens.

Is someone actually able to confirm that the setting 96dpi or 192dpi does make a difference on their system?

Maybe a nice small improvement to fix this would be to allow multiple URLs for XYZ connections - e.g. one for low-res tiles (256x256px) and one for high-res tiles (512x512px), so QGIS would pick automatically the right one. High-res tiles could be possibly even auto-detected by checking the @2x convention when adding a connection...

This sounds like a very good proposal in any case :+1:

bsaglio2001 commented 6 months ago

Hello,

Please note that this setting for XYZ tiles connexion introduce distinct behaviours when rending layouts.

If my XYZ layer in my project is configured with Tile Resolution : Unknown (not scaled), then the zoom level of tiles is different depending on DPI resolution chosen for exporting the layout. See the following results. PNG AT 120DPI TEST 120dpi not scaled PNG AT 240DPI Much more details when zooming in the picture TEST 240dpi not scaled

If my XYZ layer in my project is configured with *Tile Resolution : Standard (256256 / 96DPI), then the zoom level for tiles is always the same, and there is only one DPI resolution for layout export that fits exactly the resolution of tiles. Compare with the following results. PNG AT 120DPI TEST 120dpi TileResolution 96dpi PNG AT 240DPI** Exactly the same detail when zooming in the picture, and in this case there is no benefit when increasing the layout resolution TEST 240dpi TileResolution 96dpi

nirvn commented 2 weeks ago

@bsaglio2001 , confirmed.

m-kuhn commented 2 weeks ago

Am I concluding correctly, that this setting has the desired effect when used for print layouts, but does not have an effect for on-screen rendering?

nirvn commented 2 weeks ago

@m-kuhn , the opposite. ATM, it works quite well on-screen, but it regressed within layouts (due to high dpi upgrades done during this year).

You can easily see this by adding an OSM layer (insuring that it has a known tile resolution), adding a layout and zooming in/out:

https://github.com/user-attachments/assets/808f9d65-3f1d-4059-b5a5-bd68e97cfddc

The logic regressed, resulting it what looks like an inverted calculation whereas the more you zoom out, the higher the the Z level. It's in the to do list for bug fixing period.