Skip to content
Permalink
Browse files

Inform that "Merge vector" allows mixed attribute type

Also add a short description and make the field type conversion less silent
  • Loading branch information
DelazJ authored and nyalldawson committed Dec 15, 2020
1 parent 6cef22b commit b465fd14bbb81822f031f4ef9cced5a2e36a2162
@@ -52,11 +52,17 @@ void QgsMergeVectorAlgorithm::initAlgorithm( const QVariantMap & )
addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT" ), QObject::tr( "Merged" ) ) );
}

QString QgsMergeVectorAlgorithm::shortDescription() const
{
return QObject::tr( "Combines multiple vector layers of the same geometry type into a single one." );
}

QString QgsMergeVectorAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm combines multiple vector layers of the same geometry type into a single one.\n\n"
"If attributes tables are different, the attribute table of the resulting layer will contain the attributes "
"from all input layers. New attributes will be added for the original layer name and source.\n\n"
"The attribute table of the resulting layer will contain the fields from all input layers. "
"If fields with the same name but different types are found then the exported field will be automatically converted into a string type field. "
"New fields storing the original layer name and source are also added.\n\n"
"If any input layers contain Z or M values, then the output layer will also contain these values. Similarly, "
"if any of the input layers are multi-part, the output layer will also be a multi-part layer.\n\n"
"Optionally, the destination coordinate reference system (CRS) for the merged layer can be set. If it is not set, the CRS will be "
@@ -152,8 +158,9 @@ QVariantMap QgsMergeVectorAlgorithm::processAlgorithm( const QVariantMap &parame
found = true;
if ( destField.type() != sourceField.type() )
{
feedback->pushInfo( QObject::tr( "%1 field in layer %2 has different data type than the destination layer (%3 instead of %4)" )
.arg( sourceField.name(), vl->name(), sourceField.typeName(), destField.typeName() ) );
feedback->pushWarning( QObject::tr( "%1 field in layer %2 has different data type than the destination layer (%3 instead of %4). "
"%1 field will be converted to string type." )
.arg( sourceField.name(), vl->name(), sourceField.typeName(), destField.typeName() ) );
destField.setType( QVariant::String );
destField.setSubType( QVariant::Invalid );
destField.setLength( 0 );
@@ -43,6 +43,7 @@ class QgsMergeVectorAlgorithm : public QgsProcessingAlgorithm
QStringList tags() const override;
QString group() const override;
QString groupId() const override;
QString shortDescription() const override;
QString shortHelpString() const override;
QgsMergeVectorAlgorithm *createInstance() const override SIP_FACTORY;

0 comments on commit b465fd1

Please sign in to comment.