[QGIS-Developer] PyQGIS WMS tiles don't load on Windows

Jonathan Moules jonathan-lists at lightpear.com
Tue Apr 9 12:00:14 PDT 2019


Hi Erik,

(Staying on list)

I'm afraid I can't help you with QGIS stuff as I don't know anything 
about the code-base. Just wanted to clear up confusion.

That Google service is definitely not a WMS service. To get a maptile 
via WMS it would have this in the query string somewhere: 
&request=getmap&service=WMS&version= at the minimum. Most OGC services 
build URLs similar that, so they're easy to spot.

Other map service types are TMS (which is most similar to Google map 
tiles and OSM tile services) and WMTS (a more complex version of TMS). 
Both are designed for sharing basemap tiles. It took me a while to get 
my head around the different types too!

Cheers,

Jonathan


On 2019-04-09 19:53, Erik Polzin wrote:
> Hi Jonathan,
> Thanks for your reply.
>
> I'd been reading through some of the documentation on the OGC specifications
> <https://docs.qgis.org/testing/en/docs/user_manual/working_with_ogc/ogc_client_support.html>,
> and came across those URLs to the google maps servers elsewhere. So I
> glanced at the data from this url
> https://mt1.google.com/vt?lyrs=s&x=0&y=0&z=0, and thought it looked like a
> WMS server - so hardly an educated approach!
> But, like I mentioned, that source works fine in the full-blown QGIS app
> (as a WMS layer).
>
> But I haven't been working with map servers for very long - so I guess my
> question is what other options for server types are there? You mention that
> Google has a non-WMS based service. Anywhere you know of I can find out
> more about this? Can I use it through QGIS?
>
> I appreciate the help,
> Erik
>
> On Tue, Apr 9, 2019 at 6:25 PM Jonathan Moules <jonathan-lists at lightpear.com>
> wrote:
>
>> Hi Erik,
>>
>> I think maybe there's a nomenclature problem here. I wasn't aware that any
>> Google services were available via WMS.
>>
>> WMS is a specific specification, and if you're googling around using that
>> term you're going to find results that aren't pertinent to what you
>> actually want to do (which is using Google's tile based, non-WMS services).
>>
>> Cheers,
>>
>> Jonathan
>>
>>
>> On 2019-04-09 08:54, Erik Polzin wrote:
>>
>> I'm busy developing an app using the QGIS Python api, PyQGIS, and am
>> noticing some strange behaviour when loading WMS tiles: Running the python
>> script on Linux Mint loads xyz layers from Google Maps and Google Satellite
>> just fine. On Windows, only the Google Maps layer loads.
>>
>> Here is a test script I wrote to demonstrate the problem:
>>
>> from qgis.core import QgsApplication, QgsProject, QgsRasterLayer
>> from qgis.gui import QgsMapCanvas, QgsLayerTreeMapCanvasBridge
>>
>> from PyQt5.QtWidgets import QMainWindow
>> import os
>>
>> GOOGLE_MAPS_SOURCE = "type=xyz&url=https://mt1.google.com/vt?lyrs%3Dm%26x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D&zmax=19&zmin=0
>> "
>> GOOGLE_SATELLITE_SOURCE = "type=xyz&url=https://mt1.google.com/vt?lyrs%3Ds%26x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D&zmax=19&zmin=0
>> "
>>
>> class WMSTestApp(QMainWindow):
>>
>>      def __init__(self):
>>          super().__init__()
>>
>>          self.canvas = QgsMapCanvas(self)
>>          self.bridge =
>> QgsLayerTreeMapCanvasBridge(QgsProject.instance().layerTreeRoot(),
>> self.canvas)
>>
>>          layer = QgsRasterLayer(GOOGLE_SATELLITE_SOURCE, "Test WMS Layer",
>> "wms")
>>
>>          QgsProject.instance().addMapLayer(layer)
>>          self.canvas.setLayers([layer])
>>
>>          self.setCentralWidget(self.canvas)
>>
>>
>> QgsApplication.setPrefixPath(os.environ.get("QGIS_PREFIX_PATH", "C:\Program
>> Files\QGIS 3.4\apps\qgis"), True)
>> qgs = QgsApplication([], True)
>> qgs.initQgis()
>>
>> app = WMSTestApp()
>> app.show()
>> qgs.exec_()
>> qgs.exitQgis()
>>
>> Interestingly, the layers (from the same sources!) both load from the
>> Windows QGIS app.
>> So I did some digging and noticed that the default Google Maps url returns
>> PNG files, while the Satellite url returns JPEGs. I tested a couple of
>> other links, and it seems like only PNG tile servers have any effect on
>> windows systems.
>>
>> Have tested this on Windows 7 and 10, with the same results.
>>
>> Does PyQgis need to be reconfigured in some way to get this to work? Or is
>> it a known issue with the version (3.4) I'm using?
>>
>> Cheers and thanks,
>> Erik
>>
>>
>>
>> _______________________________________________
>> QGIS-Developer mailing listQGIS-Developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer



More information about the QGIS-Developer mailing list