|
QGIS API Documentation 3.99.0-Master (c22de0620c0)
|
Contains utility functions for working with map layers. More...
#include <qgsmaplayerutils.h>
Static Public Member Functions | |
| static QgsRectangle | combinedExtent (const QList< QgsMapLayer * > &layers, const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext) |
| Returns the combined extent of a list of layers. | |
| static QgsAbstractDatabaseProviderConnection * | databaseConnection (const QgsMapLayer *layer) |
Creates and returns the (possibly nullptr) database connection for a layer. | |
| static bool | isOpenStreetMapLayer (QgsMapLayer *layer) |
Returns true if the layer is served by OpenStreetMap server. | |
| static QString | launderLayerName (const QString &name) |
| Launders a layer's name, converting it into a format which is general suitable for file names or database layer names. | |
| static bool | layerRefersToUri (const QgsMapLayer *layer, const QString &uri, Qgis::SourceHierarchyLevel level=Qgis::SourceHierarchyLevel::Object) |
Returns true if a layer and uri point to the same resource at the specified hierarchy level. | |
| static bool | layerSourceMatchesPath (const QgsMapLayer *layer, const QString &path) |
Returns true if the source of the specified layer matches the given path. | |
| static QString | layerTypeToString (Qgis::LayerType type) |
| Returns the translated name of the type for a given layer type. | |
| static QList< QgsMapLayer * > | sortLayersByType (const QList< QgsMapLayer * > &layers, const QList< Qgis::LayerType > &order) |
| Sorts a list of map layers by their layer type, respecting the order of types specified. | |
| static bool | updateLayerSourcePath (QgsMapLayer *layer, const QString &newPath) |
| Updates a layer's data source, replacing its data source with a path referring to newPath. | |
Contains utility functions for working with map layers.
Definition at line 38 of file qgsmaplayerutils.h.
|
static |
Returns the combined extent of a list of layers.
The crs argument specifies the desired coordinate reference system for the combined extent.
Definition at line 35 of file qgsmaplayerutils.cpp.
|
static |
Creates and returns the (possibly nullptr) database connection for a layer.
Ownership is transferred to the caller.
Definition at line 97 of file qgsmaplayerutils.cpp.
|
static |
Returns true if the layer is served by OpenStreetMap server.
Definition at line 197 of file qgsmaplayerutils.cpp.
|
static |
Launders a layer's name, converting it into a format which is general suitable for file names or database layer names.
Specifically this method:
Definition at line 185 of file qgsmaplayerutils.cpp.
|
static |
Returns true if a layer and uri point to the same resource at the specified hierarchy level.
This method parses the underlying connection parameters of the layer and uri to check if they share the same scope defined by level.
| QgsNotSupportedException | if the layer's provider does not implement the QgsProviderMetadata::ProviderMetadataCapability::UrisReferToSame capability. |
Definition at line 134 of file qgsmaplayerutils.cpp.
|
static |
Returns true if the source of the specified layer matches the given path.
This method can be used to test whether a layer is associated with a file path.
Definition at line 125 of file qgsmaplayerutils.cpp.
|
static |
Returns the translated name of the type for a given layer type.
Definition at line 214 of file qgsmaplayerutils.cpp.
|
static |
Sorts a list of map layers by their layer type, respecting the order of types specified.
Layer types which appear earlier in the order list will result in matching layers appearing earlier in the result list.
Definition at line 168 of file qgsmaplayerutils.cpp.
|
static |
Updates a layer's data source, replacing its data source with a path referring to newPath.
Returns true if the layer was updated, or false if the layer was not updated (e.g. it uses a data provider which does not specify paths in a layer URI.
Definition at line 153 of file qgsmaplayerutils.cpp.