QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
qgswmsutils.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgswmsutils.cpp
3
---------------
4
begin : September 2025
5
copyright : (C) 2025 by Germán Carrillo
6
email : german at opengis dot ch
7
***************************************************************************/
8
9
/***************************************************************************
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
***************************************************************************/
17
18
#include "
qgswmsutils.h
"
19
20
#include "
qgsproviderregistry.h
"
21
22
#include <QString>
23
24
using namespace
Qt::StringLiterals;
25
26
bool
QgsWmsUtils::isWmsLayer
(
QgsMapLayer
*layer )
27
{
28
if
( !layer || layer->
providerType
() !=
"wms"
_L1 )
29
return
false
;
30
31
// Discard WMTS layers
32
const
QString url = layer->
publicSource
();
33
if
( url.contains(
"SERVICE=WMTS"
_L1, Qt::CaseInsensitive ) || url.contains(
"/WMTSCapabilities.xml"
_L1, Qt::CaseInsensitive ) )
34
{
35
return
false
;
36
}
37
38
// Discard XYZ layers
39
const
QVariantMap parts =
QgsProviderRegistry::instance
()->
decodeUri
( u
"wms"
_s, layer->
source
() );
40
if
( parts.value( u
"type"
_s ).toString() ==
"xyz"
_L1 )
41
{
42
return
false
;
43
}
44
45
return
true
;
46
}
47
48
QString
QgsWmsUtils::wmsVersion
(
QgsRasterLayer
*layer )
49
{
50
if
( !layer || !layer->
dataProvider
() || !
QgsWmsUtils::isWmsLayer
( layer ) )
51
return
QString();
52
53
return
layer->
dataProvider
()->
metadata
().value( u
"WmsVersion"
_s, QString() ).toString();
54
}
QgsDataProvider::metadata
virtual QVariantMap metadata() const
Returns provider specific metadata.
Definition
qgsdataprovider.h:177
QgsMapLayer
Base class for all map layer types.
Definition
qgsmaplayer.h:83
QgsMapLayer::source
QString source() const
Returns the source for the layer.
Definition
qgsmaplayer.cpp:515
QgsMapLayer::providerType
QString providerType() const
Returns the provider type (provider key) for this layer.
Definition
qgsmaplayer.cpp:2457
QgsMapLayer::publicSource
QString publicSource(bool hidePassword=false) const
Gets a version of the internal layer definition that has sensitive bits removed (for example,...
Definition
qgsmaplayer.cpp:499
QgsProviderRegistry::decodeUri
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
Definition
qgsproviderregistry.cpp:656
QgsProviderRegistry::instance
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Definition
qgsproviderregistry.cpp:86
QgsRasterLayer
Represents a raster layer.
Definition
qgsrasterlayer.h:82
QgsRasterLayer::dataProvider
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
Definition
qgsrasterlayer.cpp:330
QgsWmsUtils::wmsVersion
static QString wmsVersion(QgsRasterLayer *layer)
Returns the WMS version of a WMS layer as a string (e.g., "1.3.0").
Definition
qgswmsutils.cpp:48
QgsWmsUtils::isWmsLayer
static bool isWmsLayer(QgsMapLayer *layer)
Returns whether a map layer is an OGC WMS layer or not.
Definition
qgswmsutils.cpp:26
qgswmsutils.h
qgsproviderregistry.h
Generated on
for QGIS API Documentation by
1.17.0