27#define PROVIDER_KEY QStringLiteral( "vectortile" )
28#define PROVIDER_DESCRIPTION QStringLiteral( "Vector tile provider" )
30QgsVectorTileProviderMetadata::QgsVectorTileProviderMetadata()
35QIcon QgsVectorTileProviderMetadata::icon()
const
40QList<QgsDataItemProvider *> QgsVectorTileProviderMetadata::dataItemProviders()
const
42 QList< QgsDataItemProvider * > providers;
43 providers <<
new QgsVectorTileDataItemProvider;
47QMap<QString, QgsAbstractProviderConnection *> QgsVectorTileProviderMetadata::connections(
bool cached )
49 return connectionsProtected<QgsVectorTileProviderConnection, QgsVectorTileProviderConnection>( cached );
54 return new QgsVectorTileProviderConnection( name );
57void QgsVectorTileProviderMetadata::deleteConnection(
const QString &name )
59 deleteConnectionProtected<QgsVectorTileProviderConnection>( name );
64 saveConnectionProtected( connection, name );
67QgsProviderMetadata::ProviderCapabilities QgsVectorTileProviderMetadata::providerCapabilities()
const
72QVariantMap QgsVectorTileProviderMetadata::decodeUri(
const QString &uri )
const
77 QVariantMap uriComponents;
78 uriComponents.insert( QStringLiteral(
"type" ), dsUri.
param( QStringLiteral(
"type" ) ) );
79 if ( dsUri.
hasParam( QStringLiteral(
"serviceType" ) ) )
80 uriComponents.insert( QStringLiteral(
"serviceType" ), dsUri.
param( QStringLiteral(
"serviceType" ) ) );
82 if ( uriComponents[ QStringLiteral(
"type" ) ] == QLatin1String(
"mbtiles" ) ||
83 ( uriComponents[ QStringLiteral(
"type" ) ] == QLatin1String(
"xyz" ) &&
84 !dsUri.
param( QStringLiteral(
"url" ) ).startsWith( QLatin1String(
"http" ) ) ) )
86 uriComponents.insert( QStringLiteral(
"path" ), dsUri.
param( QStringLiteral(
"url" ) ) );
90 uriComponents.insert( QStringLiteral(
"url" ), dsUri.
param( QStringLiteral(
"url" ) ) );
93 if ( dsUri.
hasParam( QStringLiteral(
"zmin" ) ) )
94 uriComponents.insert( QStringLiteral(
"zmin" ), dsUri.
param( QStringLiteral(
"zmin" ) ) );
95 if ( dsUri.
hasParam( QStringLiteral(
"zmax" ) ) )
96 uriComponents.insert( QStringLiteral(
"zmax" ), dsUri.
param( QStringLiteral(
"zmax" ) ) );
100 if ( dsUri.
hasParam( QStringLiteral(
"styleUrl" ) ) )
101 uriComponents.insert( QStringLiteral(
"styleUrl" ), dsUri.
param( QStringLiteral(
"styleUrl" ) ) );
104 if ( !authcfg.isEmpty() )
105 uriComponents.insert( QStringLiteral(
"authcfg" ), authcfg );
107 return uriComponents;
110QString QgsVectorTileProviderMetadata::encodeUri(
const QVariantMap &parts )
const
113 dsUri.
setParam( QStringLiteral(
"type" ), parts.value( QStringLiteral(
"type" ) ).toString() );
114 if ( parts.contains( QStringLiteral(
"serviceType" ) ) )
115 dsUri.
setParam( QStringLiteral(
"serviceType" ), parts[ QStringLiteral(
"serviceType" ) ].toString() );
116 dsUri.
setParam( QStringLiteral(
"url" ), parts.value( parts.contains( QStringLiteral(
"path" ) ) ? QStringLiteral(
"path" ) : QStringLiteral(
"url" ) ).toString() );
118 if ( parts.contains( QStringLiteral(
"zmin" ) ) )
119 dsUri.
setParam( QStringLiteral(
"zmin" ), parts[ QStringLiteral(
"zmin" ) ].toString() );
120 if ( parts.contains( QStringLiteral(
"zmax" ) ) )
121 dsUri.
setParam( QStringLiteral(
"zmax" ), parts[ QStringLiteral(
"zmax" ) ].toString() );
125 if ( parts.contains( QStringLiteral(
"styleUrl" ) ) )
126 dsUri.
setParam( QStringLiteral(
"styleUrl" ), parts[ QStringLiteral(
"styleUrl" ) ].toString() );
128 if ( parts.contains( QStringLiteral(
"authcfg" ) ) )
129 dsUri.
setAuthConfigId( parts[ QStringLiteral(
"authcfg" ) ].toString() );
134QString QgsVectorTileProviderMetadata::absoluteToRelativeUri(
const QString &uri,
const QgsReadWriteContext &context )
const
139 const QString sourceType = dsUri.
param( QStringLiteral(
"type" ) );
140 QString sourcePath = dsUri.
param( QStringLiteral(
"url" ) );
141 if ( sourceType == QLatin1String(
"xyz" ) )
143 const QUrl sourceUrl( sourcePath );
144 if ( sourceUrl.isLocalFile() )
149 dsUri.
setParam( QStringLiteral(
"url" ), QUrl::fromLocalFile( relSrcUrl ).toString() );
153 else if ( sourceType == QLatin1String(
"mbtiles" ) )
157 dsUri.
setParam( QStringLiteral(
"url" ), sourcePath );
164QString QgsVectorTileProviderMetadata::relativeToAbsoluteUri(
const QString &uri,
const QgsReadWriteContext &context )
const
169 const QString sourceType = dsUri.
param( QStringLiteral(
"type" ) );
170 QString sourcePath = dsUri.
param( QStringLiteral(
"url" ) );
171 if ( sourceType == QLatin1String(
"xyz" ) )
173 const QUrl sourceUrl( sourcePath );
174 if ( sourceUrl.isLocalFile() )
178 dsUri.
setParam( QStringLiteral(
"url" ), QUrl::fromLocalFile( absSrcUrl ).toString() );
182 else if ( sourceType == QLatin1String(
"mbtiles" ) )
186 dsUri.
setParam( QStringLiteral(
"url" ), sourcePath );
193QList<Qgis::LayerType> QgsVectorTileProviderMetadata::supportedLayerTypes()
const
195 return { Qgis::LayerType::VectorTile };
The QgsAbstractProviderConnection provides an interface for data provider connections.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Class for storing the component parts of a RDBMS data source URI (e.g.
QByteArray encodedUri() const
Returns the complete encoded URI as a byte array.
bool hasParam(const QString &key) const
Returns true if a parameter with the specified key exists.
int removeParam(const QString &key)
Removes a generic parameter by key.
void setEncodedUri(const QByteArray &uri)
Sets the complete encoded uri.
void setAuthConfigId(const QString &authcfg)
Sets the authentication configuration ID for the URI.
QgsHttpHeaders httpHeaders() const
Returns http headers.
QString param(const QString &key) const
Returns a generic parameter value corresponding to the specified key.
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI.
QString authConfigId() const
Returns any associated authentication configuration ID stored in the URI.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
The class is used as a container of context for various read/write operations on other objects.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.