31QString QgsVtpkVectorTileDataProvider::DATA_PROVIDER_KEY = QStringLiteral( 
"vtpkvectortiles" );
 
   32QString QgsVtpkVectorTileDataProvider::DATA_PROVIDER_DESCRIPTION = QObject::tr( 
"VTPK Vector Tiles data provider" );
 
   35QgsVtpkVectorTileDataProvider::QgsVtpkVectorTileDataProvider( 
const QString &uri, 
const ProviderOptions &providerOptions, ReadFlags flags )
 
   40  const QString sourcePath = dsUri.
param( QStringLiteral( 
"url" ) );
 
   45    QgsDebugError( QStringLiteral( 
"failed to open VTPK file: " ) + sourcePath );
 
   50  const QVariantMap metadata = reader.metadata();
 
   51  const QString format = metadata.value( QStringLiteral( 
"tileInfo" ) ).toMap().value( QStringLiteral( 
"format" ) ).toString();
 
   52  if ( format != QLatin1String( 
"pbf" ) )
 
   54    QgsDebugError( QStringLiteral( 
"Cannot open VTPK for vector tiles. Format = " ) + format );
 
   59  mMatrixSet = reader.matrixSet();
 
   60  mCrs = mMatrixSet.crs();
 
   61  mExtent = reader.extent( transformContext() );
 
   62  mLayerMetadata = reader.layerMetadata();
 
   63  mStyleDefinition = reader.styleDefinition();
 
   64  mSpriteDefinition = reader.spriteDefinition();
 
   65  if ( !mSpriteDefinition.isEmpty() )
 
   67    mSpriteImage = reader.spriteImage();
 
   73QgsVtpkVectorTileDataProvider::QgsVtpkVectorTileDataProvider( 
const QgsVtpkVectorTileDataProvider &other )
 
   76  mIsValid = other.mIsValid;
 
   78  mExtent = other.mExtent;
 
   79  mMatrixSet = other.mMatrixSet;
 
   80  mLayerMetadata = other.mLayerMetadata;
 
   81  mStyleDefinition = other.mStyleDefinition;
 
   82  mSpriteDefinition = other.mSpriteDefinition;
 
   83  mSpriteImage = other.mSpriteImage;
 
   86Qgis::VectorTileProviderFlags QgsVtpkVectorTileDataProvider::providerFlags()
 const 
   91Qgis::VectorTileProviderCapabilities QgsVtpkVectorTileDataProvider::providerCapabilities()
 const 
   96QString QgsVtpkVectorTileDataProvider::name()
 const 
  100  return DATA_PROVIDER_KEY;
 
  103QString QgsVtpkVectorTileDataProvider::description()
 const 
  107  return DATA_PROVIDER_DESCRIPTION;
 
  113  return new QgsVtpkVectorTileDataProvider( *
this );
 
  116QString QgsVtpkVectorTileDataProvider::sourcePath()
 const 
  122  return dsUri.param( QStringLiteral( 
"url" ) );
 
  125bool QgsVtpkVectorTileDataProvider::isValid()
 const 
  139QgsRectangle QgsVtpkVectorTileDataProvider::extent()
 const 
  148  return mLayerMetadata;
 
  158QVariantMap QgsVtpkVectorTileDataProvider::styleDefinition()
 const 
  162  return mStyleDefinition;
 
  165QVariantMap QgsVtpkVectorTileDataProvider::spriteDefinition()
 const 
  169  return mSpriteDefinition;
 
  172QImage QgsVtpkVectorTileDataProvider::spriteImage()
 const 
  184  if ( mShared->getCachedTileData( data, 
id ) )
 
  192  mShared->storeCachedTileData( rawData );
 
  204  std::unique_ptr< QgsVtpkTiles > reader;
 
  206  QList<QgsVectorTileRawData> rawTiles;
 
  207  QSet< QgsTileXYZ > fetchedTiles;
 
  208  rawTiles.reserve( tiles.size() );
 
  209  fetchedTiles.reserve( tiles.size() );
 
  210  for ( 
QgsTileXYZ id : std::as_const( tiles ) )
 
  215    if ( fetchedTiles.contains( 
id ) )
 
  219    if ( mShared->getCachedTileData( data, 
id ) )
 
  221      rawTiles.append( data );
 
  222      fetchedTiles.insert( data.
id );
 
  228        reader = std::make_unique< QgsVtpkTiles >( dsUri.param( QStringLiteral( 
"url" ) ) );
 
  232      if ( !rawData.
data.isEmpty() && !fetchedTiles.contains( rawData.
id ) )
 
  234        rawTiles.append( rawData );
 
  235        fetchedTiles.insert( rawData.
id );
 
  236        mShared->storeCachedTileData( rawData );
 
  243QString QgsVtpkVectorTileDataProvider::htmlMetadata()
 const 
  252  if ( !reader.rootTileMap().isEmpty() )
 
  253    metadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) % tr( 
"VTPK storage" ) % QStringLiteral( 
"</td><td>" ) % tr( 
"Indexed VTPK (tilemap is present)" ) % QStringLiteral( 
"</td></tr>\n" );
 
  255    metadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) % tr( 
"VTPK storage" ) % QStringLiteral( 
"</td><td>" ) % tr( 
"Flat VTPK (no tilemap)" ) % QStringLiteral( 
"</td></tr>\n" );
 
  257  if ( reader.metadata().contains( QStringLiteral( 
"minLOD" ) ) )
 
  259    metadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) % tr( 
"Tile detail levels" ) % QStringLiteral( 
"</td><td>" ) % QStringLiteral( 
"%1 - %2" ).arg( reader.metadata().value( QStringLiteral( 
"minLOD" ) ).toInt() ).arg( reader.metadata().value( QStringLiteral( 
"maxLOD" ) ).toInt() ) % QStringLiteral( 
"</td></tr>\n" );
 
  278  if ( tileData.isNull() )
 
  282  res.tileGeometryId = requestedTile;
 
  291QgsVtpkVectorTileDataProviderMetadata::QgsVtpkVectorTileDataProviderMetadata()
 
  292  : 
