Skip to content

Commit

Permalink
Add checkType() method to all checks
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 30, 2018
1 parent e63526f commit 6a5a602
Show file tree
Hide file tree
Showing 20 changed files with 69 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/analysis/vector/geometry_checker/qgsgeometryareacheck.h
Expand Up @@ -40,9 +40,9 @@ class ANALYSIS_EXPORT QgsGeometryAreaCheck : public QgsGeometryCheck

static QList<QgsWkbTypes::GeometryType> factoryCompatibleGeometryTypes() {return {QgsWkbTypes::PolygonGeometry}; }
static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); }
QString factoryDescription() const { return tr( "Minimal area" ); }
static QString factoryDescription() { return tr( "Minimal area" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometryAreaCheck" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometryAreaCheck" ); }
static QgsGeometryCheck::CheckType factoryCheckType() { return QgsGeometryCheck::FeatureCheck; }

private:
Expand Down
Expand Up @@ -42,7 +42,7 @@ class ANALYSIS_EXPORT QgsGeometryContainedCheckError : public QgsGeometryCheckEr
static_cast<QgsGeometryContainedCheckError *>( other )->containingFeature() == containingFeature();
}

QString factoryDescription() const { return QApplication::translate( "QgsGeometryContainedCheckError", "Within feature" ); }
static QString factoryDescription() { return QApplication::translate( "QgsGeometryContainedCheckError", "Within feature" ); }
QString description() const override { return factoryDescription(); }

private:
Expand Down
13 changes: 8 additions & 5 deletions src/analysis/vector/geometry_checker/qgsgeometrydanglecheck.h
Expand Up @@ -26,16 +26,19 @@ class ANALYSIS_EXPORT QgsGeometryDangleCheck : public QgsGeometryCheck
QgsGeometryDangleCheck( QgsGeometryCheckContext *context, const QVariantMap &configuration )
: QgsGeometryCheck( context, configuration )
{}
static QList<QgsWkbTypes::GeometryType> factoryCompatibleGeometryTypes() {return {QgsWkbTypes::LineGeometry}; }
static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); }
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;

QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Dangle" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometryDangleCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }

static QList<QgsWkbTypes::GeometryType> factoryCompatibleGeometryTypes() {return {QgsWkbTypes::LineGeometry}; }
static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); }
static QString factoryDescription() { return tr( "Dangle" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometryDangleCheck" ); }
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;

enum ResolutionMethod { NoChange };
Expand Down
Expand Up @@ -27,16 +27,20 @@ class ANALYSIS_EXPORT QgsGeometryDegeneratePolygonCheck : public QgsGeometryChec

explicit QgsGeometryDegeneratePolygonCheck( QgsGeometryCheckContext *context, const QVariantMap &configuration )
: QgsGeometryCheck( context, configuration ) {}
static QList<QgsWkbTypes::GeometryType> factoryCompatibleGeometryTypes() {return {QgsWkbTypes::PolygonGeometry}; }
static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); }
QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }

void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;

QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Polygon with less than three nodes" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometryDegeneratePolygonCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }

