QGIS API Documentation  3.8.0-Zanzibar (11aff65)
qgsgeometrychecker.h
Go to the documentation of this file.
1 /***************************************************************************
2  * qgsgeometrychecker.h *
3  * ------------------- *
4  * copyright : (C) 2014 by Sandro Mani / Sourcepole AG *
5  * email : [email protected] *
6  ***************************************************************************/
7 
8 /***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #define SIP_NO_FILE
18 
19 #ifndef QGS_GEOMETRY_CHECKER_H
20 #define QGS_GEOMETRY_CHECKER_H
21 
22 #include <QFuture>
23 #include <QList>
24 #include <QMutex>
25 #include <QStringList>
26 
27 #include "qgis_analysis.h"
28 #include "qgsfeedback.h"
29 #include "qgsfeatureid.h"
30 
31 typedef qint64 QgsFeatureId;
33 class QgsGeometryCheck;
35 class QgsMapLayer;
36 class QgsVectorLayer;
37 class QgsFeaturePool;
38 class QMutex;
39 
47 class ANALYSIS_EXPORT QgsGeometryChecker : public QObject
48 {
49  Q_OBJECT
50  public:
51  QgsGeometryChecker( const QList<QgsGeometryCheck *> &checks, QgsGeometryCheckContext *context SIP_TRANSFER, const QMap<QString, QgsFeaturePool *> &featurePools );
52  ~QgsGeometryChecker() override;
53  QFuture<void> execute( int *totalSteps = nullptr );
54  bool fixError( QgsGeometryCheckError *error, int method, bool triggerRepaint = false );
55  const QList<QgsGeometryCheck *> getChecks() const { return mChecks; }
56  QStringList getMessages() const { return mMessages; }
57  void setMergeAttributeIndices( const QMap<QString, int> &mergeAttributeIndices ) { mMergeAttributeIndices = mergeAttributeIndices; }
58  QgsGeometryCheckContext *getContext() const { return mContext; }
59  const QMap<QString, QgsFeaturePool *> featurePools() const {return mFeaturePools;}
60 
61  signals:
62  void errorAdded( QgsGeometryCheckError *error );
63  void errorUpdated( QgsGeometryCheckError *error, bool statusChanged );
64  void progressValue( int value );
65 
66  private:
67  class RunCheckWrapper
68  {
69  public:
70  explicit RunCheckWrapper( QgsGeometryChecker *instance );
71  void operator()( const QgsGeometryCheck *check );
72  private:
73  QgsGeometryChecker *mInstance = nullptr;
74  };
75 
76  QList<QgsGeometryCheck *> mChecks;
77  QgsGeometryCheckContext *mContext = nullptr;
78  QList<QgsGeometryCheckError *> mCheckErrors;
79  QStringList mMessages;
80  QMutex mErrorListMutex;
81  QMap<QString, int> mMergeAttributeIndices;
82  QgsFeedback mFeedback;
83  QMap<QString, QgsFeaturePool *> mFeaturePools;
84 
85  void runCheck( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheck *check );
86 
87  private slots:
88  void emitProgressValue();
89 };
90 
91 #endif // QGS_GEOMETRY_CHECKER_H
Base class for all map layer types.
Definition: qgsmaplayer.h:78
QStringList getMessages() const
const QMap< QString, QgsFeaturePool * > featurePools() const
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Definition: qgsfeedback.h:44
Base configuration for geometry checks.
Manages and runs a set of geometry checks.
void setMergeAttributeIndices(const QMap< QString, int > &mergeAttributeIndices)
#define SIP_TRANSFER
Definition: qgis_sip.h:36
This class implements a geometry check.
const QList< QgsGeometryCheck * > getChecks() const
A feature pool is based on a vector layer and caches features.
QgsGeometryCheckContext * getContext() const
This represents an error reported by a geometry check.
Represents a vector layer which manages a vector based data sets.
qint64 QgsFeatureId