[QGIS-Developer] WMTS/XYZ on high DPI screens

Richard Duivenvoorde rdmailings at duif.net
Wed Feb 27 01:47:15 PST 2019


On 26/02/2019 17.23, Martin Dobias wrote:
> Hi all
> 
> Whenever I use a background map like OpenStreetMap on my high-res
> laptop screen (192 DPI) in QGIS, the labels are tiny. That is
> "natural" because tiles are made for screens with ~96 DPI where the
> size of labels is just fine. When I look at OSM tiles in the browser,
> I can see that the browser displays the tiles scaled ... so even
> though the tiles do not look super crisp, at least I do not need a
> magnifying glass to read labels.
> 
> A similar problem I have encountered before is when using tiles from
> WMTS/XYZ in print/PDF output: with higher resolution of print the
> rendering engine picks very detailed tiles which again may contain
> very tiny labels.
> 
> I would like to fix this in QGIS but I am wondering what would be the
> correct approach.
> 
> One simple (and wrong?) solution would be to just scale tiles of all
> tile layers, but I guess if the service displays some raw imagery it
> would be wasteful to scale them as this unnecessarily would remove
> details which could be still shown on high res display.
> 
> Other solution would be to introduce a new flag for WMTS/XYZ layers
> where users could set native DPI. By default this flag would be
> disabled, but for services like OSM one could explicitly set their DPI
> to 96 and get the tiles scaled accordingly. This would need an update
> of raster block request API as well where we would also need to
> specify output DPI in addition to output width/height (but that should
> not be a big deal).
> 
> This solution could also work nicely with services that provide
> high-res tiles (using 512x512 for each tile instead of 256x256) -
> right now QGIS thinks they are 256x256 so instead of a magnifying
> glass one needs a microscope - you can try it [1]. Setting explicitly
> DPI of high-res tiles to 192 DPI should also fix also that issue.
> 
> My only worry is if this setting is not going to be too difficult to
> use for ordinary users... But maybe a combo box would make the choice
> easier: "Normal resolution (96 DPI)" / "High resolution (192 DPI)" /
> "Custom resolution" (with a spin box).
> 
> Are there any opinions / ideas how to deal with that?

Hi Martin,

not sure if this is helpfull, but Matthijs of the OpenGeoGroep.nl
created a hidpi tilecache for mac users not so long ago for an Dutch,
osm based base map. I asked him what he did.  He says (translated):

"Yes we serve two versions, eg"

http://www.openbasiskaart.nl/mapcache/wmts/?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=osm-nb&STYLE=default&TILEMATRIXSET=rd&TILEMATRIX=5&TILEROW=16&TILECOL=15&FORMAT=image%2Fpng

http://www.openbasiskaart.nl/mapcache/wmts/?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=osm-nb-hq&STYLE=default&TILEMATRIXSET=rd-hq&TILEMATRIX=5&TILEROW=16&TILECOL=15&FORMAT=image%2Fpng

"Only the tileing protocol metadata is not really prepeared for HQ
tiles. I now set it up i a way that for HiDPI tiles you have use the
same TILEMATRIX, TILEROW en TILEROW, but you receive either a 256x256
tile or a 512x512 tile depending on the TILEMATRIXSET. But you have to
fool the tile server a little, so if you use current URL
(http://www.openbasiskaart.nl/mapcache and layer with HQ in QGIS) you
get big labels."

Maybe you can use the service to check/test?
(note hq is only in EPSG:28992)

Regards,

Richard Duivenvoorde





More information about the QGIS-Developer mailing list