QgsProviderMetadata( QgsVtpkVectorTileDataProvider::DATA_PROVIDER_KEY, QgsVtpkVectorTileDataProvider::DATA_PROVIDER_DESCRIPTION )
 
  296QgsProviderMetadata::ProviderMetadataCapabilities QgsVtpkVectorTileDataProviderMetadata::capabilities()
 const 
  298  return ProviderMetadataCapability::LayerTypesForUri
 
  299         | ProviderMetadataCapability::PriorityForUri
 
  300         | ProviderMetadataCapability::QuerySublayers;
 
  303QgsVtpkVectorTileDataProvider *QgsVtpkVectorTileDataProviderMetadata::createProvider( 
const QString &uri, 
const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
 
  305  return new QgsVtpkVectorTileDataProvider( uri, options, flags );
 
  308QIcon QgsVtpkVectorTileDataProviderMetadata::icon()
 const 
  313QgsProviderMetadata::ProviderCapabilities QgsVtpkVectorTileDataProviderMetadata::providerCapabilities()
 const 
  315  return FileBasedUris;
 
  331      return QObject::tr( 
"VTPK Vector Tiles" ) + QStringLiteral( 
" (*.vtpk *.VTPK)" );
 
  336QList<QgsProviderSublayerDetails> QgsVtpkVectorTileDataProviderMetadata::querySublayers( 
const QString &uri, Qgis::SublayerQueryFlags, 
QgsFeedback * )
 const 
  339  const QFileInfo fi( uri );
 
  346    const QVariantMap parts = decodeUri( uri );
 
  347    fileName = parts.value( QStringLiteral( 
"path" ) ).toString();
 
  350  if ( fileName.isEmpty() )
 
  353  if ( QFileInfo( fileName ).suffix().compare( QLatin1String( 
"vtpk" ), Qt::CaseInsensitive ) == 0 )
 
  356    parts.insert( QStringLiteral( 
"path" ), fileName );
 
  359    details.
setUri( encodeUri( parts ) );
 
  371int QgsVtpkVectorTileDataProviderMetadata::priorityForUri( 
const QString &uri )
 const 
  379QList<Qgis::LayerType> QgsVtpkVectorTileDataProviderMetadata::validLayerTypesForUri( 
const QString &uri )
 const 
  381  const QFileInfo fi( uri );
 
  382  if ( fi.isFile() && fi.suffix().compare( QLatin1String( 
"vtpk" ), Qt::CaseInsensitive ) == 0 )
 
  387  const QVariantMap parts = decodeUri( uri );
 
  388  if ( parts.value( QStringLiteral( 
"path" ) ).toString().endsWith( 
".vtpk", Qt::CaseSensitivity::CaseInsensitive ) )
 
  394QVariantMap QgsVtpkVectorTileDataProviderMetadata::decodeUri( 
const QString &uri )
 const 
  399  QVariantMap uriComponents;
 
  400  uriComponents.insert( QStringLiteral( 
"type" ), QStringLiteral( 
"vtpk" ) );
 
  401  uriComponents.insert( QStringLiteral( 
"path" ), dsUri.
param( QStringLiteral( 
"url" ) ) );
 
  403  return uriComponents;
 
  406QString QgsVtpkVectorTileDataProviderMetadata::encodeUri( 
const QVariantMap &parts )
 const 
  409  dsUri.
setParam( QStringLiteral( 
"type" ), QStringLiteral( 
"vtpk" ) );
 
  410  dsUri.
setParam( QStringLiteral( 
"url" ), parts.value( parts.contains( QStringLiteral( 
"path" ) ) ? QStringLiteral( 
"path" ) : QStringLiteral( 
"url" ) ).toString() );
 
  414QString QgsVtpkVectorTileDataProviderMetadata::absoluteToRelativeUri( 
const QString &uri, 
const QgsReadWriteContext &context )
 const 
  416  QVariantMap parts = decodeUri( uri );
 
  418  const QString originalPath = parts.value( QStringLiteral( 
"path" ) ).toString();
 
  421  return encodeUri( parts );
 
  424QString QgsVtpkVectorTileDataProviderMetadata::relativeToAbsoluteUri( 
const QString &uri, 
const QgsReadWriteContext &context )
 const 
  426  QVariantMap parts = decodeUri( uri );
 
  428  const QString originalPath = parts.value( QStringLiteral( 
"path" ) ).toString();
 
  431  return encodeUri( parts );
 
  434QList<Qgis::LayerType> QgsVtpkVectorTileDataProviderMetadata::supportedLayerTypes()
 const 
@ ReadLayerMetadata
Provider can read layer metadata from data store. See QgsDataProvider::layerMetadata()
 
@ AlwaysUseTileMatrixSetFromProvider
Vector tile layer must always use the tile matrix set from the data provider, and should never store,...
 
FileFilterType
Type of file filters.
 
@ TiledScene
Tiled scene layers (since QGIS 3.34)
 
@ VectorTile
Vector tile layers (since QGIS 3.32)
 
@ MeshDataset
Mesh datasets.
 
@ PointCloud
Point clouds (since QGIS 3.18)
 
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
 
RendererUsage
Usage of the renderer.
 
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
 
This class represents a coordinate reference system (CRS).
 
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.
 
void setEncodedUri(const QByteArray &uri)
Sets the complete encoded uri.
 
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.
 
Base class for feedback objects to be used for cancellation of something running in a worker thread.
 
bool isCanceled() const
Tells whether the operation has been canceled already.
 
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.
 
Contains details about a sub layer available from a dataset.
 
void setUri(const QString &uri)
Sets the layer's uri.
 
void setType(Qgis::LayerType type)
Sets the layer type.
 
void setName(const QString &name)
Sets the layer's name.
 
void setProviderKey(const QString &key)
Sets the associated data provider key.
 
static QString suggestLayerNameFromFilePath(const QString &path)
Suggests a suitable layer name given only a file 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.
 
A rectangle specified with double values.
 
Defines a set of tile matrices for multiple zoom levels.
 
int minimumZoom() const
Returns the minimum zoom level for tiles present in the set.
 
Stores coordinates of a tile in a tile matrix set.
 
int zoomLevel() const
Returns tile's zoom level (Z)
 
int column() const
Returns tile's column index (X)
 
int row() const
Returns tile's row index (Y)
 
Base class for vector tile layer data providers.
 
Encapsulates properties of a vector tile matrix set, including tile origins and scaling information.
 
Keeps track of raw tile data that need to be decoded.
 
QByteArray data
Raw tile data.
 
QgsTileXYZ id
Tile position in tile matrix set.
 
Utility class for reading and writing ESRI VTPK files.
 
QByteArray tileData(int z, int x, int y)
Returns the raw tile data for the matching tile.
 
QgsVectorTileMatrixSet matrixSet() const
Returns the vector tile matrix set representing the tiles.
 
#define QgsDebugError(str)
 
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
 
Setting options for creating vector data providers.