QGIS API Documentation  3.8.0-Zanzibar (11aff65)
qgsgeometrytypecheck.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgeometrytypecheck.h
3  ---------------------
4  begin : September 2015
5  copyright : (C) 2014 by Sandro Mani / Sourcepole AG
6  email : smani at sourcepole dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #define SIP_NO_FILE
17 
18 #ifndef QGS_GEOMETRY_TYPE_CHECK_H
19 #define QGS_GEOMETRY_TYPE_CHECK_H
20 
21 #include "qgssinglegeometrycheck.h"
22 
27 {
28  public:
30  const QgsGeometry &geometry,
31  const QgsGeometry &errorLocation,
32  QgsWkbTypes::Type flatType )
33  : QgsSingleGeometryCheckError( check, geometry, errorLocation )
34  , mFlatType( flatType )
35  {
36  }
37 
38  bool isEqual( const QgsSingleGeometryCheckError *other ) const override;
39 
40  QString description() const override;
41 
42  private:
43  QgsWkbTypes::Type mFlatType;
44 };
45 
49 class ANALYSIS_EXPORT QgsGeometryTypeCheck : public QgsSingleGeometryCheck
50 {
51  public:
52  QgsGeometryTypeCheck( QgsGeometryCheckContext *context, const QVariantMap &configuration, int allowedTypes )
53  : QgsSingleGeometryCheck( context, configuration )
54  , mAllowedTypes( allowedTypes )
55  {}
56  QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }
57  QList<QgsSingleGeometryCheckError *> processGeometry( const QgsGeometry &geometry ) const override;
58  void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
59  QStringList resolutionMethods() const override;
60  QString description() const override;
61  QString id() const override;
62  QgsGeometryCheck::CheckType checkType() const override;
63 
65  static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); }
66  static QString factoryDescription() SIP_SKIP;
67  static QString factoryId() SIP_SKIP;
68  static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;
69 
70  private:
71  enum ResolutionMethod { Convert, Delete, NoChange };
72  int mAllowedTypes;
73 };
74 
75 #endif // QGS_GEOMETRY_TYPE_CHECK_H
QgsGeometryTypeCheck(QgsGeometryCheckContext *context, const QVariantMap &configuration, int allowedTypes)
static bool factoryIsCompatible(QgsVectorLayer *layer)
virtual bool isEqual(const QgsSingleGeometryCheckError *other) const
Check if this error is equal to other.
CheckType
The type of a check.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:111
Base class for geometry checks for a single geometry without any context of the layer or other layers...
static QList< QgsWkbTypes::GeometryType > factoryCompatibleGeometryTypes()
Base configuration for geometry checks.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:68
#define SIP_SKIP
Definition: qgis_sip.h:119
virtual CheckType checkType() const =0
Returns the check type.
QgsGeometryTypeCheckError(const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, QgsWkbTypes::Type flatType)
virtual QString id() const =0
Returns an id for this check.
An error from a QgsSingleGeometryCheck.
virtual QString description() const
A human readable description of this error.
QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const override
A list of geometry types for which this check can be performed.
QMap< QString, QMap< QgsFeatureId, QList< QgsGeometryCheck::Change > > > Changes
A collection of changes.
virtual QString description() const =0
Returns a human readable description for this check.
virtual void fixError(const QMap< QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap< QString, int > &mergeAttributeIndices, Changes &changes) const
Fix the error error with the specified method.
virtual QList< QgsSingleGeometryCheckError * > processGeometry(const QgsGeometry &geometry) const =0
Check the geometry for errors.
virtual QStringList resolutionMethods() const =0
Returns a list of descriptions for available resolutions for errors.
This represents an error reported by a geometry check.
Represents a vector layer which manages a vector based data sets.