QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
38 QgsDebugMsgLevel( QStringLiteral(
"Layer count: %1" ).arg( layers.count() ), 5 );
44 if ( layer->extent().isNull() )
60 QgsDebugMsg( QStringLiteral(
"Could not reproject layer extent" ) );
64 if ( fullExtent.
width() == 0.0 || fullExtent.
height() == 0.0 )
73 fullExtent.
set( -1.0, -1.0, 1.0, 1.0 );
77 const double padFactor = 1e-8;
78 const double widthPad = fullExtent.
xMinimum() * padFactor;
79 const double heightPad = fullExtent.
yMinimum() * padFactor;
80 const double xmin = fullExtent.
xMinimum() - widthPad;
81 const double xmax = fullExtent.
xMaximum() + widthPad;
82 const double ymin = fullExtent.
yMinimum() - heightPad;
83 const double ymax = fullExtent.
yMaximum() + heightPad;
84 fullExtent.
set( xmin, ymin, xmax, ymax );
102 if ( ! providerMetadata )
108 return conn.release();
112 QgsDebugMsg( QStringLiteral(
"Error retrieving database connection for layer %1: %2" ).arg( layer->
name(), ex.
what() ) );
119 if ( !layer || path.isEmpty() )
123 return parts.value( QStringLiteral(
"path" ) ).toString() == path;
128 if ( !layer || newPath.isEmpty() )
132 if ( !parts.contains( QStringLiteral(
"path" ) ) )
135 parts.insert( QStringLiteral(
"path" ), newPath );
143 QList< QgsMapLayer * > res = layers;
146 for ( QgsMapLayerType type : order )
148 if ( a->type() == type && b->type() != type )
150 else if ( b->type() == type )
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
Contains information about the context in which a coordinate transform is executed.
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
void set(const QgsPointXY &p1, const QgsPointXY &p2, bool normalize=true)
Sets the rectangle from two QgsPoints.
#define QgsDebugMsgLevel(str, level)
const QgsCoordinateReferenceSystem & crs
QString encodeUri(const QString &providerKey, const QVariantMap &parts)
Reassembles a provider data source URI from its component paths (e.g.
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
void setMinimal() SIP_HOLDGIL
Set a rectangle so that min corner is at max and max corner is at min.
static QgsAbstractDatabaseProviderConnection * databaseConnection(const QgsMapLayer *layer)
Creates and returns the (possibly nullptr) database connection for a layer.
A rectangle specified with double values.
QString providerType() const
Returns the provider type (provider key) for this layer.
static bool layerSourceMatchesPath(const QgsMapLayer *layer, const QString &path)
Returns true if the source of the specified layer matches the given path.
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
Custom exception class for Coordinate Reference System related exceptions.
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
static QList< QgsMapLayer * > sortLayersByType(const QList< QgsMapLayer * > &layers, const QList< QgsMapLayerType > &order)
Sorts a list of map layers by their layer type, respecting the order of types specified.
QgsProviderMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
static QgsRectangle combinedExtent(const QList< QgsMapLayer * > &layers, const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &transformContext)
Returns the combined extent of a list of layers.
Custom exception class for provider connection related exceptions.
This class represents a coordinate reference system (CRS).
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
QString source() const
Returns the source for the layer.
void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag=false)
Updates the data source of the layer.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
Base class for all map layer types. This is the base class for all map layer types (vector,...
static bool updateLayerSourcePath(QgsMapLayer *layer, const QString &newPath)
Updates a layer's data source, replacing its data source with a path referring to newPath.
virtual QString name() const =0
Returns a provider name.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...