static QList<QgsWkbTypes::GeometryType> factoryCompatibleGeometryTypes() {return {QgsWkbTypes::PolygonGeometry}; }
static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); }
static QString factoryDescription() { return tr( "Polygon with less than three nodes" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometryDegeneratePolygonCheck" ); }
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;

private:
Expand Down
Expand Up @@ -62,6 +62,7 @@ class ANALYSIS_EXPORT QgsGeometryDuplicateCheck : public QgsGeometryCheck
QStringList resolutionMethods() const override;
QString description() const override { return factoryDescription(); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }

static QList<QgsWkbTypes::GeometryType> factoryCompatibleGeometryTypes() {return {QgsWkbTypes::PointGeometry, QgsWkbTypes::LineGeometry, QgsWkbTypes::PolygonGeometry}; }
static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); }
Expand Down
Expand Up @@ -31,10 +31,11 @@ class ANALYSIS_EXPORT QgsGeometryDuplicateNodesCheck : public QgsGeometryCheck
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Duplicate node" ); }
static QString factoryDescription() { return tr( "Duplicate node" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometryDuplicateNodesCheck" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometryDuplicateNodesCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;

enum ResolutionMethod { RemoveDuplicates, NoChange };
Expand Down
Expand Up @@ -34,10 +34,11 @@ class ANALYSIS_EXPORT QgsGeometryFollowBoundariesCheck : public QgsGeometryCheck
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Polygon does not follow boundaries" ); }
static QString factoryDescription() { return tr( "Polygon does not follow boundaries" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometryFollowBoundariesCheck" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometryFollowBoundariesCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;
private:
enum ResolutionMethod { NoChange };
Expand Down
5 changes: 3 additions & 2 deletions src/analysis/vector/geometry_checker/qgsgeometryholecheck.h
Expand Up @@ -31,10 +31,11 @@ class ANALYSIS_EXPORT QgsGeometryHoleCheck : public QgsGeometryCheck
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Polygon with hole" ); }
static QString factoryDescription() { return tr( "Polygon with hole" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometryHoleCheck" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometryHoleCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
static QgsGeometryCheck::CheckType factoryCheckType() { return QgsGeometryCheck::FeatureCheck; }

enum ResolutionMethod { RemoveHoles, NoChange };
Expand Down
Expand Up @@ -32,10 +32,11 @@ class ANALYSIS_EXPORT QgsGeometryLineIntersectionCheck : public QgsGeometryCheck
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Intersection" ); }
static QString factoryDescription() { return tr( "Intersection" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometryLineIntersectionCheck" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometryLineIntersectionCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;

enum ResolutionMethod { NoChange };
Expand Down
Expand Up @@ -33,10 +33,11 @@ class ANALYSIS_EXPORT QgsGeometryLineLayerIntersectionCheck : public QgsGeometry
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Intersection" ); }
static QString factoryDescription() { return tr( "Intersection" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometryLineLayerIntersectionCheck" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometryLineLayerIntersectionCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;

enum ResolutionMethod { NoChange };
Expand Down
Expand Up @@ -32,10 +32,11 @@ class ANALYSIS_EXPORT QgsGeometryMultipartCheck : public QgsSingleGeometryCheck
QList<QgsSingleGeometryCheckError *> processGeometry( const QgsGeometry &geometry ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Multipart object with only one feature" ); }
static QString factoryDescription() { return tr( "Multipart object with only one feature" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometryMultipartCheck" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometryMultipartCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
static QgsGeometryCheck::CheckType factoryCheckType() { return QgsGeometryCheck::FeatureCheck; }

enum ResolutionMethod { ConvertToSingle, RemoveObject, NoChange };
Expand Down
Expand Up @@ -250,6 +250,11 @@ QgsGeometryOverlapCheckError::QgsGeometryOverlapCheckError( const QgsGeometryChe

}

QString QgsGeometryOverlapCheckError::description() const
{
return QCoreApplication::translate( "QgsGeometryTypeCheckError", "Overlap with %1:%2" ).arg( mOverlappedFeature.first, QString::number( mOverlappedFeature.second ) );
}

QgsGeometryCheck::CheckType QgsGeometryOverlapCheck::factoryCheckType()
{
return QgsGeometryCheck::LayerCheck;
Expand Down
Expand Up @@ -63,8 +63,7 @@ class ANALYSIS_EXPORT QgsGeometryOverlapCheckError : public QgsGeometryCheckErro
return true;
}

QString factoryDescription() const { return QApplication::translate( "QgsGeometryTypeCheckError", "Overlap with %1:%2" ).arg( mOverlappedFeature.first ).arg( mOverlappedFeature.second ); }
QString description() const override { return factoryDescription(); }
QString description() const override;

private:
QPair<QString, QgsFeatureId> mOverlappedFeature;
Expand Down
Expand Up @@ -32,10 +32,11 @@ class ANALYSIS_EXPORT QgsGeometryPointCoveredByLineCheck : public QgsGeometryChe
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Point not covered by line" ); }
static QString factoryDescription() { return tr( "Point not covered by line" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometryPointCoveredByLineCheck" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometryPointCoveredByLineCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;

enum ResolutionMethod { NoChange };
Expand Down
Expand Up @@ -32,10 +32,11 @@ class ANALYSIS_EXPORT QgsGeometryPointInPolygonCheck : public QgsGeometryCheck
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Point not in polygon" ); }
static QString factoryDescription() { return tr( "Point not in polygon" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometryPointInPolygonCheck" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometryPointInPolygonCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;

enum ResolutionMethod { NoChange };
Expand Down
Expand Up @@ -33,10 +33,11 @@ class ANALYSIS_EXPORT QgsGeometrySegmentLengthCheck : public QgsGeometryCheck
void collectErrors( const QMap<QString, QgsFeaturePool *> &featurePools, QList<QgsGeometryCheckError *> &errors, QStringList &messages, QgsFeedback *feedback = nullptr, const LayerFeatureIds &ids = LayerFeatureIds() ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Minimal segment length" ); }
static QString factoryDescription() { return tr( "Minimal segment length" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometrySegmentLengthCheck" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometrySegmentLengthCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;

enum ResolutionMethod { NoChange };
Expand Down
Expand Up @@ -31,10 +31,11 @@ class ANALYSIS_EXPORT QgsGeometrySelfContactCheck : public QgsSingleGeometryChec
QList<QgsSingleGeometryCheckError *> processGeometry( const QgsGeometry &geometry ) const override;
void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes & ) const override;
QStringList resolutionMethods() const override;
QString factoryDescription() const { return tr( "Self contact" ); }
static QString factoryDescription() { return tr( "Self contact" ); }
QString description() const override { return factoryDescription(); }
QString factoryId() const { return QStringLiteral( "QgsGeometrySelfContactCheck" ); }
static QString factoryId() { return QStringLiteral( "QgsGeometrySelfContactCheck" ); }
QString id() const override { return factoryId(); }
QgsGeometryCheck::CheckType checkType() const override { return factoryCheckType(); }
static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;

enum ResolutionMethod { NoChange };
Expand Down

0 comments on commit 6a5a602

Please sign in to comment.