43#include "moc_qgsvectortilelayer.cpp"
68 mDataProvider.reset();
73bool QgsVectorTileLayer::loadDataSource()
77 QgsDataSourceUri dsUri;
80 setCrs( QgsCoordinateReferenceSystem( QStringLiteral(
"EPSG:3857" ) ) );
82 const QgsDataProvider::ProviderOptions providerOptions { mTransformContext };
85 mSourceType = dsUri.param( QStringLiteral(
"type" ) );
87 if ( mSourceType == QLatin1String(
"xyz" ) && dsUri.param( QStringLiteral(
"serviceType" ) ) == QLatin1String(
"arcgis" ) )
89 providerKey = QStringLiteral(
"arcgisvectortileservice" );
91 else if ( mSourceType == QLatin1String(
"xyz" ) )
93 providerKey = QStringLiteral(
"xyzvectortiles" );
95 else if ( mSourceType == QLatin1String(
"mbtiles" ) )
97 providerKey = QStringLiteral(
"mbtilesvectortiles" );
99 else if ( mSourceType == QLatin1String(
"vtpk" ) )
101 providerKey = QStringLiteral(
"vtpkvectortiles" );
105 QgsDebugError( QStringLiteral(
"Unknown source type: " ) + mSourceType );
110 mProviderKey = mDataProvider ? mDataProvider->name() : providerKey;
114 mMatrixSet = qgis::down_cast< QgsVectorTileDataProvider * >( mDataProvider.get() )->tileMatrixSet();
115 setCrs( mDataProvider->crs() );
119 return mDataProvider && mDataProvider->isValid();
139 return mDataProvider.get();
146 return mDataProvider.get();
164 const QDomElement matrixSetElement = layerNode.firstChildElement( QStringLiteral(
"matrixSet" ) );
165 if ( !matrixSetElement.isNull() )
167 mMatrixSet.readXml( matrixSetElement, context );
170 setCrs( mMatrixSet.crs() );
184 QDomElement mapLayerNode = layerNode.toElement();
189 mapLayerNode.appendChild( mMatrixSet.writeXml( doc, context ) );
195 QDomElement provider = doc.createElement( QStringLiteral(
"provider" ) );
196 const QDomText providerText = doc.createTextNode(
providerType() );
197 provider.appendChild( providerText );
198 mapLayerNode.appendChild( provider );
211 const QDomElement elem = node.toElement();
215 const QDomElement elemRenderer = elem.firstChildElement( QStringLiteral(
"renderer" ) );
216 if ( elemRenderer.isNull() )
218 errorMessage = tr(
"Missing <renderer> tag" );
221 const QString rendererType = elemRenderer.attribute( QStringLiteral(
"type" ) );
226 if ( rendererType == QLatin1String(
"basic" ) )
230 errorMessage = tr(
"Unknown renderer type: " ) + rendererType;
234 r->
readXml( elemRenderer, context );
238 if ( categories.testFlag(
Labeling ) )
241 const QDomElement elemLabeling = elem.firstChildElement( QStringLiteral(
"labeling" ) );
242 if ( !elemLabeling.isNull() )
244 const QString labelingType = elemLabeling.attribute( QStringLiteral(
"type" ) );
246 if ( labelingType == QLatin1String(
"basic" ) )
250 errorMessage = tr(
"Unknown labeling type: " ) + rendererType;
253 if ( elemLabeling.hasAttribute( QStringLiteral(
"labelsEnabled" ) ) )
254 mLabelsEnabled = elemLabeling.attribute( QStringLiteral(
"labelsEnabled" ) ).toInt();
256 mLabelsEnabled =
true;
260 labeling->readXml( elemLabeling, context );
269 const QDomNode blendModeNode = node.namedItem( QStringLiteral(
"blendMode" ) );
270 if ( !blendModeNode.isNull() )
272 const QDomElement e = blendModeNode.toElement();
280 const QDomNode layerOpacityNode = node.namedItem( QStringLiteral(
"layerOpacity" ) );
281 if ( !layerOpacityNode.isNull() )
283 const QDomElement e = layerOpacityNode.toElement();
295 Q_UNUSED( errorMessage )
296 QDomElement elem = node.toElement();
302 QDomElement elemRenderer = doc.createElement( QStringLiteral(
"renderer" ) );
303 elemRenderer.setAttribute( QStringLiteral(
"type" ), mRenderer->type() );
306 mRenderer->writeXml( elemRenderer, context );
308 elem.appendChild( elemRenderer );
311 if ( mLabeling && categories.testFlag(
Labeling ) )
313 QDomElement elemLabeling = doc.createElement( QStringLiteral(
"labeling" ) );
314 elemLabeling.setAttribute( QStringLiteral(
"type" ), mLabeling->type() );
315 elemLabeling.setAttribute( QStringLiteral(
"labelsEnabled" ), mLabelsEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
316 mLabeling->writeXml( elemLabeling, context );
317 elem.appendChild( elemLabeling );
323 QDomElement blendModeElem = doc.createElement( QStringLiteral(
"blendMode" ) );
325 blendModeElem.appendChild( blendModeText );
326 node.appendChild( blendModeElem );
332 QDomElement layerOpacityElem = doc.createElement( QStringLiteral(
"layerOpacity" ) );
333 const QDomText layerOpacityText = doc.createTextNode( QString::number(
opacity() ) );
334 layerOpacityElem.appendChild( layerOpacityText );
335 node.appendChild( layerOpacityElem );
357 QStringList warnings;
367 if ( mSourceType == QLatin1String(
"xyz" ) )
384 return loadDefaultStyleAndSubLayersPrivate(
error, warnings,
nullptr );
391 return loadDefaultStyleAndSubLayersPrivate(
error, warnings, &
subLayers );
394bool QgsVectorTileLayer::loadDefaultStyleAndSubLayersPrivate( QString &error, QStringList &warnings, QList<QgsMapLayer *> *subLayers )
404 QVariantMap styleDefinition;
407 if ( !dsUri.
param( QStringLiteral(
"styleUrl" ) ).isEmpty() )
409 styleUrl = dsUri.
param( QStringLiteral(
"styleUrl" ) );
413 styleUrl = vtProvider->styleUrl();
416 styleDefinition = vtProvider->styleDefinition();
417 const QVariantMap spriteDefinition = vtProvider->spriteDefinition();
418 if ( !spriteDefinition.isEmpty() )
420 const QImage spriteImage = vtProvider->spriteImage();
421 context.
setSprites( spriteImage, spriteDefinition );
424 if ( !styleDefinition.isEmpty() || !styleUrl.isEmpty() )
426 if ( styleDefinition.isEmpty() )
428 QNetworkRequest request = QNetworkRequest( QUrl( styleUrl ) );
432 QgsBlockingNetworkRequest networkRequest;
433 switch ( networkRequest.
get( request ) )
441 error = QObject::tr(
"Error retrieving default style" );
445 const QgsNetworkReplyContent content = networkRequest.
reply();
452 if ( !styleDefinition.isEmpty() )
460 QgsMapBoxGlStyleConverter converter;
481 bool resultFlag =
false;
492 if ( !mDataProvider || !mDataProvider->isValid() )
527 QString info = QStringLiteral(
"<html><head></head>\n<body>\n" );
531 info += QStringLiteral(
"<h1>" ) + tr(
"Information from provider" ) + QStringLiteral(
"</h1>\n<hr>\n" ) %
532 QStringLiteral(
"<table class=\"list-view\">\n" );
534 info += QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Source type" ) % QStringLiteral(
"</td><td>" ) %
sourceType() % QStringLiteral(
"</td></tr>\n" );
536 info += QStringLiteral(
"<tr><td class=\"highlight\">" ) % tr(
"Zoom levels" ) % QStringLiteral(
"</td><td>" ) % QStringLiteral(
"%1 - %2" ).arg(
sourceMinZoom() ).arg(
sourceMaxZoom() ) % QStringLiteral(
"</td></tr>\n" );
539 info += qobject_cast< const QgsVectorTileDataProvider * >( mDataProvider.get() )->htmlMetadata();
541 info += QLatin1String(
"</table>\n<br>" );
547 info += QStringLiteral(
"<h1>" ) % tr(
"Identification" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
548 htmlFormatter.identificationSectionHtml() %
549 QStringLiteral(
"<br>\n" ) %
552 QStringLiteral(
"<h1>" ) % tr(
"Extent" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
553 htmlFormatter.extentSectionHtml( ) %
554 QStringLiteral(
"<br>\n" ) %
557 QStringLiteral(
"<h1>" ) % tr(
"Access" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
558 htmlFormatter.accessSectionHtml( ) %
559 QStringLiteral(
"<br>\n" ) %
563 QStringLiteral(
"<h1>" ) % tr(
"Contacts" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
564 htmlFormatter.contactsSectionHtml( ) %
565 QStringLiteral(
"<br><br>\n" ) %
568 QStringLiteral(
"<h1>" ) % tr(
"References" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
569 htmlFormatter.linksSectionHtml( ) %
570 QStringLiteral(
"<br>\n" ) %
573 QStringLiteral(
"<h1>" ) % tr(
"History" ) % QStringLiteral(
"</h1>\n<hr>\n" ) %
574 htmlFormatter.historySectionHtml( ) %
575 QStringLiteral(
"<br>\n" ) %
579 QStringLiteral(
"\n</body>\n</html>\n" );
587 return vtProvider->sourcePath();
600 return vtProvider->readTile( mMatrixSet, tileID );
607 mRenderer.reset( r );
615 return mRenderer.get();
630 return mLabeling.get();
638 return mLabelsEnabled &&
static_cast< bool >( mLabeling );
645 mLabelsEnabled = enabled;
652 QList< QgsFeature > res;
653 res.reserve( mSelectedFeatures.size() );
654 for (
auto it = mSelectedFeatures.begin(); it != mSelectedFeatures.end(); ++it )
655 res.append( it.value() );
664 return mSelectedFeatures.size();
677 QSet< QgsFeatureId > prevSelection;
678 prevSelection.reserve( mSelectedFeatures.size() );
679 for (
auto it = mSelectedFeatures.begin(); it != mSelectedFeatures.end(); ++it )
680 prevSelection.insert( it.key() );
687 mSelectedFeatures.clear();
698 bool isPointOrRectangle;
703 isPointOrRectangle =
true;
704 point = selectionGeom.
asPoint();
713 auto addDerivedFields = [](
QgsFeature & feature,
const int tileZoom,
const QString & layer )
716 fields.
append(
QgsField( QStringLiteral(
"tile_zoom" ), QMetaType::Type::Int ) );
717 fields.
append(
QgsField( QStringLiteral(
"tile_layer" ), QMetaType::Type::QString ) );
719 attributes << tileZoom << layer;
724 std::unique_ptr<QgsGeometryEngine> selectionGeomPrepared;
725 QList< QgsFeature > singleSelectCandidates;
757 if ( data.
data.isEmpty() )
761 if ( !decoder.
decode( data ) )
764 QMap<QString, QgsFields> perLayerFields;
765 const QStringList layerNames = decoder.
layers();
766 for (
const QString &layerName : layerNames )
768 QSet<QString> fieldNames = qgis::listToSet( decoder.
layerFieldNames( layerName ) );
773 const QStringList featuresLayerNames = features.keys();
774 for (
const QString &layerName : featuresLayerNames )
776 const QgsFields fFields = perLayerFields[layerName];
777 const QVector<QgsFeature> &layerFeatures = features[layerName];
780 if ( renderContext && mRenderer && !mRenderer->willRenderFeature( f, tileID.zoomLevel(), layerName, *renderContext ) )
783 if ( f.geometry().intersects( r ) )
785 bool selectFeature =
true;
786 if ( selectionGeomPrepared )
788 switch ( relationship )
791 selectFeature = selectionGeomPrepared->intersects( f.geometry().constGet() );
794 selectFeature = selectionGeomPrepared->contains( f.geometry().constGet() );
802 addDerivedFields( derivedFeature, tileID.zoomLevel(), layerName );
804 singleSelectCandidates << derivedFeature;
806 mSelectedFeatures.insert( derivedFeature.
id(), derivedFeature );
820 for (
auto it = mSelectedFeatures.begin(); it != mSelectedFeatures.end(); )
822 bool matchesGeometry =
false;
823 if ( selectionGeomPrepared )
825 switch ( relationship )
828 matchesGeometry = selectionGeomPrepared->intersects( it->geometry().constGet() );
831 matchesGeometry = selectionGeomPrepared->contains( it->geometry().constGet() );
837 switch ( relationship )
840 matchesGeometry = it->geometry().intersects( r );
843 matchesGeometry = r.
contains( it->geometry().boundingBox() );
850 singleSelectCandidates << it.value();
860 it = mSelectedFeatures.erase( it );
876 double smallestArea = std::numeric_limits< double >::max();
877 double smallestLength = std::numeric_limits< double >::max();
878 for (
const QgsFeature &candidate : std::as_const( singleSelectCandidates ) )
880 if ( !mSelectedFeatures.contains( candidate.id() ) )
883 switch ( candidate.geometry().type() )
886 bestCandidate = candidate;
890 const double length = candidate.geometry().length();
893 bestCandidate = candidate;
894 smallestLength = length;
900 const double area = candidate.geometry().area();
903 bestCandidate = candidate;
915 if ( !bestCandidate.
isValid() )
918 double smallestArea = std::numeric_limits< double >::max();
919 double smallestLength = std::numeric_limits< double >::max();
920 for (
const QgsFeature &candidate : std::as_const( singleSelectCandidates ) )
922 switch ( candidate.geometry().type() )
925 bestCandidate = candidate;
929 const double length = candidate.geometry().length();
932 bestCandidate = candidate;
933 smallestLength = length;
939 const double area = candidate.geometry().area();
942 bestCandidate = candidate;
956 if ( prevSelection.contains( bestCandidate.
id() ) )
957 mSelectedFeatures.remove( bestCandidate.
id() );
959 mSelectedFeatures.insert( bestCandidate.
id(), bestCandidate );
967 mSelectedFeatures.insert( bestCandidate.
id(), bestCandidate );
972 if ( mSelectedFeatures.contains( bestCandidate.
id() ) )
974 mSelectedFeatures.clear();
975 mSelectedFeatures.insert( bestCandidate.
id(), bestCandidate );
979 mSelectedFeatures.clear();
986 mSelectedFeatures.remove( bestCandidate.
id() );
993 QSet< QgsFeatureId > newSelection;
994 newSelection.reserve( mSelectedFeatures.size() );
995 for (
auto it = mSelectedFeatures.begin(); it != mSelectedFeatures.end(); ++it )
996 newSelection.insert( it.key() );
999 if ( prevSelection != newSelection )
1007 if ( mSelectedFeatures.empty() )
1010 mSelectedFeatures.clear();
Provides global constants and enumerations for use throughout the application.
@ IsBasemapLayer
Layer is considered a 'basemap' layer, and certain properties of the layer should be ignored when cal...
@ 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,...
QFlags< SelectionFlag > SelectionFlags
Flags which control feature selection behavior.
BlendMode
Blending modes defining the available composition modes that can be used when painting.
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Millimeters
Millimeters.
@ ToggleSelection
Enables a "toggle" selection mode, where previously selected matching features will be deselected and...
@ SingleFeatureSelection
Select only a single feature, picking the "best" match for the selection geometry.
QFlags< MapLayerProperty > MapLayerProperties
Map layer properties.
SelectGeometryRelationship
Geometry relationship test to apply for selecting features.
@ Within
Select where features are within the reference geometry.
@ Intersect
Select where features intersect the reference geometry.
SelectBehavior
Specifies how a selection should be applied.
@ SetSelection
Set selection, removing any existing selection.
@ AddToSelection
Add selection to current selection.
@ IntersectSelection
Modify current selection to include only select features which match.
@ RemoveFromSelection
Remove from current selection.
ErrorCode get(QNetworkRequest &request, bool forceRefresh=false, QgsFeedback *feedback=nullptr, RequestFlags requestFlags=QgsBlockingNetworkRequest::RequestFlags())
Performs a "get" operation on the specified request.
@ NetworkError
A network error occurred.
@ ServerExceptionError
An exception was raised by the server.
@ NoError
No error was encountered.
@ TimeoutError
Timeout was reached before a reply was received.
QgsNetworkReplyContent reply() const
Returns the content of the network reply, after a get(), post(), head() or put() request has been mad...
Contains information about the context in which a coordinate transform is executed.
Abstract base class for spatial data provider implementations.
Stores the component parts of a data source URI (e.g.
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.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
void setFields(const QgsFields &fields, bool initAttributes=false)
Assigns a field map with the feature to allow attribute access by attribute name.
bool isValid() const
Returns the validity of this feature.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
A geometry is the spatial representation of a feature.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
bool isGeosEqual(const QgsGeometry &) const
Compares the geometry with another geometry using GEOS.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry, double precision=0.0, Qgis::GeosCreationFlags flags=Qgis::GeosCreationFlag::SkipEmptyInteriorRings)
Creates and returns a new geometry engine representing the specified geometry using precision on a gr...
static QVariant parseJson(const std::string &jsonString)
Converts JSON jsonString to a QVariant, in case of parsing error an invalid QVariant is returned and ...
Context for a MapBox GL style conversion operation.
void setTargetUnit(Qgis::RenderUnit targetUnit)
Sets the target unit type.
void setSprites(const QImage &image, const QVariantMap &definitions, const QString &category=QString())
Sets the sprite image and definitions JSON for a given category to use during conversion.
void setPixelSizeConversionFactor(double sizeConversionFactor)
Sets the pixel size conversion factor, used to scale the original pixel sizes when converting styles.
QgsVectorTileRenderer * renderer() const
Returns a new instance of a vector tile renderer representing the converted style,...
QgsVectorTileLabeling * labeling() const
Returns a new instance of a vector tile labeling representing the converted style,...
Result convert(const QVariantMap &style, QgsMapBoxGlStyleConversionContext *context=nullptr)
Converts a JSON style map, and returns the resultant status of the conversion.
QList< QgsMapLayer * > createSubLayers() const
Returns a list of new map layers corresponding to sublayers of the style, e.g.
@ Success
Conversion was successful.
QString errorMessage() const
Returns a descriptive error message if an error was encountered during the style conversion,...
QStringList warnings() const
Returns a list of user-friendly warnings generated during the conversion, e.g.
static QString typeToString(Qgis::LayerType type)
Converts a map layer type to a string value.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any). To be called by subclasses.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists). To be called by subclasses.
QString source() const
Returns the source for the layer.
QString providerType() const
Returns the provider type (provider key) for this layer.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
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...
QString mLayerName
Name of the layer - used for display.
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
QString crsHtmlMetadata() const
Returns a HTML fragment containing the layer's CRS metadata, for use in the htmlMetadata() method.
QgsLayerMetadata metadata
QgsMapLayer(Qgis::LayerType type=Qgis::LayerType::Vector, const QString &name=QString(), const QString &source=QString())
Constructor for QgsMapLayer.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
virtual void setMetadata(const QgsLayerMetadata &metadata)
Sets the layer's metadata store.
QFlags< StyleCategory > StyleCategories
QString mProviderKey
Data provider key (name of the data provider).
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
virtual QgsError error() const
Gets current status error.
QgsMapLayer::LayerFlags flags
virtual QStringList subLayers() const
Returns the sublayers of this layer.
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
QString mDataSource
Data source description string, varies by layer type.
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...
void setValid(bool valid)
Sets whether layer is valid or not.
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
@ Rendering
Rendering: scale visibility, simplify method, opacity.
QString customPropertyHtmlMetadata() const
Returns an HTML fragment containing custom property information, for use in the htmlMetadata() method...
QString generalHtmlMetadata() const
Returns an HTML fragment containing general metadata information, for use in the htmlMetadata() metho...
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types.
void invalidateWgs84Extent()
Invalidates the WGS84 extent.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
QByteArray content() const
Returns the reply content.
static Qgis::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a Qgis::BlendMode corresponding to a QPainter::CompositionMode.
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a Qgis::BlendMode.
QString absoluteToRelativeUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts absolute path(s) to relative path(s) in the given provider-specific URI.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QString relativeToAbsoluteUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts relative path(s) to absolute path(s) in the given provider-specific URI.
A container for the context for various read/write operations on objects.
A rectangle specified with double values.
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle.
Contains information about the context of a rendering operation.
Encapsulates the context of a layer selection operation.
double scale() const
Returns the map scale at which the selection should occur.
QVector< QgsTileXYZ > tilesInRange(QgsTileRange range, int zoomLevel) const
Returns a list of tiles in the given tile range.
QgsTileMatrix tileMatrix(int zoom) const
Returns the tile matrix corresponding to the specified zoom.
int scaleToZoomLevel(double scale, bool clamp=true) const
Finds the best fitting (integer) zoom level given a map scale denominator.
Defines a matrix of tiles for a single zoom level: it is defined by its size (width *.
QgsTileRange tileRangeFromExtent(const QgsRectangle &mExtent) const
Returns tile range that fully covers the given extent.
A range of tiles in a tile matrix.
Stores coordinates of a tile in a tile matrix set.
Basic labeling configuration for vector tile layers.
The default vector tile renderer implementation.
static QList< QgsVectorTileBasicRendererStyle > simpleStyleWithRandomColors()
Returns a list of styles to render all layers, using random colors.
Base class for vector tile layer data providers.
Base class for labeling configuration classes for vector tile layers.
Provides map rendering functionality for vector tile layers.
QgsVectorTileLayer(const QString &path=QString(), const QString &baseName=QString(), const QgsVectorTileLayer::LayerOptions &options=QgsVectorTileLayer::LayerOptions())
Constructs a new vector tile layer.
bool readXml(const QDomNode &layerNode, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files.
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.
void setRenderer(QgsVectorTileRenderer *r)
Sets renderer for the map layer.
bool loadDefaultStyleAndSubLayers(QString &error, QStringList &warnings, QList< QgsMapLayer * > &subLayers)
Loads the default style for the layer, and returns true if the style was successfully loaded.
QString sourceType() const
Returns type of the data source.
void setLabelsEnabled(bool enabled)
Sets whether labels should be enabled for the layer.
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.
void selectByGeometry(const QgsGeometry &geometry, const QgsSelectionContext &context, Qgis::SelectBehavior behavior=Qgis::SelectBehavior::SetSelection, Qgis::SelectGeometryRelationship relationship=Qgis::SelectGeometryRelationship::Intersect, Qgis::SelectionFlags flags=Qgis::SelectionFlags(), QgsRenderContext *renderContext=nullptr)
Selects features found within the search geometry (in layer's 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...
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
void setLabeling(QgsVectorTileLabeling *labeling)
Sets labeling for the map layer.
QList< QgsFeature > selectedFeatures() const
Returns the list of features currently selected in the layer.
QgsVectorTileLabeling * labeling() const
Returns currently assigned labeling.
~QgsVectorTileLayer() override
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.
int sourceMinZoom() const
Returns minimum zoom level at which source has any valid tiles (negative = unconstrained).
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
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...
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...
Qgis::MapLayerProperties properties() const override
Returns the map layer properties of this layer.
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
int sourceMaxZoom() const
Returns maximum zoom level at which source has any valid tiles (negative = unconstrained).
QgsVectorTileRenderer * renderer() const
Returns currently assigned renderer.
void removeSelection()
Clear selection.
QgsDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
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...
QString sourcePath() const
Returns URL/path of the data source (syntax different to each data source type).
QgsVectorTileRawData getRawTile(QgsTileXYZ tileID)
Fetches raw tile data for the give tile coordinates.
void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
QgsVectorTileMatrixSet & tileMatrixSet()
Returns the vector tile matrix set.
void selectionChanged()
Emitted whenever the selected features in the layer are changed.
QgsVectorTileLayer * clone() const override
Returns a new instance equivalent to this one except for the id which is still unique.
int selectedFeatureCount() const
Returns the number of features that are selected in this layer.
Responsible for decoding raw tile data written with Mapbox Vector Tiles encoding.
QStringList layerFieldNames(const QString &layerName) const
Returns a list of all field names in a tile. It can only be called after a successful decode().
QStringList layers() const
Returns a list of sub-layer names in a tile. It can only be called after a successful decode().
bool decode(const QgsVectorTileRawData &rawTileData)
Tries to decode raw tile data, returns true on success.
QgsVectorTileFeatures layerFeatures(const QMap< QString, QgsFields > &perLayerFields, const QgsCoordinateTransform &ct, const QSet< QString > *layerSubset=nullptr) const
Returns decoded features grouped by sub-layers.
Keeps track of raw tile data from one or more sources that need to be decoded.
QMap< QString, QByteArray > data
Raw tile data by source ID.
Abstract base class for all vector tile renderer implementations.
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads renderer's properties from given XML element.
static QgsFields makeQgisFields(const QSet< QString > &flds)
Returns QgsFields instance based on the set of field names.
static void loadSprites(const QVariantMap &styleDefinition, QgsMapBoxGlStyleConversionContext &context, const QString &styleUrl=QString())
Downloads the sprite image and sets it to the conversion context.
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
#define QgsSetRequestInitiatorClass(request, _class)
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
QMap< QString, QVector< QgsFeature > > QgsVectorTileFeatures
Features of a vector tile, grouped by sub-layer names (key of the map).
Setting options for creating vector data providers.
Setting options for loading vector tile layers.