-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preview of tiled layers (WMTS) + support XYZ tile layers #3473
Conversation
Otherwise we would end up with rendering artifacts due to overpainting
Yes, that means OpenStreetMap tiles and various other sources! No GUI so far...
... so we first receive tiles in the middle rather those at the border
Marked raster interface as uncopiable (it should have always been uncopiable)
Moved all temporary projector members to a private class, so even recursive block() calls will not affect each other (there is no new performance penalty as block() call always recomputes the temporary control point matrix anyway)
It would make sense to have it enabled by default with WMTS too
This makes it easier to get at least basic preview without having to wait until new tiles are downloaded. The strategy is to use tiles up to two levels lower resolution tiles and one level higher resolution tiles.
For those looking for Python API for XYZ tile layers: uri = QgsDataSourceUri()
uri.setParam("type", "xyz")
uri.setParam("url", "http://c.tile.openstreetmap.org/{z}/{x}/{y}.png")
layer = QgsRasterLayer(unicode(uri.encodedUri()), "OpenStreetMap", "wms") |
Thanks a lot, very useful. Probably good to add a bunch of default server, especially OSM? |
That's really good news! 👏 |
@wonder-sk , I was wondering what new feature would make me switch my daily QGIS build to master. This _ is _ it! 😄 |
YES! On Fri, 9 Sep 2016 7:31 pm Mathieu Pellerin notifications@github.com
|
@wonder-sk , @nyalldawson , yay, rotation support: |
@wonder-sk , suggestion: fix layer menu item's "zoom to native resolution (100%)" to have the zoom level change to the closest value to display pixel-perfect tiles at the current tile level. |
Ok, more findings:
|
I have fixed previews in Qt5 and an unrelated crash in Qt5. The crash mentioned above seems to be caused by a race in QgsNetworkAccessManager::createRequest(), specifically the part related to auth manager. @nirvn could you please confirm that the crash happens only if the layers use HTTPS protocol? |
|
||
if ( it == tileMatrices.constEnd() ) | ||
return nullptr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious - what's the change in qt5 which required this? It's hard to tell from this commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I should have explained it in the commit message... in Qt4 if the iterator is at the first item, going backwards will set the iterator to be equal to constEnd(). However in Qt5 this is not the case and it would just leave iterator in undefined state. So the main change in the commit is to first check if we are not already at constBegin() before going backwards. Probably this was changed to be in line with behavior of iterators of ordinary c++ containers... not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good insight. I m assuming these bits of knowledge will come in handy for other folks too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @wonder-sk - just helps to know what other potential issues we'll run into..
@wonder-sk , great I'll try the updated PR and report. |
@wonder-sk , preview/progressive rendering now works on Qt5, kudos. Regarding the QSocketNotifier, the error is actually caused by a delimited text layer I have in the project, not related to this PR. Removing that layer seems to get rid of the crasher (so good so far). I'll file a separate issue on the hub regarding this. |
Thanks for testing. If there are no objections, I will merge it later today. It would be best to create feature requests afterwards for any extra functionality. |
@wonder-sk , when the commit in PR #3483 is applied, I can't get this PR to crash anymore (with delimited text layer), yay. IMO, the absence of a user-friendly way to set a zmin / zmax will have to be addressed during this dev cycle for the XYZ support to be as good as it gets. Editing the .qgs file to add a &zmax=12 value to the string isn't a viable option ;) that said, happy to report adding such a zmax value to the datasource uri does work. |
@wonder-sk , just ran into a composer export to file issue, whereas not all tiles are rendered. Here's the project file: Simply open composer 6, and export (at 300dpi) the composer sheet to a .png. Over here, this is what I get: |
Max. 100 tiles is just too low. The max request area is currently 2000x2000 pixels which boils down to approx 8x8 tiles of size 256x256, therefore max 64 tiles. However this is the ideal case if the view scale matches the scale of tiles. If the map view scale is approx in between two levels, we may need 12x12 tiles to serve the request, so bumping the maximum to 256 should be enough.
|
The recent test failure is unrelated, looks like a false positive in testziplayer. |
Seen these too many times but never a real alarm from this test, would be good to turn it off. |
@m-kuhn is it always the tar test which fails? Maybe we should just disable this one on Travis rather than the whole lot? (But otherwise, yes let's blacklist this) |
@wonder-sk , composer export fixed. I've now emptied my bag of comments ;) great work. |
@wonder-sk was playing with this today and it works really well. very smooth! One thing I'm not sure about is the "grid" image used as a temporary placeholder. To me this is very distracting and I don't think it's necessary - we don't use placeholders for other providers while rendering is underway. Are you attached to this behaviour? |
@nyalldawson thanks! Nope I'm not attached to the temporary grid 😄 It was helpful when debugging some issues when loading tiles, we can get rid of it now... |
Hi @wonder-sk
Mac 10.11.6 |
@Gustry does it help if you add Just wondering - what platform is that? (all other platforms seem to build fine) |
Ok, it seems I'm not alone with some problem about exp10 on mac : I made a fix @wonder-sk |
@wonder-sk Hi Martin, nice! I'm wondering though how you determine the 'native resolution'? FYI: these are the native resolutions for our national schema (epsg:28992):
Taken from: http://www.geonovum.nl/sites/default/files/nederlandse_richtlijn_tiling_-_versie_1.1.pdf FYI2: the tile-slider picked up the right scale values (IF you enalbe the slide and make the wmts layer active) |
Native resolution of rasters does not always make sense. For GDAL rasters we have the true resolution of the whole layer, but that's not really the case for WMS/WMTS/XYZ where there may be multiple native resolutions. Calling Tile scale dock widget is currently the way how to switch between scales that are native to WMTS/XYZ layers. Internally, the widget calls Please note that my recent work has not touched any of this existing functionality - this is just an explanation how things work. The context menu could get some more love to better support WMS/WMTS/XYZ layers |
This introduces live preview when rendering WMTS layers - as soon as individual tiles are loaded, they are shown in map canvas... no need to wait with a blank map until all tiles are fully downloaded. Additionally, if there are already locally cached tiles of other zoom levels, they may be used in the preview while the tiles with best matching zoom level are being downloaded. This greatly improves the user experience when working with WMTS layers.
Additionally, I have added native support for XYZ tile layers into WMS provider (based on existing implementation of WMTS tiling). This allows loading of various new raster tile sources (e.g. OpenStreetMap tiles) that were before available only with QuickMapServices or OpenLayers plugins. To use XYZ tile layers, open the browser dock in QGIS and look for "Tile Servers (XYZ)" root entry. Right-clicking will open a menu to add connections. For example for OpenStreetMap the URL would be
http://c.tile.openstreetmap.org/{z}/{x}/{y}.png
The work on WMTS live preview has been funded by Land Information New Zealand.
The work on XYZ tile layers has been funded by Lutra Consulting.