25#include "moc_qgsvectortileprovidermetadata.cpp"
29#define PROVIDER_KEY QStringLiteral( "vectortile" )
30#define PROVIDER_DESCRIPTION QStringLiteral( "Vector tile provider" )
32QgsVectorTileProviderMetadata::QgsVectorTileProviderMetadata()
37QIcon QgsVectorTileProviderMetadata::icon()
const
42QList<QgsDataItemProvider *> QgsVectorTileProviderMetadata::dataItemProviders()
const
44 QList< QgsDataItemProvider * > providers;
45 providers <<
new QgsVectorTileDataItemProvider;
49QMap<QString, QgsAbstractProviderConnection *> QgsVectorTileProviderMetadata::connections(
bool cached )
51 return connectionsProtected<QgsVectorTileProviderConnection, QgsVectorTileProviderConnection>( cached );
56 return new QgsVectorTileProviderConnection( name );
59void QgsVectorTileProviderMetadata::deleteConnection(
const QString &name )
61 deleteConnectionProtected<QgsVectorTileProviderConnection>( name );
66 saveConnectionProtected( connection, name );
74QVariantMap QgsVectorTileProviderMetadata::decodeUri(
const QString &uri )
const
79 QVariantMap uriComponents;
80 uriComponents.insert( QStringLiteral(
"type" ), dsUri.
param( QStringLiteral(
"type" ) ) );
81 if ( dsUri.
hasParam( QStringLiteral(
"serviceType" ) ) )
82 uriComponents.insert( QStringLiteral(
"serviceType" ), dsUri.
param( QStringLiteral(
"serviceType" ) ) );
84 if ( uriComponents[ QStringLiteral(
"type" ) ] == QLatin1String(
"mbtiles" ) ||
85 ( uriComponents[ QStringLiteral(
"type" ) ] == QLatin1String(
"xyz" ) &&
86 !dsUri.
param( QStringLiteral(
"url" ) ).startsWith( QLatin1String(
"http" ) ) ) )
88 uriComponents.insert( QStringLiteral(
"path" ), dsUri.
param( QStringLiteral(
"url" ) ) );
92 uriComponents.insert( QStringLiteral(
"url" ), dsUri.
param( QStringLiteral(
"url" ) ) );
95 if ( dsUri.
hasParam( QStringLiteral(
"zmin" ) ) )
96 uriComponents.insert( QStringLiteral(
"zmin" ), dsUri.
param( QStringLiteral(
"zmin" ) ) );
97 if ( dsUri.
hasParam( QStringLiteral(
"zmax" ) ) )
98 uriComponents.insert( QStringLiteral(
"zmax" ), dsUri.
param( QStringLiteral(
"zmax" ) ) );
102 if ( dsUri.
hasParam( QStringLiteral(
"styleUrl" ) ) )
103 uriComponents.insert( QStringLiteral(
"styleUrl" ), dsUri.
param( QStringLiteral(
"styleUrl" ) ) );
106 if ( !authcfg.isEmpty() )
107 uriComponents.insert( QStringLiteral(
"authcfg" ), authcfg );
109 return uriComponents;
112QString QgsVectorTileProviderMetadata::encodeUri(
const QVariantMap &parts )
const
115 dsUri.
setParam( QStringLiteral(
"type" ), parts.value( QStringLiteral(
"type" ) ).toString() );
116 if ( parts.contains( QStringLiteral(
"serviceType" ) ) )
117 dsUri.
setParam( QStringLiteral(
"serviceType" ), parts[ QStringLiteral(
"serviceType" ) ].toString() );
118 dsUri.
setParam( QStringLiteral(
"url" ), parts.value( parts.contains( QStringLiteral(
"path" ) ) ? QStringLiteral(
"path" ) : QStringLiteral(
"url" ) ).toString() );
120 if ( parts.contains( QStringLiteral(
"zmin" ) ) )
121 dsUri.
setParam( QStringLiteral(
"zmin" ), parts[ QStringLiteral(
"zmin" ) ].toString() );
122 if ( parts.contains( QStringLiteral(
"zmax" ) ) )
123 dsUri.
setParam( QStringLiteral(
"zmax" ), parts[ QStringLiteral(
"zmax" ) ].toString() );
127 if ( parts.contains( QStringLiteral(
"styleUrl" ) ) )
128 dsUri.
setParam( QStringLiteral(
"styleUrl" ), parts[ QStringLiteral(
"styleUrl" ) ].toString() );
130 if ( parts.contains( QStringLiteral(
"authcfg" ) ) )
131 dsUri.
setAuthConfigId( parts[ QStringLiteral(
"authcfg" ) ].toString() );
136QString QgsVectorTileProviderMetadata::absoluteToRelativeUri(
const QString &uri,
const QgsReadWriteContext &context )
const
141 const QString sourceType = dsUri.
param( QStringLiteral(
"type" ) );
142 QString sourcePath = dsUri.
param( QStringLiteral(
"url" ) );
143 if ( sourceType == QLatin1String(
"xyz" ) )
145 const QUrl sourceUrl( sourcePath );
146 if ( sourceUrl.isLocalFile() )
151 dsUri.
setParam( QStringLiteral(
"url" ), QUrl::fromLocalFile( relSrcUrl ).toString( QUrl::DecodeReserved ) );
155 else if ( sourceType == QLatin1String(
"mbtiles" ) )
159 dsUri.
setParam( QStringLiteral(
"url" ), sourcePath );
166QString QgsVectorTileProviderMetadata::relativeToAbsoluteUri(
const QString &uri,
const QgsReadWriteContext &context )
const
171 const QString sourceType = dsUri.
param( QStringLiteral(
"type" ) );
172 QString sourcePath = dsUri.
param( QStringLiteral(
"url" ) );
173 if ( sourceType == QLatin1String(
"xyz" ) )
175 const QUrl sourceUrl( sourcePath );
176 if ( sourceUrl.isLocalFile() )
180 dsUri.
setParam( QStringLiteral(
"url" ), QUrl::fromLocalFile( absSrcUrl ).toString( QUrl::DecodeReserved ) );
184 else if ( sourceType == QLatin1String(
"mbtiles" ) )
188 dsUri.
setParam( QStringLiteral(
"url" ), sourcePath );
195QList<Qgis::LayerType> QgsVectorTileProviderMetadata::supportedLayerTypes()
const
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
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.
Stores the component parts of a 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.
A container for the context for various read/write operations on objects.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.