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

Matthias Kuhn matthias at opengis.ch
Thu Feb 28 01:06:03 PST 2019


Hi

On 2/27/19 9:45 PM, Martin Dobias wrote:
> On Wed, Feb 27, 2019 at 1:03 PM Matthias Kuhn <matthias at opengis.ch> wrote:
>>> I am wondering if we should have three options for tile resolutions:
>>> - standard (96 DPI) ... autoscaled, for 256x256 tiles for XYZ tiles
>>> - high res (192 DPI) ... autoscaled, for 512x512 tiles for XYZ tiles
>>> - undefined ... not scaled
>> Sounds reasonable.
>>
>> I can see the following options for what a data provider can offer:
>>
>>   * A predefined set of available DPI from the server (e.g. XYZ)
>>
>>   * Manually specify DPI (e.g. as WMS parameter "DPI=300")
>>
>>   * No scaling available
> Right.
>
>
>> Some dataproviders might know what they can offer (WMS might include
>> that in the GetCapabilities, AFS maybe?), others might need
>> configuration on layer / data provider properties (XYZ, preconfigured
>> through QMS or ,qml/.qlr files).
> As mentioned in my earlier email, WMS, WMTS, XYZ have no way to tell
> the true DPI of tiles (as far as I know). AMS does but QGIS does not
> take it into account.

What I wanted to say is mostly that the API should be prepared for that
(or at least not prevent it) if possible, so AMS can be improved or an
enhanced WMS version can communicate what they offer natively.

>
>> I assume that it's also not always desired to get the maximum resolution.
>>
>> E.g. in HighRes atlas printing a WMS via a network connection with
>> "DPI=3000" parameter could be very slow, so the API should be prepared
>> to specify
>>
>>  * "data source DPI", i.e. what's requested from the provider
>>
>>  * and output device DPI, i.e. what it's scaled to for screen/paper
> 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?

> 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.

> 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.

Cheers
Matthias

>
> The PR does not address scaling issues with WMTS layers. Compared to
> XYZ layers where one connection = one tile layer, with WMTS there may
> be multiple tile layers within one connection, each with different DPI
> - and as mentioned above, WMTS does not provide information about DPI.
>
> Cheers
> Martin



More information about the QGIS-Developer mailing list