22QString QgsCopyLayerMetadataAlgorithm::name()
const
24 return QStringLiteral(
"copylayermetadata" );
27QString QgsCopyLayerMetadataAlgorithm::displayName()
const
29 return QObject::tr(
"Copy layer metadata" );
32QStringList QgsCopyLayerMetadataAlgorithm::tags()
const
34 return QObject::tr(
"change,layer,metadata,qmd" ).split(
',' );
37QString QgsCopyLayerMetadataAlgorithm::group()
const
39 return QObject::tr(
"Metadata tools" );
42QString QgsCopyLayerMetadataAlgorithm::groupId()
const
44 return QStringLiteral(
"metadatatools" );
47QString QgsCopyLayerMetadataAlgorithm::shortHelpString()
const
49 return QObject::tr(
"Copies metadata from an source layer to a target layer.\n\nAny existing metadata in the target layer will be replaced." );
52QgsCopyLayerMetadataAlgorithm *QgsCopyLayerMetadataAlgorithm::createInstance()
const
54 return new QgsCopyLayerMetadataAlgorithm();
57void QgsCopyLayerMetadataAlgorithm::initAlgorithm(
const QVariantMap & )
67 QgsMapLayer *sourceLayer = parameterAsLayer( parameters, QStringLiteral(
"SOURCE" ), context );
68 QgsMapLayer *targetLayer = parameterAsLayer( parameters, QStringLiteral(
"TARGET" ), context );
69 const bool saveAsDefault = parameterAsBool( parameters, QStringLiteral(
"DEFAULT" ), context );
77 mLayerId = targetLayer->
id();
94 Q_UNUSED( parameters );
98 results.insert( QStringLiteral(
"OUTPUT" ), mLayerId );
104QString QgsApplyLayerMetadataAlgorithm::name()
const
106 return QStringLiteral(
"setlayermetadata" );
109QString QgsApplyLayerMetadataAlgorithm::displayName()
const
111 return QObject::tr(
"Set layer metadata" );
114QStringList QgsApplyLayerMetadataAlgorithm::tags()
const
116 return QObject::tr(
"change,layer,metadata,qmd" ).split(
',' );
119QString QgsApplyLayerMetadataAlgorithm::group()
const
121 return QObject::tr(
"Metadata tools" );
124QString QgsApplyLayerMetadataAlgorithm::groupId()
const
126 return QStringLiteral(
"metadatatools" );
129QString QgsApplyLayerMetadataAlgorithm::shortHelpString()
const
131 return QObject::tr(
"Applies the metadata to a layer. The metadata must be defined as QMD file.\n\nAny existing metadata in the layer will be replaced." );
134QgsApplyLayerMetadataAlgorithm *QgsApplyLayerMetadataAlgorithm::createInstance()
const
136 return new QgsApplyLayerMetadataAlgorithm();
139void QgsApplyLayerMetadataAlgorithm::initAlgorithm(
const QVariantMap & )
149 QgsMapLayer *layer = parameterAsLayer( parameters, QStringLiteral(
"INPUT" ), context );
150 const QString metadata = parameterAsFile( parameters, QStringLiteral(
"METADATA" ), context );
151 const bool saveAsDefault = parameterAsBool( parameters, QStringLiteral(
"DEFAULT" ), context );
156 mLayerId = layer->
id();
180 Q_UNUSED( parameters );
184 results.insert( QStringLiteral(
"OUTPUT" ), mLayerId );
190QString QgsExportLayerMetadataAlgorithm::name()
const
192 return QStringLiteral(
"exportlayermetadata" );
195QString QgsExportLayerMetadataAlgorithm::displayName()
const
197 return QObject::tr(
"Export layer metadata" );
200QStringList QgsExportLayerMetadataAlgorithm::tags()
const
202 return QObject::tr(
"export,layer,metadata,qmd" ).split(
',' );
205QString QgsExportLayerMetadataAlgorithm::group()
const
207 return QObject::tr(
"Metadata tools" );
210QString QgsExportLayerMetadataAlgorithm::groupId()
const
212 return QStringLiteral(
"metadatatools" );
215QString QgsExportLayerMetadataAlgorithm::shortHelpString()
const
217 return QObject::tr(
"Exports layer's metadata to a QMD file." );
220QgsExportLayerMetadataAlgorithm *QgsExportLayerMetadataAlgorithm::createInstance()
const
222 return new QgsExportLayerMetadataAlgorithm();
225void QgsExportLayerMetadataAlgorithm::initAlgorithm(
const QVariantMap & )
228 addParameter(
new QgsProcessingParameterFileDestination( QStringLiteral(
"OUTPUT" ), QObject::tr(
"Output" ), QObject::tr(
"QGIS Metadata File" ) + QStringLiteral(
" (*.qmd *.QMD)" ) ) );
233 QgsMapLayer *layer = parameterAsLayer( parameters, QStringLiteral(
"INPUT" ), context );
234 const QString outputFile = parameterAsString( parameters, QStringLiteral(
"OUTPUT" ), context );
247 results.insert( QStringLiteral(
"OUTPUT" ), outputFile );
253QString QgsAddHistoryMetadataAlgorithm::name()
const
255 return QStringLiteral(
"addhistorymetadata" );
258QString QgsAddHistoryMetadataAlgorithm::displayName()
const
260 return QObject::tr(
"Add history metadata" );
263QStringList QgsAddHistoryMetadataAlgorithm::tags()
const
265 return QObject::tr(
"add,history,metadata" ).split(
',' );
268QString QgsAddHistoryMetadataAlgorithm::group()
const
270 return QObject::tr(
"Metadata tools" );
273QString QgsAddHistoryMetadataAlgorithm::groupId()
const
275 return QStringLiteral(
"metadatatools" );
278QString QgsAddHistoryMetadataAlgorithm::shortHelpString()
const
280 return QObject::tr(
"Adds a new history entry to the layer's metadata." );
283QgsAddHistoryMetadataAlgorithm *QgsAddHistoryMetadataAlgorithm::createInstance()
const
285 return new QgsAddHistoryMetadataAlgorithm();
288void QgsAddHistoryMetadataAlgorithm::initAlgorithm(
const QVariantMap & )
297 QgsMapLayer *layer = parameterAsLayer( parameters, QStringLiteral(
"INPUT" ), context );
298 const QString history = parameterAsString( parameters, QStringLiteral(
"HISTORY" ), context );
303 mLayerId = layer->
id();
305 std::unique_ptr<QgsLayerMetadata> md( layer->
metadata().
clone() );
306 md->addHistoryItem( history );
314 Q_UNUSED( parameters );
318 results.insert( QStringLiteral(
"OUTPUT" ), mLayerId );
324QString QgsUpdateLayerMetadataAlgorithm::name()
const
326 return QStringLiteral(
"updatelayermetadata" );
329QString QgsUpdateLayerMetadataAlgorithm::displayName()
const
331 return QObject::tr(
"Update layer metadata" );
334QStringList QgsUpdateLayerMetadataAlgorithm::tags()
const
336 return QObject::tr(
"change,update,layer,metadata,qmd" ).split(
',' );
339QString QgsUpdateLayerMetadataAlgorithm::group()
const
341 return QObject::tr(
"Metadata tools" );
344QString QgsUpdateLayerMetadataAlgorithm::groupId()
const
346 return QStringLiteral(
"metadatatools" );
349QString QgsUpdateLayerMetadataAlgorithm::shortHelpString()
const
351 return QObject::tr(
"Copies all non-empty metadata fields from an source layer to a target layer.\n\nLeaves empty input fields unchanged in the target." );
354QgsUpdateLayerMetadataAlgorithm *QgsUpdateLayerMetadataAlgorithm::createInstance()
const
356 return new QgsUpdateLayerMetadataAlgorithm();
359void QgsUpdateLayerMetadataAlgorithm::initAlgorithm(
const QVariantMap & )
368 QgsMapLayer *sourceLayer = parameterAsLayer( parameters, QStringLiteral(
"SOURCE" ), context );
369 QgsMapLayer *targetLayer = parameterAsLayer( parameters, QStringLiteral(
"TARGET" ), context );
377 mLayerId = targetLayer->
id();
379 std::unique_ptr<QgsLayerMetadata> md( targetLayer->
metadata().
clone() );
380 md->combine( &sourceLayer->
metadata() );
388 Q_UNUSED( parameters );
392 results.insert( QStringLiteral(
"OUTPUT" ), mLayerId );
398QString QgsSetMetadataFieldsAlgorithm::name()
const
400 return QStringLiteral(
"setmetadatafields" );
403QString QgsSetMetadataFieldsAlgorithm::displayName()
const
405 return QObject::tr(
"Set metadata fields" );
408QStringList QgsSetMetadataFieldsAlgorithm::tags()
const
410 return QObject::tr(
"set,metadata,title,abstract,identifier" ).split(
',' );
413QString QgsSetMetadataFieldsAlgorithm::group()
const
415 return QObject::tr(
"Metadata tools" );
418QString QgsSetMetadataFieldsAlgorithm::groupId()
const
420 return QStringLiteral(
"metadatatools" );
423QString QgsSetMetadataFieldsAlgorithm::shortHelpString()
const
425 return QObject::tr(
"Sets various metadata fields for a layer." );
428QgsSetMetadataFieldsAlgorithm *QgsSetMetadataFieldsAlgorithm::createInstance()
const
430 return new QgsSetMetadataFieldsAlgorithm();
433void QgsSetMetadataFieldsAlgorithm::initAlgorithm(
const QVariantMap & )
436 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"IDENTIFIER" ), QObject::tr(
"Identifier" ), QVariant(),
false,
true ) );
437 addParameter(
new QgsProcessingParameterString( QStringLiteral(
"PARENT_IDENTIFIER" ), QObject::tr(
"Parent identifier" ), QVariant(),
false,
true ) );
443 addParameter(
new QgsProcessingParameterCrs( QStringLiteral(
"CRS" ), QObject::tr(
"Coordinatem reference system" ), QVariant(),
true ) );
451 QgsMapLayer *layer = parameterAsLayer( parameters, QStringLiteral(
"INPUT" ), context );
456 mLayerId = layer->
id();
458 const bool ignoreEmpty = parameterAsBool( parameters, QStringLiteral(
"IGNORE_EMPTY" ), context );
460 std::unique_ptr<QgsLayerMetadata> md( layer->
metadata().
clone() );
462 if ( parameters.value( QStringLiteral(
"IDENTIFIER" ) ).isValid() )
464 const QString identifier = parameterAsString( parameters, QStringLiteral(
"IDENTIFIER" ), context );
465 if ( !identifier.isEmpty() || !ignoreEmpty )
467 md->setIdentifier( identifier );
471 if ( parameters.value( QStringLiteral(
"PARENT_IDENTIFIER" ) ).isValid() )
473 const QString parentIdentifier = parameterAsString( parameters, QStringLiteral(
"PARENT_IDENTIFIER" ), context );
474 if ( !parentIdentifier.isEmpty() || !ignoreEmpty )
476 md->setParentIdentifier( parentIdentifier );
480 if ( parameters.value( QStringLiteral(
"TITLE" ) ).isValid() )
482 const QString title = parameterAsString( parameters, QStringLiteral(
"TITLE" ), context );
483 if ( !title.isEmpty() || !ignoreEmpty )
485 md->setTitle( title );
489 if ( parameters.value( QStringLiteral(
"TYPE" ) ).isValid() )
491 const QString type = parameterAsString( parameters, QStringLiteral(
"TYPE" ), context );
492 if ( !type.isEmpty() || !ignoreEmpty )
498 if ( parameters.value( QStringLiteral(
"LANGUAGE" ) ).isValid() )
500 const QString language = parameterAsString( parameters, QStringLiteral(
"LANGUAGE" ), context );
501 if ( !language.isEmpty() || !ignoreEmpty )
503 md->setLanguage( language );
507 if ( parameters.value( QStringLiteral(
"ENCODING" ) ).isValid() )
509 const QString encoding = parameterAsString( parameters, QStringLiteral(
"ENCODING" ), context );
510 if ( !encoding.isEmpty() || !ignoreEmpty )
512 md->setEncoding( encoding );
516 if ( parameters.value( QStringLiteral(
"ABSTRACT" ) ).isValid() )
518 const QString abstract = parameterAsString( parameters, QStringLiteral(
"ABSTRACT" ), context );
519 if ( !abstract.isEmpty() || !ignoreEmpty )
521 md->setAbstract( abstract );
525 if ( parameters.value( QStringLiteral(
"CRS" ) ).isValid() )
534 if ( parameters.value( QStringLiteral(
"FEES" ) ).isValid() )
536 const QString fees = parameterAsString( parameters, QStringLiteral(
"FEES" ), context );
537 if ( !fees.isEmpty() || !ignoreEmpty )
550 Q_UNUSED( parameters );
554 results.insert( QStringLiteral(
"OUTPUT" ), mLayerId );
@ File
Parameter is a single file.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Base class for all map layer types.
virtual QString loadNamedMetadata(const QString &uri, bool &resultFlag)
Retrieve a named metadata for this layer if one exists (either as a .qmd file on disk or as a record ...
QgsLayerMetadata metadata
virtual void setMetadata(const QgsLayerMetadata &metadata)
Sets the layer's metadata store.
virtual QString saveDefaultMetadata(bool &resultFlag)
Save the current metadata of this layer as the default metadata (either as a .qmd file on disk or as ...
QString saveNamedMetadata(const QString &uri, bool &resultFlag)
Save the current metadata of this layer as a named metadata (either as a .qmd file on disk or as a re...
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
A map layer output for processing algorithms, where layers may be either vector or raster.
A boolean parameter for processing algorithms.
A coordinate reference system parameter for processing algorithms.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
An input file or folder parameter for processing algorithms.
A map layer parameter for processing algorithms.
A string parameter for processing algorithms.
const QgsCoordinateReferenceSystem & crs