24 QString QgsGeometryDuplicateCheckError::duplicatesString(
const QMap<QString, QgsFeaturePool *> &featurePools,
const QMap<QString, QList<QgsFeatureId>> &duplicates )
29 str.append( featurePools[it.key()]->layer()->name() +
":" );
31 ids.reserve( it.value().length() );
34 ids.append( QString::number(
id ) );
36 str.back() += ids.join(
',' );
38 return str.join( QStringLiteral(
"; " ) );
46 QList<QString> layerIds = featureIds.keys();
50 layerIds.removeOne( layerFeatureA.layer()->id() );
55 if ( !geomEngineA->isValid() )
57 messages.append( tr(
"Duplicate check failed for (%1): the geometry is invalid" ).arg( layerFeatureA.id() ) );
60 QMap<QString, QList<QgsFeatureId>> duplicates;
67 if ( layerFeatureA.layer()->id() == layerFeatureB.layer()->id() && layerFeatureB.feature().id() >= layerFeatureA.feature().id() )
73 std::unique_ptr<QgsAbstractGeometry> diffGeom( geomEngineA->symDifference( geomB.
constGet(), &errMsg ) );
74 if ( errMsg.isEmpty() && diffGeom && diffGeom->isEmpty() )
76 duplicates[layerFeatureB.layer()->id()].append( layerFeatureB.feature().id() );
78 else if ( !errMsg.isEmpty() )
80 messages.append( tr(
"Duplicate check failed for (%1, %2): %3" ).arg( layerFeatureA.id(), layerFeatureB.id(), errMsg ) );
83 if ( !duplicates.isEmpty() )
110 const QMap<QString, QList<QgsFeatureId>> duplicates = duplicateError->
duplicates();
111 for (
auto it = duplicates.constBegin(); it != duplicates.constEnd(); ++it )
113 const QString layerIdB = it.key();
115 const QList< QgsFeatureId > ids = it.value();
119 if ( !featurePoolB->
getFeature( idB, featureB ) )
125 if ( diffGeom && diffGeom->
isEmpty() )
144 static QStringList methods = QStringList()
146 << tr(
"Remove duplicates" );
152 return QStringLiteral(
"QgsGeometryDuplicateCheck" );