QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
28 {
29  public:
31  const QgsGeometry &geometry,
32  const QgsGeometry &errorLocation,
33  QgsWkbTypes::Type flatType )
34  : QgsSingleGeometryCheckError( check, geometry, errorLocation )
35  , mFlatType( flatType )
36  {
37  }
38 
39  bool isEqual( const QgsSingleGeometryCheckError *other ) const override;
40 
41  QString description() const override;
42 
43  private:
44  QgsWkbTypes::Type mFlatType;
45 };
46 
51 class ANALYSIS_EXPORT QgsGeometryTypeCheck : public QgsSingleGeometryCheck
52 {
53  Q_DECLARE_TR_FUNCTIONS( QgsGeometryTypeCheck )
54  public:
55  QgsGeometryTypeCheck( QgsGeometryCheckContext *context, const QVariantMap &configuration, int allowedTypes )
56  : QgsSingleGeometryCheck( context, configuration )
57  , mAllowedTypes( allowedTypes )
58  {}
59  QList<QgsWkbTypes::GeometryType> compatibleGeometryTypes() const override { return factoryCompatibleGeometryTypes(); }
60  QList<QgsSingleGeometryCheckError *> processGeometry( const QgsGeometry &geometry ) const override;
61  void fixError( const QMap<QString, QgsFeaturePool *> &featurePools, QgsGeometryCheckError *error, int method, const QMap<QString, int> &mergeAttributeIndices, Changes &changes ) const override;
62  Q_DECL_DEPRECATED QStringList resolutionMethods() const override;
63  QString description() const override;
64  QString id() const override;
65  QgsGeometryCheck::CheckType checkType() const override;
66 
68  static bool factoryIsCompatible( QgsVectorLayer *layer ) SIP_SKIP { return factoryCompatibleGeometryTypes().contains( layer->geometryType() ); }
69  static QString factoryDescription() SIP_SKIP;
70  static QString factoryId() SIP_SKIP;
71  static QgsGeometryCheck::CheckType factoryCheckType() SIP_SKIP;
72 
73  private:
74  enum ResolutionMethod { Convert, Delete, NoChange };
75  int mAllowedTypes;
76 };
77 
78 #endif // QGS_GEOMETRY_TYPE_CHECK_H
Base configuration for geometry checks.
This represents an error reported by a geometry check.
This class implements a geometry check.
CheckType
The type of a check.
A geometry type check error.
QgsGeometryTypeCheckError(const QgsSingleGeometryCheck *check, const QgsGeometry &geometry, const QgsGeometry &errorLocation, QgsWkbTypes::Type flatType)
A geometry type check.
static QList< QgsWkbTypes::GeometryType > factoryCompatibleGeometryTypes()
QList< QgsWkbTypes::GeometryType > compatibleGeometryTypes() const override
A list of geometry types for which this check can be performed.
QgsGeometryTypeCheck(QgsGeometryCheckContext *context, const QVariantMap &configuration, int allowedTypes)
static bool factoryIsCompatible(QgsVectorLayer *layer)
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:125
An error from a QgsSingleGeometryCheck.
virtual bool isEqual(const QgsSingleGeometryCheckError *other) const
Check if this error is equal to other.
virtual QString description() const
A human readable description of this error.
Base class for geometry checks for a single geometry without any context of the layer or other layers...
Represents a vector layer which manages a vector based data sets.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
#define SIP_SKIP
Definition: qgis_sip.h:126