QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
43 , mTransformContext( options.transformContext )
57 void QgsVectorTileLayer::setDataSourcePrivate(
const QString &dataSource,
const QString &baseName,
const QString &,
const QgsDataProvider::ProviderOptions &, QgsDataProvider::ReadFlags )
61 mDataProvider.reset();
66 bool QgsVectorTileLayer::loadDataSource()
73 mSourceType = dsUri.
param( QStringLiteral(
"type" ) );
74 mSourcePath = dsUri.
param( QStringLiteral(
"url" ) );
75 if ( mSourceType == QLatin1String(
"xyz" ) && dsUri.
param( QStringLiteral(
"serviceType" ) ) == QLatin1String(
"arcgis" ) )
77 if ( !setupArcgisVectorTileServiceConnection( mSourcePath, dsUri ) )
80 else if ( mSourceType == QLatin1String(
"xyz" ) )
84 QgsDebugMsg( QStringLiteral(
"Invalid format of URL for XYZ source: " ) + mSourcePath );
90 if ( dsUri.
hasParam( QStringLiteral(
"zmin" ) ) )
91 zMin = dsUri.
param( QStringLiteral(
"zmin" ) ).toInt();
94 if ( dsUri.
hasParam( QStringLiteral(
"zmax" ) ) )
95 zMax = dsUri.
param( QStringLiteral(
"zmax" ) ).toInt();
98 setExtent(
QgsRectangle( -20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892 ) );
100 else if ( mSourceType == QLatin1String(
"mbtiles" ) )
103 if ( !reader.open() )
105 QgsDebugMsg( QStringLiteral(
"failed to open MBTiles file: " ) + mSourcePath );
109 const QString format = reader.metadataValue( QStringLiteral(
"format" ) );
110 if ( format != QLatin1String(
"pbf" ) )
112 QgsDebugMsg( QStringLiteral(
"Cannot open MBTiles for vector tiles. Format = " ) + format );
116 QgsDebugMsgLevel( QStringLiteral(
"name: " ) + reader.metadataValue( QStringLiteral(
"name" ) ), 2 );
117 bool minZoomOk, maxZoomOk;
118 const int minZoom = reader.metadataValue( QStringLiteral(
"minzoom" ) ).toInt( &minZoomOk );
119 const int maxZoom = reader.metadataValue( QStringLiteral(
"maxzoom" ) ).toInt( &maxZoomOk );
129 ct.setBallparkTransformsAreAppropriate(
true );
130 r = ct.transformBoundingBox( r );
133 else if ( mSourceType == QLatin1String(
"vtpk" ) )
136 if ( !reader.open() )
138 QgsDebugMsg( QStringLiteral(
"failed to open VTPK file: " ) + mSourcePath );
142 const QVariantMap
metadata = reader.metadata();
143 const QString format =
metadata.value( QStringLiteral(
"tileInfo" ) ).toMap().value( QStringLiteral(
"format" ) ).toString();
144 if ( format != QLatin1String(
"pbf" ) )
146 QgsDebugMsg( QStringLiteral(
"Cannot open VTPK for vector tiles. Format = " ) + format );
150 mMatrixSet = reader.matrixSet();
156 QgsDebugMsg( QStringLiteral(
"Unknown source type: " ) + mSourceType );
161 const QgsDataProvider::ReadFlags
flags;
162 mDataProvider.reset(
new QgsVectorTileDataProvider( providerOptions,
flags ) );
168 bool QgsVectorTileLayer::setupArcgisVectorTileServiceConnection(
const QString &uri,
const QgsDataSourceUri &dataSourceUri )
170 QString tileServiceUri = uri;
171 QUrl url( tileServiceUri );
175 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"pjson" ) );
176 url.setQuery( query );
178 QNetworkRequest request = QNetworkRequest( url );
183 switch ( networkRequest.get( request ) )
195 const QByteArray raw = content.
content();
199 const QJsonDocument doc = QJsonDocument::fromJson( raw, &err );
205 mArcgisLayerConfiguration = doc.object().toVariantMap();
206 if ( mArcgisLayerConfiguration.contains( QStringLiteral(
"error" ) ) )
211 if ( !mArcgisLayerConfiguration.value( QStringLiteral(
"tiles" ) ).
isValid() )
214 const QString sourceUri = mArcgisLayerConfiguration.value( QStringLiteral(
"sources" ) ).toMap().value( QStringLiteral(
"esri" ) ).toMap().value( QStringLiteral(
"url" ) ).toString();
215 if ( !sourceUri.isEmpty() )
217 QUrl url( sourceUri );
221 query.addQueryItem( QStringLiteral(
"f" ), QStringLiteral(
"pjson" ) );
222 url.setQuery( query );
224 QNetworkRequest request = QNetworkRequest( url );
229 switch ( networkRequest.get( request ) )
241 const QByteArray raw = content.
content();
245 const QJsonDocument doc = QJsonDocument::fromJson( raw, &err );
251 tileServiceUri = sourceUri;
254 mArcgisStyleConfiguration = mArcgisLayerConfiguration;
255 mArcgisLayerConfiguration = doc.object().toVariantMap();
256 if ( mArcgisLayerConfiguration.contains( QStringLiteral(
"error" ) ) )
263 mSourcePath = tileServiceUri +
'/' + mArcgisLayerConfiguration.value( QStringLiteral(
"tiles" ) ).toList().value( 0 ).toString();
266 QgsDebugMsg( QStringLiteral(
"Invalid format of URL for XYZ source: " ) + mSourcePath );
270 mArcgisLayerConfiguration.insert( QStringLiteral(
"serviceUri" ), tileServiceUri );
277 if ( dataSourceUri.
hasParam( QStringLiteral(
"zmin" ) ) )
280 if ( dataSourceUri.
hasParam( QStringLiteral(
"zmax" ) ) )
283 const QVariantMap fullExtent = mArcgisLayerConfiguration.value( QStringLiteral(
"fullExtent" ) ).toMap();
284 if ( !fullExtent.isEmpty() )
287 fullExtent.value( QStringLiteral(
"xmin" ) ).toDouble(),
288 fullExtent.value( QStringLiteral(
"ymin" ) ).toDouble(),
289 fullExtent.value( QStringLiteral(
"xmax" ) ).toDouble(),
290 fullExtent.value( QStringLiteral(
"ymax" ) ).toDouble()
297 setExtent( extentTransform.transformBoundingBox( fullExtentRect ) );
301 QgsDebugMsg( QStringLiteral(
"Could not transform layer fullExtent to layer CRS" ) );
310 setExtent( extentTransform.transformBoundingBox(
QgsRectangle( -20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892 ) ) );
314 QgsDebugMsg( QStringLiteral(
"Could not transform layer extent to layer CRS" ) );
334 return mDataProvider.get();
339 return mDataProvider.get();
351 const QDomElement matrixSetElement = layerNode.firstChildElement( QStringLiteral(
"matrixSet" ) );
352 if ( !matrixSetElement.isNull() )
354 mMatrixSet.
readXml( matrixSetElement, context );
368 QDomElement mapLayerNode = layerNode.toElement();
371 mapLayerNode.appendChild( mMatrixSet.
writeXml( doc, context ) );
376 QDomElement provider = doc.createElement( QStringLiteral(
"provider" ) );
377 const QDomText providerText = doc.createTextNode(
providerType() );
378 provider.appendChild( providerText );
379 mapLayerNode.appendChild( provider );
390 const QDomElement elem = node.toElement();
394 const QDomElement elemRenderer = elem.firstChildElement( QStringLiteral(
"renderer" ) );
395 if ( elemRenderer.isNull() )
397 errorMessage = tr(
"Missing <renderer> tag" );
400 const QString rendererType = elemRenderer.attribute( QStringLiteral(
"type" ) );
405 if ( rendererType == QLatin1String(
"basic" ) )
409 errorMessage = tr(
"Unknown renderer type: " ) + rendererType;
413 r->
readXml( elemRenderer, context );
417 if ( categories.testFlag(
Labeling ) )
420 const QDomElement elemLabeling = elem.firstChildElement( QStringLiteral(
"labeling" ) );
421 if ( !elemLabeling.isNull() )
423 const QString labelingType = elemLabeling.attribute( QStringLiteral(
"type" ) );
425 if ( labelingType == QLatin1String(
"basic" ) )
429 errorMessage = tr(
"Unknown labeling type: " ) + rendererType;
443 const QDomNode blendModeNode = node.namedItem( QStringLiteral(
"blendMode" ) );
444 if ( !blendModeNode.isNull() )
446 const QDomElement e = blendModeNode.toElement();
454 const QDomNode layerOpacityNode = node.namedItem( QStringLiteral(
"layerOpacity" ) );
455 if ( !layerOpacityNode.isNull() )
457 const QDomElement e = layerOpacityNode.toElement();
467 Q_UNUSED( errorMessage )
468 QDomElement elem = node.toElement();
474 QDomElement elemRenderer = doc.createElement( QStringLiteral(
"renderer" ) );
475 elemRenderer.setAttribute( QStringLiteral(
"type" ), mRenderer->type() );
478 mRenderer->writeXml( elemRenderer, context );
480 elem.appendChild( elemRenderer );
483 if ( mLabeling && categories.testFlag(
Labeling ) )
485 QDomElement elemLabeling = doc.createElement( QStringLiteral(
"labeling" ) );
486 elemLabeling.setAttribute( QStringLiteral(
"type" ), mLabeling->type() );
487 mLabeling->writeXml( elemLabeling, context );
488 elem.appendChild( elemLabeling );
494 QDomElement blendModeElem = doc.createElement( QStringLiteral(
"blendMode" ) );
496 blendModeElem.appendChild( blendModeText );
497 node.appendChild( blendModeElem );
503 QDomElement layerOpacityElem = doc.createElement( QStringLiteral(
"layerOpacity" ) );
504 const QDomText layerOpacityText = doc.createTextNode( QString::number(
opacity() ) );
505 layerOpacityElem.appendChild( layerOpacityText );
506 node.appendChild( layerOpacityElem );
524 QStringList warnings;
531 Qgis::MapLayerProperties res;
532 if ( mSourceType == QLatin1String(
"xyz" ) )
550 QVariantMap styleDefinition;
553 if ( !dsUri.
param( QStringLiteral(
"styleUrl" ) ).isEmpty() )
555 styleUrl = dsUri.
param( QStringLiteral(
"styleUrl" ) );
557 else if ( mSourceType == QLatin1String(
"xyz" ) && dsUri.
param( QStringLiteral(
"serviceType" ) ) == QLatin1String(
"arcgis" ) )
560 styleUrl = mArcgisLayerConfiguration.value( QStringLiteral(
"serviceUri" ) ).toString()
561 +
'/' + mArcgisLayerConfiguration.value( QStringLiteral(
"defaultStyles" ) ).toString();
564 if ( mSourceType == QLatin1String(
"vtpk" ) )
567 if ( !reader.
open() )
569 QgsDebugMsg( QStringLiteral(
"failed to open VTPK file: " ) + mSourcePath );
576 if ( !spriteDefinition.isEmpty() )
579 context.
setSprites( spriteImage, spriteDefinition );
582 else if ( !mArcgisStyleConfiguration.isEmpty() || !styleUrl.isEmpty() )
584 if ( !mArcgisStyleConfiguration.isEmpty() )
586 styleDefinition = mArcgisStyleConfiguration;
590 QNetworkRequest request = QNetworkRequest( QUrl( styleUrl ) );
595 switch ( networkRequest.
get( request ) )
603 error = QObject::tr(
"Error retrieving default style" );
611 if ( styleDefinition.contains( QStringLiteral(
"sprite" ) ) )
614 QString spriteUriBase;
615 if ( styleDefinition.value( QStringLiteral(
"sprite" ) ).toString().startsWith( QLatin1String(
"http" ) ) )
617 spriteUriBase = styleDefinition.value( QStringLiteral(
"sprite" ) ).toString();
621 spriteUriBase = styleUrl +
'/' + styleDefinition.value( QStringLiteral(
"sprite" ) ).toString();
624 for (
int resolution = 2; resolution > 0; resolution-- )
626 QUrl spriteUrl = QUrl( spriteUriBase );
627 spriteUrl.setPath( spriteUrl.path() + QStringLiteral(
"%1.json" ).arg( resolution > 1 ? QStringLiteral(
"@%1x" ).arg( resolution ) : QString() ) );
628 QNetworkRequest request = QNetworkRequest( spriteUrl );
631 switch ( networkRequest.
get( request ) )
639 QUrl spriteUrl = QUrl( spriteUriBase );
640 spriteUrl.setPath( spriteUrl.path() + QStringLiteral(
"%1.png" ).arg( resolution > 1 ? QStringLiteral(
"@%1x" ).arg( resolution ) : QString() ) );
641 QNetworkRequest request = QNetworkRequest( spriteUrl );
644 switch ( networkRequest.
get( request ) )
649 const QImage spriteImage( QImage::fromData( imageContent.
content() ) );
650 context.
setSprites( spriteImage, spriteDefinition );
675 if ( !styleDefinition.isEmpty() )
698 bool resultFlag =
false;
708 if ( mSourceType == QLatin1String(
"xyz" ) && dsUri.
param( QStringLiteral(
"serviceType" ) ) == QLatin1String(
"arcgis" ) )
712 metadata.
setIdentifier( mArcgisLayerConfiguration.value( QStringLiteral(
"serviceUri" ) ).toString() );
713 const QString parentIdentifier = mArcgisLayerConfiguration.value( QStringLiteral(
"serviceItemId" ) ).toString();
714 if ( !parentIdentifier.isEmpty() )
719 metadata.
setTitle( mArcgisLayerConfiguration.value( QStringLiteral(
"name" ) ).toString() );
720 const QString copyright = mArcgisLayerConfiguration.value( QStringLiteral(
"copyrightText" ) ).toString();
721 if ( !copyright.isEmpty() )
730 else if ( mSourceType == QLatin1String(
"vtpk" ) )
733 if ( !reader.
open() )
735 QgsDebugMsg( QStringLiteral(
"failed to open VTPK file: " ) + mSourcePath );
763 if ( sourceUrl.isLocalFile() )
768 dsUri.
setParam( QStringLiteral(
"url" ), QUrl::fromLocalFile( relSrcUrl ).toString() );
772 else if (
sourceType == QLatin1String(
"mbtiles" ) )
795 if ( sourceUrl.isLocalFile() )
799 dsUri.
setParam( QStringLiteral(
"url" ), QUrl::fromLocalFile( absSrcUrl ).toString() );
803 else if (
sourceType == QLatin1String(
"mbtiles" ) )
818 QString info = QStringLiteral(
"<html><head></head>\n<body>\n" );
822 info += QStringLiteral(
"<h1>" ) + tr(
"Information from provider" ) + QStringLiteral(
"</h1>\n<hr>\n" ) %
823 QStringLiteral(
"<table class=\"list-view\">\n" );
825 info += QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Source type" ) % QStringLiteral(
"</td><td>" ) %
sourceType() % QStringLiteral(
"</td></tr>\n" );
827 info += QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Zoom levels" ) % QStringLiteral(
"</td><td>" ) % QStringLiteral(
"%1 - %2" ).arg(
sourceMinZoom() ).arg(
sourceMaxZoom() ) % QStringLiteral(
"</td></tr>\n" );
829 info += QLatin1String(
"</table>\n<br>" );
835 info += QStringLiteral(
"<h1>" ) % tr(
"Identification" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
837 QStringLiteral(
"<br>\n" ) %
840 QStringLiteral(
"<h1>" ) % tr(
"Extent" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
842 QStringLiteral(
"<br>\n" ) %
845 QStringLiteral(
"<h1>" ) % tr(
"Access" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
847 QStringLiteral(
"<br>\n" ) %
851 QStringLiteral(
"<h1>" ) % tr(
"Contacts" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
853 QStringLiteral(
"<br><br>\n" ) %
856 QStringLiteral(
"<h1>" ) % tr(
"References" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
858 QStringLiteral(
"<br>\n" ) %
861 QStringLiteral(
"<h1>" ) % tr(
"History" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
863 QStringLiteral(
"<br>\n" ) %
865 QStringLiteral(
"\n</body>\n</html>\n" );
880 if ( rawTiles.isEmpty() )
882 return rawTiles.first().data;
887 mRenderer.reset( r );
893 return mRenderer.get();
904 return mLabeling.get();
913 QgsVectorTileDataProvider::QgsVectorTileDataProvider(
914 const ProviderOptions &options,
915 QgsDataProvider::ReadFlags flags )
924 QString QgsVectorTileDataProvider::name()
const
926 return QStringLiteral(
"vectortile" );
929 QString QgsVectorTileDataProvider::description()
const
939 bool QgsVectorTileDataProvider::isValid()
const
944 bool QgsVectorTileDataProvider::renderInPreview(
const PreviewContext &context )
949 return context.lastRenderingTimeMs <= 1000;
QString crsHtmlMetadata() const
Returns a HTML fragment containing the layer's CRS metadata, for use in the htmlMetadata() method.
QgsCoordinateReferenceSystem crs
void setTargetUnit(QgsUnitTypes::RenderUnit targetUnit)
Sets the target unit type.
QString loadDefaultMetadata(bool &resultFlag) override
Retrieve the default metadata for this layer if one exists (either as a .qmd file on disk or as a rec...
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
Setting options for loading vector tile layers.
QgsVectorTileRenderer * renderer() const
Returns a new instance of a vector tile renderer representing the converted style,...
Class for storing the component parts of a RDBMS data source URI (e.g. a Postgres data source).
Implements a map layer that is dedicated to rendering of vector tiles. Vector tiles compared to "ordi...
Contains information about the context in which a coordinate transform is executed.
QString sourceType() const
Returns type of the data source.
Setting options for creating vector data providers.
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
Stores coordinates of a tile in a tile matrix set. Tile matrix is identified by the zoomLevel(),...
The class is used as a container of context for various read/write operations on other objects.
Abstract base class for spatial data provider implementations.
QgsDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
Range of tiles in a tile matrix to be rendered. The selection is rectangular, given by start/end row ...
#define QgsDebugMsgLevel(str, level)
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
const QgsCoordinateReferenceSystem & crs
QgsMapLayerType
Types of layers that can be added to a map.
void setRenderer(QgsVectorTileRenderer *r)
Sets renderer for the map layer.
QgsNetworkReplyContent reply() const
Returns the content of the network reply, after a get(), post(), head() or put() request has been mad...
Utility class for reading and writing ESRI VTPK files.
The default vector tile renderer implementation. It has an ordered list of "styles",...
Contains information about the context of a rendering operation.
static QgsCoordinateReferenceSystem convertSpatialReference(const QVariantMap &spatialReferenceMap)
Converts a spatial reference JSON definition to a QgsCoordinateReferenceSystem value.
Basic labeling configuration for vector tile layers. It contains a definition of a list of labeling s...
@ RenderMillimeters
Millimeters.
~QgsVectorTileLayer() override
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
This class provides map rendering functionality for vector tile layers. In render() function (assumed...
QgsTileMatrix tileMatrix(int zoom) const
Returns the tile matrix corresponding to the specified zoom.
bool fromEsriJson(const QVariantMap &json)
Initializes the tile structure settings from an ESRI REST VectorTileService json map.
virtual void setMetadata(const QgsLayerMetadata &metadata)
Sets the layer's metadata store.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
A rectangle specified with double values.
QgsVectorTileLayer * clone() const override
Returns a new instance equivalent to this one except for the id which is still unique.
#define QgsSetRequestInitiatorClass(request, _class)
void dropMatricesOutsideZoomRange(int minimumZoom, int maximumZoom)
Deletes any existing matrices which fall outside the zoom range specified by minimumZoom to maximumZo...
QString errorMessage() const
Returns a descriptive error message if an error was encountered during the style conversion,...
QString mProviderKey
Data provider key (name of the data provider)
@ ServerExceptionError
An exception was raised by the server.
@ Rendering
Rendering: scale visibility, simplify method, opacity.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
int maximumZoom() const
Returns the maximum zoom level for tiles present in the set.
QString providerType() const
Returns the provider type (provider key) for this layer.
Result convert(const QVariantMap &style, QgsMapBoxGlStyleConversionContext *context=nullptr)
Converts a JSON style map, and returns the resultant status of the conversion.
QString encodedSource(const QString &source, const QgsReadWriteContext &context) const FINAL
Called by writeLayerXML(), used by derived classes to encode provider's specific data source to proje...
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
@ Success
Conversion was successful.
QString mLayerName
Name of the layer - used for display.
QString param(const QString &key) const
Returns a generic parameter value corresponding to the specified key.
QgsLayerMetadata layerMetadata() const
Reads layer metadata from the VTPK file.
Context for a MapBox GL style conversion operation.
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
QString sourcePath() const
Returns URL/path of the data source (syntax different to each data source type)
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
Defines a matrix of tiles for a single zoom level: it is defined by its size (width *.
static QString typeToString(QgsMapLayerType type)
Converts a map layer type to a string value.
Utility class for reading and writing MBTiles files (which are SQLite3 databases).
QgsLayerMetadata metadata
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
Custom exception class for Coordinate Reference System related exceptions.
static bool checkXYZUrlTemplate(const QString &url)
Checks whether the URL template string is correct (contains {x}, {y} / {-y}, {z} placeholders)
virtual QDomElement writeXml(QDomDocument &document, const QgsReadWriteContext &context) const
Writes the set to an XML element.
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
static QList< QgsVectorTileRawData > blockingFetchTileRawData(const QString &sourceType, const QString &sourcePath, const QgsTileMatrix &tileMatrix, const QPointF &viewCenter, const QgsTileRange &range, const QString &authid, const QgsHttpHeaders &headers, QgsFeedback *feedback=nullptr)
Returns raw tile data for the specified range of tiles. Blocks the caller until all tiles are fetched...
Abstract base class for all vector tile renderer implementations.
bool open()
Tries to open the file, returns true on success.
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any). To be called by subclasses.
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types.
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads renderer's properties from given XML element.
QgsVectorTileRenderer * renderer() const
Returns currently assigned renderer.
QString generalHtmlMetadata() const
Returns an HTML fragment containing general metadata information, for use in the htmlMetadata() metho...
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
void setSprites(const QImage &image, const QVariantMap &definitions)
Sets the sprite image and definitions JSON to use during conversion.
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
QVariantMap spriteDefinition() const
Returns the VTPK sprites definitions.
@ IsBasemapLayer
Layer is considered a 'basemap' layer, and certain properties of the layer should be ignored when cal...
QVariantMap styleDefinition() const
Returns the VTPK style definition.
virtual QString loadDefaultStyle(bool &resultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
@ NoError
No error was encountered.
QVariantMap spriteDefinitions() const
Returns the sprite definitions to use during conversion.
QString loadDefaultStyle(bool &resultFlag) override
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
void setLabeling(QgsVectorTileLabeling *labeling)
Sets labeling for the map layer.
QString mDataSource
Data source description string, varies by layer type.
int removeParam(const QString &key)
Removes a generic parameter by key.
bool writeXml(QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by children to write state specific to them to project files.
int zoomLevel() const
Returns tile's zoom level (Z)
QgsVectorTileLabeling * labeling() const
Returns a new instance of a vector tile labeling representing the converted style,...
This class represents a coordinate reference system (CRS).
virtual bool readXml(const QDomElement &element, QgsReadWriteContext &context)
Reads the set from an XML element.
bool hasParam(const QString &key) const
Returns true if a parameter with the specified key exists.
@ TimeoutError
Timeout was reached before a reply was received.
void setPixelSizeConversionFactor(double sizeConversionFactor)
Sets the pixel size conversion factor, used to scale the original pixel sizes when converting styles.
int sourceMaxZoom() const
Returns maximum zoom level at which source has any valid tiles (negative = unconstrained)
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
QString source() const
Returns the source for the layer.
ErrorCode get(QNetworkRequest &request, bool forceRefresh=false, QgsFeedback *feedback=nullptr)
Performs a "get" operation on the specified request.
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists). To be called by subclasses.
QByteArray encodedUri() const
Returns the complete encoded URI as a byte array.
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
void setEncodedUri(const QByteArray &uri)
Sets the complete encoded uri.
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) override
Read the symbology for the current layer from the DOM node supplied.
QgsVectorTileLabeling * labeling() const
Returns currently assigned labeling.
int row() const
Returns tile's row index (Y)
QgsCoordinateReferenceSystem crs() const
Returns the coordinate reference system associated with the tiles.
Base class for all map layer types. This is the base class for all map layer types (vector,...
void invalidateWgs84Extent()
Invalidates the WGS84 extent.
@ VectorTileLayer
Vector tile layer. Added in QGIS 3.14.
virtual QString loadDefaultMetadata(bool &resultFlag)
Retrieve the default metadata for this layer if one exists (either as a .qmd file on disk or as a rec...
QByteArray getRawTile(QgsTileXYZ tileID)
Fetches raw tile data for the give tile coordinates.
QString decodedSource(const QString &source, const QString &provider, const QgsReadWriteContext &context) const FINAL
Called by readLayerXML(), used by derived classes to decode provider's specific data source from proj...
static QgsVectorTileMatrixSet fromWebMercator(int minimumZoom=0, int maximumZoom=14)
Returns a vector tile structure corresponding to the standard web mercator/GoogleCRS84Quad setup.
Qgis::MapLayerProperties properties() const override
Returns the map layer properties of this layer.
QByteArray content() const
Returns the reply content.
Encapsulates a network reply within a container which is inexpensive to copy and safe to pass between...
void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
int minimumZoom() const
Returns the minimum zoom level for tiles present in the set.
Base class for labeling configuration classes for vector tile layers.
int sourceMinZoom() const
Returns minimum zoom level at which source has any valid tiles (negative = unconstrained)
bool readXml(const QDomNode &layerNode, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files.
static QList< QgsVectorTileBasicRendererStyle > simpleStyleWithRandomColors()
Returns a list of styles to render all layers, using random colors.
QStringList warnings() const
Returns a list of user-friendly warnings generated during the conversion, e.g.
QString authConfigId() const
Returns any associated authentication configuration ID stored in the URI.
@ NetworkError
A network error occurred.
QgsVectorTileLayer(const QString &path=QString(), const QString &baseName=QString(), const QgsVectorTileLayer::LayerOptions &options=QgsVectorTileLayer::LayerOptions())
Constructs a new vector tile layer.
void setValid(bool valid)
Sets whether layer is valid or not.
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads labeling properties from given XML element.
QImage spriteImage() const
Returns the VTPK sprite image, if it exists.
A thread safe class for performing blocking (sync) network requests, with full support for QGIS proxy...
Handles conversion of MapBox GL styles to QGIS vector tile renderers and labeling settings.
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const override
Write the style for the layer into the document provided.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
int column() const
Returns tile's column index (X)
QgsHttpHeaders httpHeaders() const
Returns http headers.
virtual QgsError error() const
Gets current status error.
static QVariant parseJson(const std::string &jsonString)
Converts JSON jsonString to a QVariant, in case of parsing error an invalid QVariant is returned and ...