-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsgeometryduplicatecheck.h
62 lines (52 loc) · 2.61 KB
/
qgsgeometryduplicatecheck.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/***************************************************************************
* qgsgeometryduplicatecheck.h *
* ------------------- *
* copyright : (C) 2014 by Sandro Mani / Sourcepole AG *
* email : smani@sourcepole.ch *
***************************************************************************/
#ifndef QGS_GEOMETRY_DUPLICATE_CHECK_H
#define QGS_GEOMETRY_DUPLICATE_CHECK_H
#include "qgsgeometrycheck.h"
class QgsGeometryDuplicateCheckError : public QgsGeometryCheckError
{
public:
QgsGeometryDuplicateCheckError( const QgsGeometryCheck* check,
const QgsFeatureId& featureId,
const QgsPointV2& errorLocation,
const QList<QgsFeatureId>& duplicates )
: QgsGeometryCheckError( check, featureId, errorLocation, QgsVertexId(), duplicatesString( duplicates ) ), mDuplicates( duplicates ) { }
const QList<QgsFeatureId>& duplicates() const { return mDuplicates; }
bool isEqual( QgsGeometryCheckError* other ) const override
{
return other->check() == check() &&
other->featureId() == featureId() &&
// static_cast: since other->checker() == checker is only true if the types are actually the same
static_cast<QgsGeometryDuplicateCheckError*>( other )->duplicates() == duplicates();
}
private:
QList<QgsFeatureId> mDuplicates;
static inline QString duplicatesString( const QList<QgsFeatureId>& duplicates )
{
QStringList str;
foreach ( QgsFeatureId id, duplicates )
{
str.append( QString::number( id ) );
}
return str.join( ", " );
}
};
class QgsGeometryDuplicateCheck : public QgsGeometryCheck
{
Q_OBJECT
public:
QgsGeometryDuplicateCheck( QgsFeaturePool* featurePool )
: QgsGeometryCheck( FeatureCheck, featurePool ) {}
void collectErrors( QList<QgsGeometryCheckError*>& errors, QStringList &messages, QAtomicInt* progressCounter = 0, const QgsFeatureIds& ids = QgsFeatureIds() ) const override;
void fixError( QgsGeometryCheckError* error, int method, int mergeAttributeIndex, Changes& changes ) const override;
const QStringList& getResolutionMethods() const override;
QString errorDescription() const override { return tr( "Duplicate" ); }
QString errorName() const override { return "QgsGeometryDuplicateCheck"; }
private:
enum ResolutionMethod { NoChange, RemoveDuplicates };
};
#endif // QGS_GEOMETRY_DUPLICATE_CHECK_H