23 QString QgsExportLayersInformationAlgorithm::name()
 const 
   25   return QStringLiteral( 
"exportlayersinformation" );
 
   28 QString QgsExportLayersInformationAlgorithm::displayName()
 const 
   30   return QObject::tr( 
"Export layer(s) information" );
 
   33 QStringList QgsExportLayersInformationAlgorithm::tags()
 const 
   35   return QObject::tr( 
"metadata,details,extent" ).split( 
',' );
 
   38 QString QgsExportLayersInformationAlgorithm::group()
 const 
   40   return QObject::tr( 
"Layer tools" );
 
   43 QString QgsExportLayersInformationAlgorithm::groupId()
 const 
   45   return QStringLiteral( 
"layertools" );
 
   48 void QgsExportLayersInformationAlgorithm::initAlgorithm( 
const QVariantMap & )
 
   54 QString QgsExportLayersInformationAlgorithm::shortHelpString()
 const 
   56   return QObject::tr( 
"Creates a polygon layer with features corresponding to the extent of selected layer(s).\n\n" 
   57                       "Additional layer details - CRS, provider name, file path, layer name, subset filter, abstract and attribution - are attached as attributes to each feature." );
 
   60 QgsExportLayersInformationAlgorithm *QgsExportLayersInformationAlgorithm::createInstance()
 const 
   62   return new QgsExportLayersInformationAlgorithm();
 
   67   const QList< QgsMapLayer * > layers = parameterAsLayerList( parameters, QStringLiteral( 
"LAYERS" ), context );
 
   70     if ( !mCrs.isValid() )
 
   74     else if ( mCrs.authid() != QLatin1String( 
"EPSG:4326" ) )
 
   76       if ( mCrs != layer->crs() )
 
   82     mLayers.emplace_back( layer->clone() );
 
   85   if ( !mCrs.isValid() )
 
   88   if ( mLayers.empty() )
 
   89     feedback->
reportError( QObject::tr( 
"No layers selected" ), 
false );
 
   97   outFields.
append( 
QgsField( QStringLiteral( 
"name" ), QVariant::String ) );
 
   98   outFields.
append( 
QgsField( QStringLiteral( 
"source" ), QVariant::String ) );
 
   99   outFields.
append( 
QgsField( QStringLiteral( 
"crs" ), QVariant::String ) );
 
  100   outFields.
append( 
QgsField( QStringLiteral( 
"provider" ), QVariant::String ) );
 
  101   outFields.
append( 
QgsField( QStringLiteral( 
"file_path" ), QVariant::String ) );
 
  102   outFields.
append( 
QgsField( QStringLiteral( 
"layer_name" ), QVariant::String ) );
 
  103   outFields.
append( 
QgsField( QStringLiteral( 
"subset" ), QVariant::String ) );
 
  104   outFields.
append( 
QgsField( QStringLiteral( 
"abstract" ), QVariant::String ) );
 
  105   outFields.
append( 
QgsField( QStringLiteral( 
"attribution" ), QVariant::String ) );
 
  108   std::unique_ptr< QgsFeatureSink > outputSink( parameterAsSink( parameters, QStringLiteral( 
"OUTPUT" ), context, outputDest, outFields,
 
  111   const QList< QgsMapLayer * > layers = parameterAsLayerList( parameters, QStringLiteral( 
"LAYERS" ), context );
 
  113   double step = layers.size() > 0 ? 100.0 / layers.size() : 1;
 
  115   for ( 
const std::unique_ptr< QgsMapLayer > &layer : mLayers )
 
  128     attributes << layer->name()
 
  130                << layer->crs().authid();
 
  131     if ( layer->dataProvider() )
 
  134       attributes << layer->dataProvider()->name()
 
  135                  << parts[ QStringLiteral( 
"path" ) ]
 
  136                  << parts[ QStringLiteral( 
"layerName" ) ]
 
  137                  << parts[ QStringLiteral( 
"subset" ) ];
 
  141       attributes << QVariant() << QVariant() << QVariant() << QVariant();
 
  143     attributes << layer->metadata().rights().join( 
';' )
 
  144                << layer->abstract();
 
  150       if ( layer->crs() != mCrs )
 
  155           rect = transform.transformBoundingBox( rect );
 
  161           feedback->
pushInfo( QObject::tr( 
"Extent of layer %1 could not be reprojected" ).arg( layer->name() ) );
 
  170   outputs.insert( QStringLiteral( 
"OUTPUT" ), outputDest );
 
This class represents a coordinate reference system (CRS).
Custom exception class for Coordinate Reference System related exceptions.
@ FastInsert
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
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 setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
void setProgress(double progress)
Sets the current progress for the feedback object.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
static QgsGeometry fromRect(const QgsRectangle &rect) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
Base class for all map layer types.
Contains information about the context in which a processing algorithm is executed.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
A feature sink output for processing algorithms.
A parameter for processing algorithms which accepts multiple map layers.
@ TypeMapLayer
Any map layer type (raster or vector or mesh)
@ TypeVectorPolygon
Vector polygon layers.
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
A rectangle specified with double values.
bool isEmpty() const
Returns true if the rectangle is empty.