QGIS/src/analysis/vector/geometry_checker/qgsgeometrychecker.h
Matthias Kuhn bee5470e10
Python bindings for QgsGeometryCheck and co
Adds

 - python bindings
 - geometry check factory
 - geometry check registry
 - QgsFeedback for geometry checks (lots of potential still)
 - An IsValid geometry check
 - Splits classes into their own files
 - Decouples feature pools from the configuration context
2018-09-28 13:33:24 +02:00

85 lines
3.2 KiB
C++

/***************************************************************************
* qgsgeometrychecker.h *
* ------------------- *
* copyright : (C) 2014 by Sandro Mani / Sourcepole AG *
* email : smani@sourcepole.ch *
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#define SIP_NO_FILE
#ifndef QGS_GEOMETRY_CHECKER_H
#define QGS_GEOMETRY_CHECKER_H
#include <QFuture>
#include <QList>
#include <QMutex>
#include <QStringList>
#include "qgis_analysis.h"
#include "qgsfeedback.h"
#include "qgsfeatureid.h"
typedef qint64 QgsFeatureId;
struct QgsGeometryCheckContext;
class QgsGeometryCheck;
class QgsGeometryCheckError;
class QgsMapLayer;
class QgsVectorLayer;
class QgsFeaturePool;
class QMutex;
class ANALYSIS_EXPORT QgsGeometryChecker : public QObject
{
Q_OBJECT
public:
QgsGeometryChecker( const QList<QgsGeometryCheck *> &checks, const QMap<QString, QgsFeaturePool *> &featurePools );
~QgsGeometryChecker() override;
QFuture<void> execute( int *totalSteps = nullptr );
bool fixError( QgsGeometryCheckError *error, int method, bool triggerRepaint = false );
const QList<QgsGeometryCheck *> getChecks() const { return mChecks; }
QStringList getMessages() const { return mMessages; }
void setMergeAttributeIndices( const QMap<QString, int> &mergeAttributeIndices ) { mMergeAttributeIndices = mergeAttributeIndices; }
QgsGeometryCheckContext *getContext() const { return mContext; }
const QMap<QString, QgsFeaturePool *> featurePools() const {return mFeaturePools;}
signals:
void errorAdded( QgsGeometryCheckError *error );
void errorUpdated( QgsGeometryCheckError *error, bool statusChanged );
void progressValue( int value );
private:
class RunCheckWrapper
{
public:
explicit RunCheckWrapper( QgsGeometryChecker *instance );
void operator()( const QgsGeometryCheck *check );
private:
QgsGeometryChecker *mInstance = nullptr;
};
QList<QgsGeometryCheck *> mChecks;
QgsGeometryCheckContext *mContext;
QList<QgsGeometryCheckError *> mCheckErrors;
QStringList mMessages;
QMutex mErrorListMutex;
QMap<QString, int> mMergeAttributeIndices;
QgsFeedback mFeedback;
QMap<QString, QgsFeaturePool *> mFeaturePools;
void runCheck( const QMap<QString, QgsFeaturePool *> &featurePools, const QgsGeometryCheck *check );
private slots:
void emitProgressValue();
};
#endif // QGS_GEOMETRY_CHECKER_H