[QGIS-Developer] "GetMap" URL from WMS layers
Jakob Miksch
info at jakobmiksch.eu
Thu Apr 2 11:54:01 PDT 2020
Dear list,
@Jeff: Thanks for the tip. But I need a programmatic way using the
Python API how to extract the "GetMap" URL.
Currently I fixed my problem with OWSlib:
```
d = parse_qs(source)
url_get_capabilities = d['url'][0]
layers = d['layers'][0]
# request getMap URL via OWSLib
wms = WebMapService(url_get_capabilities)
url_get_map = wms.getOperationByName('GetMap').methods[0]['url'] ```
However, I am not that happy with this approach, because OWSlib makes
another request to the server. I mean, QGIS obviously knows the URL
already, but I cannot easily access it Python. Does anyone else have an
idea how the retrieve the "GetMap" URL? Thanks and best wishes, Jakob
On 31.03.20 16:54, Jeff McKenna wrote:
> Try Richard's great 'QGIS Network Logger' plugin, to see all WMS
> requests. I've recorded several options here to grab the GetMap url:
> https://github.com/mapserver/mapserver/wiki/Get-the-Raw-WMS-Request-Generated-by-QGIS
>
>
> -jeff
>
>
> --
> Jeff McKenna
> MapServer Consulting and Training Services
> https://gatewaygeomatics.com/
>
>
>
> On 2020-03-31 11:37 a.m., Jakob Miksch wrote:
>> Dear list,
>>
>> I want to extract the "GetMap" URL from WMS layers. For most of the
>> WMS layers I can extract it from "layer.source()". However this does
>> not work for WMS layers where "GetMap" and "GetCapabilities" is
>> different. Like for this layer:
>> https://www.geoportal.rlp.de/mapbender/php/wms.php?inspire=1&layer_id=69694&withChilds=1&INSPIRE=1&
>>
>>
>> The only place where I can find the "GetMap" URL is inside the
>> "layer.htmlMetadata()" document. From there the URL can be extracted
>> using REGEX. But every localization of QGIS (e.g. German, French ...)
>> have different terms for the surrounding "GetMap" HTML element. This
>> makes this approach quite tricky.
>>
>> Is there any more elegant solution how to retrieve the "GetMap" URL
>> from WMS layers?
>>
>> Thanks in advance and best wishes,
>> Jakob
>>
>
> _______________________________________________
> 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
--
Jakob Miksch
Geospatial Development
www.jakobmiksch.eu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20200402/c936954c/attachment.html>
More information about the QGIS-Developer
mailing list