17#include "moc_qgsvectortileprovidermetadata.cpp" 
   28#define PROVIDER_KEY QStringLiteral( "vectortile" ) 
   29#define PROVIDER_DESCRIPTION QStringLiteral( "Vector tile provider" ) 
   31QgsVectorTileProviderMetadata::QgsVectorTileProviderMetadata()
 
   36QIcon QgsVectorTileProviderMetadata::icon()
 const 
   41QList<QgsDataItemProvider *> QgsVectorTileProviderMetadata::dataItemProviders()
 const 
   43  QList< QgsDataItemProvider * > providers;
 
   44  providers << 
new QgsVectorTileDataItemProvider;
 
   48QMap<QString, QgsAbstractProviderConnection *> QgsVectorTileProviderMetadata::connections( 
bool cached )
 
   50  return connectionsProtected<QgsVectorTileProviderConnection, QgsVectorTileProviderConnection>( cached );
 
   55  return new QgsVectorTileProviderConnection( name );
 
   58void QgsVectorTileProviderMetadata::deleteConnection( 
const QString &name )
 
   60  deleteConnectionProtected<QgsVectorTileProviderConnection>( name );
 
   65  saveConnectionProtected( connection, name );
 
   73QVariantMap QgsVectorTileProviderMetadata::decodeUri( 
const QString &uri )
 const 
   78  QVariantMap uriComponents;
 
   79  uriComponents.insert( QStringLiteral( 
"type" ), dsUri.
param( QStringLiteral( 
"type" ) ) );
 
   80  if ( dsUri.
hasParam( QStringLiteral( 
"serviceType" ) ) )
 
   81    uriComponents.insert( QStringLiteral( 
"serviceType" ), dsUri.
param( QStringLiteral( 
"serviceType" ) ) );
 
   83  if ( uriComponents[ QStringLiteral( 
"type" ) ] == QLatin1String( 
"mbtiles" ) ||
 
   84       ( uriComponents[ QStringLiteral( 
"type" ) ] == QLatin1String( 
"xyz" ) &&
 
   85         !dsUri.
param( QStringLiteral( 
"url" ) ).startsWith( QLatin1String( 
"http" ) ) ) )
 
   87    uriComponents.insert( QStringLiteral( 
"path" ), dsUri.
param( QStringLiteral( 
"url" ) ) );
 
   91    uriComponents.insert( QStringLiteral( 
"url" ), dsUri.
param( QStringLiteral( 
"url" ) ) );
 
   94  if ( dsUri.
hasParam( QStringLiteral( 
"zmin" ) ) )
 
   95    uriComponents.insert( QStringLiteral( 
"zmin" ), dsUri.
param( QStringLiteral( 
"zmin" ) ) );
 
   96  if ( dsUri.
hasParam( QStringLiteral( 
"zmax" ) ) )
 
   97    uriComponents.insert( QStringLiteral( 
"zmax" ), dsUri.
param( QStringLiteral( 
"zmax" ) ) );
 
  101  if ( dsUri.
hasParam( QStringLiteral( 
"styleUrl" ) ) )
 
  102    uriComponents.insert( QStringLiteral( 
"styleUrl" ), dsUri.
param( QStringLiteral( 
"styleUrl" ) ) );
 
  105  if ( !authcfg.isEmpty() )
 
  106    uriComponents.insert( QStringLiteral( 
"authcfg" ), authcfg );
 
  108  return uriComponents;
 
  111QString QgsVectorTileProviderMetadata::encodeUri( 
const QVariantMap &parts )
 const 
  114  dsUri.
setParam( QStringLiteral( 
"type" ), parts.value( QStringLiteral( 
"type" ) ).toString() );
 
  115  if ( parts.contains( QStringLiteral( 
"serviceType" ) ) )
 
  116    dsUri.
setParam( QStringLiteral( 
"serviceType" ), parts[ QStringLiteral( 
"serviceType" ) ].toString() );
 
  117  dsUri.
setParam( QStringLiteral( 
"url" ), parts.value( parts.contains( QStringLiteral( 
"path" ) ) ? QStringLiteral( 
"path" ) : QStringLiteral( 
"url" ) ).toString() );
 
  119  if ( parts.contains( QStringLiteral( 
"zmin" ) ) )
 
  120    dsUri.
setParam( QStringLiteral( 
"zmin" ), parts[ QStringLiteral( 
"zmin" ) ].toString() );
 
  121  if ( parts.contains( QStringLiteral( 
"zmax" ) ) )
 
  122    dsUri.
setParam( QStringLiteral( 
"zmax" ), parts[ QStringLiteral( 
"zmax" ) ].toString() );
 
  126  if ( parts.contains( QStringLiteral( 
"styleUrl" ) ) )
 
  127    dsUri.
setParam( QStringLiteral( 
"styleUrl" ), parts[ QStringLiteral( 
"styleUrl" ) ].toString() );
 
  129  if ( parts.contains( QStringLiteral( 
"authcfg" ) ) )
 
  130    dsUri.
setAuthConfigId( parts[ QStringLiteral( 
"authcfg" ) ].toString() );
 
  135QString QgsVectorTileProviderMetadata::absoluteToRelativeUri( 
const QString &uri, 
const QgsReadWriteContext &context )
 const 
  140  const QString sourceType = dsUri.
param( QStringLiteral( 
"type" ) );
 
  141  QString sourcePath = dsUri.
param( QStringLiteral( 
"url" ) );
 
  142  if ( sourceType == QLatin1String( 
"xyz" ) )
 
  144    const QUrl sourceUrl( sourcePath );
 
  145    if ( sourceUrl.isLocalFile() )
 
  150      dsUri.
setParam( QStringLiteral( 
"url" ), QUrl::fromLocalFile( relSrcUrl ).toString() );
 
  154  else if ( sourceType == QLatin1String( 
"mbtiles" ) )
 
  158    dsUri.
setParam( QStringLiteral( 
"url" ), sourcePath );
 
  165QString QgsVectorTileProviderMetadata::relativeToAbsoluteUri( 
const QString &uri, 
const QgsReadWriteContext &context )
 const 
  170  const QString sourceType = dsUri.
param( QStringLiteral( 
"type" ) );
 
  171  QString sourcePath = dsUri.
param( QStringLiteral( 
"url" ) );
 
  172  if ( sourceType == QLatin1String( 
"xyz" ) )
 
  174    const QUrl sourceUrl( sourcePath );
 
  175    if ( sourceUrl.isLocalFile() )  
 
  179      dsUri.
setParam( QStringLiteral( 
"url" ), QUrl::fromLocalFile( absSrcUrl ).toString() );
 
  183  else if ( sourceType == QLatin1String( 
"mbtiles" ) )
 
  187    dsUri.
setParam( QStringLiteral( 
"url" ), sourcePath );
 
  194QList<Qgis::LayerType> QgsVectorTileProviderMetadata::supportedLayerTypes()
 const 
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
 
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.