[QGIS-Developer] WMTS/XYZ on high DPI screens
Martin Dobias
wonder.sk at gmail.com
Thu Feb 28 02:58:50 PST 2019
On Thu, Feb 28, 2019 at 10:06 AM Matthias Kuhn <matthias at opengis.ch> wrote:
> > To specify output device DPI there's already
> > QgsRasterDataProvider::setDpi() call which is also used when drawing
> > raster layers.
>
> Hmm... I see the docstring that says output device. How does it work
> that the provider can hold the output device DPI, when the same provider
> will be used for printing and screen rendering? I was assuming that the
> output device DPI will be specified per request / rendering context. Or
> maybe I have a different understanding of what output device DPI means?
The "trick" is that when rendering rasters, the provider gets copied
(equivalent of copying feature sources of vector layers) to make sure
we will have a local copy for rendering in background. DPI is set in
QgsRasterLayerRenderer before the provider is copied, so for each map
render we have the correct DPI stored in local provider copy. I am not
saying I like this approach - ideally DPI should be a part of block
request - but this already works so probably it's something to address
in QGIS 4 API.
> > I am not sure how do you mean it with specification of "data source
> > DPI" ... if I have a tileset with 96 DPI, do you mean that option
> > should allow overriding of the source DPI?
>
> Yes, at least for all data sources that do not natively support
> reporting the real DPI (so for most if I understand you correctly).
>
> For those sources, 96 is just a guess (even though a quite common and
> probable one).
>
> E.g. it could be interesting to use file based tiled layers with
> pyramids holding different levels of generalization rendered for HiDPI
> as basemaps which need to be scaled down on screens with 96 DPI.
With my PR I believe this should work correctly with XYZ layers: if
both source and output DPIs are defined, the "best" tile resolution is
adjusted based on their ratio.
> > In any case, here's my take on fixing three problems in one go:
> > - correct rendering of XYZ tiles on high res screen (and in print output)
> > - correct rendering of high resolution XYZ tiles (on any screen)
> > https://github.com/qgis/QGIS/pull/9296
>
> That looks like a good improvement, isolated to WMS, XYZ providers and
> not affecting any public API from what I can see.
Thanks. That PR does not affect WMS at all. It only affects XYZ and it
prepares ground for WMTS (for it we need a mechanism to set DPI for
WMTS tilelesets).
Cheers
Martin
More information about the QGIS-Developer
mailing list